Jump to content
Software FX Community

Recommended Posts

I'm using Chart FX Client Server DLL version. Development Tool is Visual

C++.

I was trying to use the attach method of annotation object. And don't know

how to pass the correct attachposition for the method. My code is as

follows:

void MyAttach(int x1,int y1,int x2, int y2)

{ VARIANT v;

wchar_t wcch[256];

V_VT(&v) = VT_BSTR | VT_BYREF;

swprintf(wcch,L"%d,%d,%d,%d",x1,y1,x2,y2);

V_BSTR(&v) = wcch;

pBalloon->Attach(ATTACH_ELASTIC, &v);

}

What's the problem with my code?

Any help would be appreciated,

Danqing

Link to post
Share on other sites

My application did crash  after I changed my code to:

V_VT(&v) = VT_BSTR;

V_BSTR(&v) = wcch;

Don't know why.

If I set x1 and y1 to some constant value, even without using x2 and y2, it

works. The working code is as follows:

x1=50;

y1=50;

swprintf(wcch,L"%d,%d",x1,y1);

V_VT(&v) = VT_BSTR | VT_BYREF;

V_BSTR(&v) = wcch;

pBalloon->Attach(ATTACH_ELASTIC,&v);

For the values of x1,y1,x2,y2, what are they respresent for when the

attachstyle equals to ATTACH_ELASTIC ?

I didn't find this information from the Extensions Reference. So could you

give more explaination on how to use this methond?

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:4WJ7Mu0LCHA.1984@webserver1.softwarefx.com...

> The problem is VT_BYREF, you are not passing a reference to a BSTR you

are

> passing the actual BSTR.

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

The following code attaches a rectangle, this code is tested in VC++

VARIANT v;

V_VT(&v) = VT_BSTR;

V_BSTR(&v) = SysAllocString(L"2,60,4,40");

rect->Attach(ATTACH_ELASTIC,&v);

VariantClear(&v);

The coordinates are interpreted as follows

The Left-Top corner is attached to 2,60; 2 being the X-Axis coordinate an 60

being the Y-Axis coordinate.

The Right-Bottom corner is attached to 4,40 (X = 4, Y = 40)

--

FP

Software FX, Inc.

Link to post
Share on other sites

So the Left-Top corner  is represented by (x1,y1) and the Right-Bottom

corner is represented by (x2,y2).

If I only attach one corner (eg. the Left-Top corner), what values I should

set for the other corner(eg. x2,y2) ?

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:trUPCpZMCHA.2748@webserver1.softwarefx.com...

> The following code attaches a rectangle, this code is tested in VC++

>

> VARIANT v;

> V_VT(&v) = VT_BSTR;

> V_BSTR(&v) = SysAllocString(L"2,60,4,40");

> rect->Attach(ATTACH_ELASTIC,&v);

> VariantClear(&v);

>

> The coordinates are interpreted as follows

>

> The Left-Top corner is attached to 2,60; 2 being the X-Axis coordinate an

60

> being the Y-Axis coordinate.

> The Right-Bottom corner is attached to 4,40 (X = 4, Y = 40)

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

But I need the object to be resized if the chart is resized.

The ATTACH_CENTER style won't allow resize the object.

For example, I want to attach a balloon to a data point ( X1 =525.25

Y1=1008.25 in axis coordinate). The left-top corner of the balloon is at the

same position of the data point. The chart coordinate(in pixels) for

left-top corner of the balloon is (left=100,top=200), the width and height

of the balloon are 20 and 16(in pixels). When the chart is resized, the

balloon should resized accordingly and should attached to the same data

point.

X2 and Y2 is represented by axis coordinate, and width and height are in

chart coordinate, then X2 and Y2 can't be calculated as follows:

X2 = X1+width

Y2 =Y1+height

So what is the right X2 and Y2 for using ATTACH_ELASTIC style?

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:fsLcK6cMCHA.1280@webserver1.softwarefx.com...

> Use ATTACH_CENTER to attach to just ONE coordinate

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

The confusion is caused by the different coordinates using in the same

annotation objects. The size and position of annotation object were defined

by pixels(in chart coordinates). But for the attach property of annotation

object, axis-based coordinates were required. I don't know how to convert

