pixelToPoint method

PointInfo 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.

late FunnelSeriesController seriesController;
SfFunnelChart(
   onChartTouchInteractionDown: (ChartTouchInteractionArgs args) {
    PointInfo<double> chartPoint =
      seriesController.pixelToPoint(args.position);
    Offset value = seriesController.pointToPixel(chartPoint);
  },
    series: FunnelSeries<ChartSampleData, String>(
        dataSource: funnelData,
        onRendererCreated:
          (FunnelSeriesController funnelSeriesController) {
          seriesController = FunnelSeriesController;
        }
    )
);

Implementation

PointInfo pixelToPoint(Offset position) {
  int pointIndex = -1;
  final List<ChartSegment> segments = seriesRenderer.segments;
  for (int i = 0; i < segments.length; i++) {
    final FunnelSegment<T, D> segment = segments[i] as FunnelSegment<T, D>;
    if (segment.contains(position)) {
      pointIndex = i;
    }
  }
  final dynamic x = seriesRenderer.xValues[pointIndex];
  final num y = seriesRenderer.yValues[pointIndex];
  return PointInfo(x, y);
}