Page 1 of 1

Annotation tool which follows a curve when scrolled/zoomed

Posted: Tue Feb 15, 2005 11:05 am
by 9524648
Hi !
I would like to know how I could do to draw a text on a curve and to refresh the position of this text when the graph is zoomed or scrolled in order this text to stay a the same X and Y (not in pixels but in axis units) position.
These X and Y co-ordinates are not necessary the coordinates of a point in the series the chart displays.
Exemple : I would like to place the upper left corner of the text box at the pixel of my curve which has the (3.578; 4.587) coordinates in the current graph, relatively to its current axes. If the graph is scrolled, the text must stay at the (3.578; 4.587) coordinates and stack the curve. The pixel corresponding coordinates must be recalculated but how ?
[img]file://c:\chart.jpg[/img]<- Hey how could I send you an image to show you what I want to do ?
Thanks for your reply

Posted: Tue Feb 15, 2005 11:33 am
by narcis
Hi tdm,

Please post the image at the steema.public.attachments newsgroup available at news://www.steema.net.

Thanks in advance.

Posted: Tue Feb 15, 2005 1:15 pm
by 9524648
Explanations and pictures have been posted in the steema.public.attachements newsgroup.
Could you have a watch to them ?
Thanks a lot.

Posted: Wed Feb 16, 2005 1:20 pm
by 9524648
Hey !
what's the matter ?
Does nobody knows how to solve my problem ?
Please have a look to the newsgroups (steema.public.attachments). The topic is Annotation Tool which follows a curve when scrolled/zoomed. There are 3 pictures which show what I want to do.
Thanks fo your help.

Posted: Wed Feb 16, 2005 2:57 pm
by narcis
Hi tdm,

Please find attached an example project at the newsgroups.

The Annotation Tool position is computed in the OnBeforeDrawAxes event using:

Code: Select all

Private Sub TChart1_OnBeforeDrawAxes()
With TChart1.Tools.Items(0).asAnnotation.Shape
    .CustomPosition = True
    .Top = TChart1.Series(0).CalcYPos(2)
    .Left = TChart1.Series(0).CalcXPos(2)
  End With
End Sub

Posted: Wed Feb 16, 2005 4:31 pm
by 9524648
Thanks a lot !
I will studdy it immediately and I'll give you a feedback as soon as I can.

Posted: Wed Feb 16, 2005 4:54 pm
by 9524648
This program draws the annotation with its upper left corner on the 2nd point of the serie isn't it ?
What if I want to put the upper left corner on a pixel of a segment which joins 2 successive points of the serie (middle of segment for exemple) ?

Posted: Thu Feb 17, 2005 9:29 am
by narcis
Hi tdm,
This program draws the annotation with its upper left corner on the 2nd point of the serie isn't it ?
Yes, that's it.
What if I want to put the upper left corner on a pixel of a segment
which joins 2 successive points of the serie (middle of segment for exemple) ?
You can do something like:

Code: Select all

Private Sub TChart1_OnBeforeDrawAxes()
With TChart1.Tools.Items(0).asAnnotation.Shape
    .CustomPosition = True
    .Top = (TChart1.Series(0).CalcYPos(2) + TChart1.Series(0).CalcYPos(3)) / 2
    .Left = (TChart1.Series(0).CalcXPos(2) + TChart1.Series(0).CalcXPos(3)) / 2
  End With
End Sub

Posted: Thu Feb 17, 2005 9:34 am
by 9524648
Yeah it's an idea.
I will take the X and Y of the two points which give the segment bounds, and compute the line equation to find the position of the annotation tool coordinates.
Thanks a lot for your help !