pixelToPoint method
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 PyramidSeriesController pyramidSeriesController;
SfPyramidChart(
onChartTouchInteractionDown: (ChartTouchInteractionArgs args) {
ChartPoint<double> chartPoint =
seriesController.pixelToPoint(args.position);
Offset value = seriesController.pointToPixel(chartPoint);
},
series: PyramidSeries<ChartSampleData, String>(
onRendererCreated: (PyramidSeriesController seriesController) {
pyramidSeriesController = seriesController;
}
),
);
Implementation
PointInfo pixelToPoint(Offset position) {
int pointIndex = -1;
final List<ChartSegment> segments = seriesRenderer.segments;
for (int i = 0; i < segments.length; i++) {
final PyramidSegment<T, D> segment = segments[i] as PyramidSegment<T, D>;
if (segment.contains(position)) {
pointIndex = i;
}
}
final dynamic x = seriesRenderer.xValues[pointIndex];
final num y = seriesRenderer.yValues[pointIndex];
return PointInfo(x, y);
}