react-apexcharts
react-apexcharts copied to clipboard
toggleDataPointSelection does not seem to work
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:

Any help would be appreciated
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