Jump to content
Software FX Community

Annotations do not invert with XAxis


Recommended Posts

The default attachment for annotation objects created from the toolbar is to

the center. This means the center of the rectangle surrounding the object

will remain at the same logical position when the chart scales changes (e.g.

the chart is resized).

You can process the ObjectCreated event if you want to change this behavior,

for example attach BOTH ends of the arrow to logical positions.

I do not see any difference in behavior when using inverted axis.

--

FP

Software FX

Link to post
Share on other sites

It seems like the default attach mode for assymetrical object would be at

the ends and not in the center.

In any case, I am able to change to attach points in the ObjectCreate event.

When processing an arrow, how do I determine where the arrow starts and

where it ends? The dimensions I see are based on the object bounds - left,

top, height and width.

post-2106-13922379488057_thumb.png

Link to post
Share on other sites

Easy,

You can convert Pixel Coordinates to Axis Coordinates using the PixelToValue

method in the Axis object.

For example:

double dx1 = chart1.AxisX.PixelToValue(e.Object.Left);

double dy1 = chart1.AxisY.PixelToValue(e.Object.Top);

double dx2 = chart1.AxisX.PixelToValue(e.Object.Left+e.Object.Width);

double dy2 = chart1.AxisY.PixelToValue(e.Object.Top+e.Object.Height);

e.Object.Attach(dx1,dy1,dx2,dy2);

--

FP

Software FX

Link to post
Share on other sites

Yes, but the problem is trying to figure out which end of the line has the

arrowhead, ie. Top, Left, Width and Height give the bounds but not the start

and end points. When I use this method, the arrowhead always ends up to the

right no matter which way I drag on the canvas.

I ended up using the MouseDown and MouseUp events to capture the actual

start and end points:

double left = this.AxisX.PixelToValue(mouseDown.X);

double right = this.AxisX.PixelToValue(mouseUp.X);

double top = this.AxisY.PixelToValue(mouseDown.Y);

double bottom = this.AxisY.PixelToValue(mouseUp.Y);

e.Object.Attach(left,top,right,bottom);

It seems to me the information should be available from the object

properties.

Link to post
Share on other sites

Yes, but this does not necessarily preserve the direction of the arrow. It

always ends up going from left to right no matter how you drag the mouse.

Are the start and end points available from the object?

As a workaround, I used the mouse down and mouse up events to record the

start and end points.

Link to post
Share on other sites

The following code preserves the direction:

Rectangle r = e.Object.ObjectBounds;

double dx1 = chart1.AxisX.PixelToValue(r.Left);

double dy1 = chart1.AxisY.PixelToValue(r.Top);

double dx2 = chart1.AxisX.PixelToValue(r.Right);

double dy2 = chart1.AxisY.PixelToValue(r.Bottom);

e.Object.Attach(dx1,dy1,dx2,dy2);

--

FP

Software FX

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...