Hi, I’m trying to position vertical line annotations on a chart. I want to position them on a visible part of the chart, but I need to use the Absolute coordinate mode as I want the annotation to move with the data as the chart is panned or zoomed.
My question is then: how can I find the currently visible extents of the X axis? If the chart is zoomed or panned I need to know what the left and rightmost visible X-axis values are (independent of the data).
If you just wish to place an annotation on the chart at a relative coordinate (e.g. 20% along the visible XAxis), then please use AnnotationBase.CoordinateMode.
Gets or sets the AnnotationCoordinateMode to use when placing the annotation. E.g. the default of Absolute requires that X1,Y1 coordinates are data-values. The value of Relative requires that X1,Y1 are double values from 0.0 to 1.0
- Absolute, requires that coordinates X1,Y1,X2,Y2 are data-values
- Relative, requires that coordinates X1,Y1,X2,Y2 are double values between 0.0 and 1.0
- RelativeX, requires that coordinates X1,X2 are double values between 0.0 and 1.0, whereas Y1,Y2 are data-values
- RelativeY, requires that coordinates Y1,Y2 are double values between 0.0 and 1.0, whereas X1,X2 are data-values
For a detailed description of the Annotations API, please see our article Annotations are Easy!
Alternatively, you can access which parts of the data are visible via the AxisBase.VisibleRange property.
Also, please see the Axis.VisibleRangeChanged event which is fired whenever the range changes.
Please login first to submit.