react-apexcharts icon indicating copy to clipboard operation
react-apexcharts copied to clipboard

toggleDataPointSelection does not seem to work

Open KristofVDB1 opened this issue 4 years ago • 1 comments

Hi

I've been trying for a while now to get the toggleDataPointSelection to work but it's not working for me.

I'm using "react-apexcharts": "^1.3.7" and "apexcharts": "^3.23.1",.

This is the code I'm currently using:

import Chart from 'react-apexcharts';
import ApexCharts from 'apexcharts';

    this.state = {
      options: {
        chart: {
          id: 'genderplot',
          events: {
            dataPointSelection: (event, context, config) => {
              this.updateFilters(event, context, config);
            },
          },
        },
        xaxis: {
          categories: ['male', 'female', 'other'],
        },
        plotOptions: {
          bar: {
            horizontal: true,
          },
        },
      },
      series: [{
        name: 'gender',
        data: [m, f, u],
      }],
    };

<Chart options={this.state.options} series={this.state.series} type="bar" />

ApexCharts.exec('genderplot', 'toggleDataPointSelection', {
        seriesIndex: 0,
        dataPointIndex: 1,
});

I've tried passing the two indexes in different manners but without any success. Other methods using exec have worked, so I don't think there will be an issue there.

The issue I'm getting in the console: image

Any help would be appreciated

KristofVDB1 avatar Jan 04 '21 17:01 KristofVDB1

It's working fine, you have to call it proper

const seriesIndex = 0;
const dataPointIndex = 0;
ApexCharts.exec('genderplot', 'toggleDataPointSelection', seriesIndex, dataPointIndex);

See ApexCharts docs

rpieciorak avatar Mar 29 '21 18:03 rpieciorak