Drawing colorLines with annotations (or any type of label)?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
LibDundas
Newbie
Newbie
Posts: 55
Joined: Fri Mar 20, 2009 12:00 am

Drawing colorLines with annotations (or any type of label)?

Post by LibDundas » Thu Mar 26, 2009 9:38 pm

I use a colorLine to mark a point on the bottom axis. I need to add a label near the chart that corresponds to this colorLine. For this, I use an Annotation and set a custom position which I obtain using:

annotationSeg1.Left = Convert.ToInt16(tChart.Axes.Bottom.CalcPosValue(segTimeSum));


When the chart is zoomed, the colorLines move automatically (as they should). The problem is that the Annotations do not move.

To resolve this, I added code to the tChart_Zoomed() event which does the following:

Bitmap b = tChart.Bitmap; // force the chart to redraw so CalcPosValue will calc the proper value
annotationSeg1.Left = 3 + Convert.ToInt16(tChart.Axes.Bottom.CalcPosValue(segTimeSum));

This all works 'fine' (its a little bulky because I actually have to cycle through a foreach statement to update up to 16 annoatationSeg's).

Basically, I need to draw a vertical line on a graph to mark a position and I need to label this random line (within the graph right near the line) so the user knows what it is.

1. Is there a better way to draw a line (with a label) at a given x-axis coordinate?

2. If not, is there a way to snap an Annotation to a colorLine so they move together?

Thanks,
Kevin

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Mar 27, 2009 9:25 am

Hi Kevin,

I can think in two possibilities:

1. Use a dummy point series. You could add this series, hide series pointer, and show series marks. With this, you'll have marks where you wish that will zoom and scroll without your intervention.

2. Continue with annotations. Using annotations, I'm afraid that you'll need to recalculate their positions each time the chart is redrawn (zoom, scroll,...). Here I only can suggest you to use an array where you could store the relations between annotation tools indexes and color lines indexes. So then, you could recalculate all the positions in a "simple" foreach statement, similar as you probably are doing.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

LibDundas
Newbie
Newbie
Posts: 55
Joined: Fri Mar 20, 2009 12:00 am

Post by LibDundas » Fri Mar 27, 2009 2:45 pm

Thanks Yeray, your first suggestion sounds interesting. I will give that a go.

Post Reply