Transform axis value to pixel value and vice-versa
3 Sep 20201 minute to read
SfChart
offers two utility methods to transform the pixel to chart point and vice-versa.
-
ValueToPoint(ChartAxis axis, double value)
- Converts the data point value to screen point. -
PointToValue(ChartAxis axis, Point point)
- Converts the screen point to chart value.
double xValue = Chart.PointToValue(Chart.PrimaryAxis, screenPoint);
double yValue = Chart.PointToValue(Chart.SecondaryAxis, screenPoint);
double chartPointX = Chart.ValueToPoint(Chart.PrimaryAxis, xValue);
double chartPointY = Chart.ValueToPoint(Chart.SecondaryAxis, yValue);
Use the ValueToPoint
and PointToValue
methods, which are available in ChartAxis
, to convert the screen point within the rendered area of the series.
NOTE
You can convert the actual axis value to 0 to 1 coefficient using the
ValueToCoefficient(double value)
andCoefficientToValue(double value)
methods ofChartAxis
.