the right-bottom corner of annotation object from chart coordinate to

axis-based coordinates.

For my case, I have a XY plot in which the x-axis ranges from 0-10000 and

y-axis ranges from 0-10000. I want to attach an object(MyBalloon) to a data

point at (525.25,1008.25). Although I know the size and left-top corner of

MyBalloon, I have no idea about how to get the axis-based coordinate for the

right-bottom corner.

Any suggestion?

I wish I had explained my question clearly enough this time.

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:Qyi7rK1MCHA.1280@webserver1.softwarefx.com...

> Then you need to attach to BOTH corners (Elastic) so that the object can

be

> resized. I don't understand why the confusion.

>

> If you want the object to be resized use ATTACH_ELASTIC and specify both

> corners.

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

OK. You don't want to specify anything in pixels as you want the physical

size and position of the object to be variable (you said you wanted the

object to resize with the chart, right ?) so, don't use any of the

pixel-based property, namely Top,Left,Width and Height, instead use the

Attach method which receives LOGICAL coordinates.

It is really up to you what coordinates to pass. If your DataPoint is at

(525.25,1008.25) this is not enough info, you still need to tell me what

size the balloon is going to have in Logical coordinates (so that it resizes

with the chart), so add that size to (525.25,1008.25) and that will be the

second set of coordinates (Right,Bottom) of your annotation object. For

example:

obj.Attach ATTACH_ELASTIC, "525.25,1008.25,1525.25,2008.25"

--

FP

Software FX, Inc.

Link to post
Share on other sites

Actually your question is my question: how can I find out the size of the

annotation object in LOGICAL coordinate?

So I can use the LOGICAL coordinate for attach methond.

The information I have:

1. The pixel-based coordinate for the annotation object:

(Left=100, Top=200, Width=20, Height = 16)

The left-top corner is (100,200) and the right-bottom corner is (120,216)

in chart coordinates (pixel-based coordinates)

2. The LOGICAL coordinate for the left-corner of the annotation object:

(X1=525.25, Y1 = 1008.25)

The same data point has pixel-based coordinate(100,200) and LOGICAL

coordinate(525.25,1008.25).

Question:

For another data point which has pixel-based coordinates(120,216), what is

its LOGICAL coordinates?

Since I can only get the pixel-based size for the annotation object, like

Width and Height, it leads to my question in previous message:

how to convert the size information(or right-corner) from pixel-based

coordinates to LOGICAL coordinate?

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:llT742LNCHA.1280@webserver1.softwarefx.com...

> OK. You don't want to specify anything in pixels as you want the physical

> size and position of the object to be variable (you said you wanted the

> object to resize with the chart, right ?) so, don't use any of the

> pixel-based property, namely Top,Left,Width and Height, instead use the

> Attach method which receives LOGICAL coordinates.

>

> It is really up to you what coordinates to pass. If your DataPoint is at

> (525.25,1008.25) this is not enough info, you still need to tell me what

> size the balloon is going to have in Logical coordinates (so that it

resizes

> with the chart), so add that size to (525.25,1008.25) and that will be the

> second set of coordinates (Right,Bottom) of your annotation object. For

> example:

>

> obj.Attach ATTACH_ELASTIC, "525.25,1008.25,1525.25,2008.25"

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

To convert Physical to Logical coordinates you can use the PixelToValue

method to convert from physical to logical coordinates, this however works

with the CURRENT scale, this will change later as the chart is either

resized or re-scaled (new data range).

Note: PixelToValue will work only after the chart is already visible and has

a size.

If you still have questions about this please contact our support line.

--

FP

Software FX, Inc.

Link to post
Share on other sites

Thanks a lot.

I got the key point.

"SoftwareFX Support" <support@softwarefx.com> wrote in message

news:3uqa6fNNCHA.1984@webserver1.softwarefx.com...

> To convert Physical to Logical coordinates you can use the PixelToValue

> method to convert from physical to logical coordinates, this however works

> with the CURRENT scale, this will change later as the chart is either

> resized or re-scaled (new data range).

>

> Note: PixelToValue will work only after the chart is already visible and

has

> a size.

>

> If you still have questions about this please contact our support line.

>

> --

> FP

> Software FX, Inc.

>

>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...