selectDataPoints method

void selectDataPoints(
  1. int pointIndex,
  2. [int seriesIndex = 0]

Selects or deselects the specified data point in the series.

The following are the arguments to be passed.

  • pointIndex - index of the data point that needs to be selected.
  • seriesIndex - index of the series in which the data point is selected.

Where the pointIndex is a required argument and seriesIndex is an optional argument. By default, 0 will be considered as the series index. Thus it will take effect on the first series if no value is specified.

For circular, pyramid and funnel charts, series index should always be 0, as it has only one series.

If the specified data point is already selected, it will be deselected, else it will be selected. Selection type and multi-selection functionality is also applicable for this, but it is based on the API values specified in ChartSelectionBehavior.

Note: Even though, the enable property in ChartSelectionBehavior is set to false, this method will work.

late SelectionBehavior selectionBehavior;

void initState() {
  selectionBehavior = SelectionBehavior(
    enable: true

Widget build(BuildContext context) {
  return Column(
    children: [
        onPressed: () {
          setState(() {
        child: Text('Select data points')
        series: <BarSeries<SalesData, num>>[
          BarSeries<SalesData, num>(
            selectionBehavior: selectionBehavior

void select() {


void selectDataPoints(int pointIndex, [int seriesIndex = 0]) {
  if (_selectionBehaviorRenderer != null) {
    final dynamic seriesRenderer = _selectionBehaviorRenderer!
        seriesRenderer is CartesianSeriesRenderer == false ||
                    SeriesHelper.getSeriesRendererDetails(seriesRenderer)) !=
        'Provided point index is not in the visible range. Provide point index which is in the visible range.');
    _selectionBehaviorRenderer = seriesRenderer is CartesianSeriesRenderer
        ? SeriesHelper.getSeriesRendererDetails(seriesRenderer)
        : _selectionBehaviorRenderer;
        ?.selectDataPoints(pointIndex, seriesIndex);