pixelToPoint method

CartesianChartPoint pixelToPoint(
  1. Offset position
)

Converts logical pixel value to the data point value.

The pixelToPoint method takes logical pixel value as input and returns a chart data point.

Since this method is in the series controller, x and y-axis associated with this particular series will be considering for conversion value.

Widget build(BuildContext context) {
  ChartSeriesController? _chartSeriesController;
  return SfCartesianChart(
    series: <LineSeries<SalesData, num>>[
      LineSeries<SalesData, num>(
        onRendererCreated: (ChartSeriesController controller) {
          _chartSeriesController = controller;
        },
      ),
    ],
    onChartTouchInteractionUp: (ChartTouchInteractionArgs args) {
      final Offset value = Offset(args.position.dx, args.position.dy);
      final CartesianChartPoint<dynamic>? chartpoint = _chartSeriesController?.pixelToPoint(value);
      print('X point: ${chartpoint?.x}');
      print('Y point: ${chartpoint?.y}');
    },
  );
}

Implementation

CartesianChartPoint<dynamic> pixelToPoint(Offset position) {
  return calculatePixelToPoint(position, seriesRenderer);
}