Having trouble getting help?
Contact Support
Contact Support
Transform axis value to pixel value and vice-versa
SfCartesianChart offers two utility methods to transform the pixel into a chart point and vice-versa.
-
ValueToPoint(ChartAxis axis,double value)
- Converts the data point value to the screen point. -
PointToValue(ChartAxis axis,double x, double y)
- Converts the screen point to the chart value.
if (chart is SfCartesianChart cartesianChart)
{
//Convert screen point to chart point.
var xValue = cartesianChart.PointToValue(cartesianChart.XAxes[0], pointX, pointY);
var yValue = cartesianChart.PointToValue(cartesianChart.YAxes[0], pointX, pointY);
//Convert chart point to screen point.
var xPoint = cartesianChart.ValueToPoint(cartesianChart.XAxes[0], xValue);
var yPoint = cartesianChart.ValueToPoint(cartesianChart.YAxes[0], yValue);
}