Conversion API
The Conversion API of the Chart, allows the conversion of a position on the screen (for example the position of the mouse) to chart coordinates data.
Convert Point to Data
To convert pixel cooridantes (like mouse position) to axis data coordinates, use the ConvertPointToData
method of the chart.
Tuple<object, object> data = this.chart.ConvertPointToData(new Point(100, 100));
ConvertPointToData
has another overload that allows you provide also the axes where the coordinates are searched.
Tuple<object, object> data = this.chart.ConvertPointToData(new Point(100, 100), horizontalAxis, verticalAxis);
Tuple<object, object>
object returned from the method contains two values - one for the horizontal and one for the vertical axis.
Convert Data to Point
To convert axis data coordinates to pixel cooridantes (like mouse position), use the ConvertDataToPoint
method of the chart.
Point point = this.chart.ConvertDataToPoint(new Tuple<object, object>(xValue, yValue));
ConvertDataToPoint
has another overload that allows you provide also the axes where the point is searched.
Point point = this.chart.ConvertDataToPoint(new Tuple<object, object>(xValue, yValue), horizontalAxis, verticalAxis);