onPlotAreaSwipe property

ChartPlotAreaSwipeCallback? onPlotAreaSwipe
final

Called while swiping on the plot area.

Whenever the swiping happens on the plot area (the series rendering area), onPlotAreaSwipe callback will be called. It provides options to get the direction of swiping.

If the chart is swiped from left to right direction, the direction is ChartSwipeDirection.start and if the swipe happens from right to left direction, the direction is ChartSwipeDirection.end.

Using this callback, the user able to achieve pagination functionality (on swiping over chart area, next set of data points can be loaded to the chart).

Also refer ChartSwipeDirection.

ChartSeriesController? seriesController;

Widget build(BuildContext context) {
   return Container(
       child: SfCartesianChart(
          onPlotAreaSwipe:
            (ChartSwipeDirection direction) =>
                performSwipe(direction),
          series: <CartesianSeries<SalesData, num>>[
               AreaSeries<SalesData, num>(
                   dataSource: chartData,
               ),
             ],
         )
    );
}
Widget performSwipe(ChartSwipeDirection direction) {
    if (direction == ChartSwipeDirection.end) {
        chartData.add(ChartSampleData(
            x: chartData[chartData.length - 1].x + 1,
            y: 10));
  seriesController.updateDataSource(addedDataIndex: chartData.length - 1);
    }
}

Implementation

final ChartPlotAreaSwipeCallback? onPlotAreaSwipe;