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
Drawing colorLines with annotations (or any type of label)?
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.
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |