This method allows you to select/deselect a data-point of a particular series.
Parameters
Name | Type | Default | Description |
---|
seriesIndex | Number | undefined | Index of the series array. If you are rendering a pie/donut/radialBar chart, this acts as dataPointIndex and is the only thing you have to provide as pie/donut/radialBar don’t support multi-series chart. |
dataPointIndex | Number | undefined | Index of the data-point in the series selected in previous argument. Not required in pie/donut/radialBar |
Returns
The DOM element which is toggled is returned. If not found, returns null
Example
var chart = new ApexCharts(el, {
chart: {
type: 'bar'
},
series: [{
data: [32, 44, 65, 12, 63]
}, {
data: [42, 12, 43, 53, 44]
}]
});
chart.toggleDataPointSelection(1, 3);
// This will toggle the 4th element of the 2nd series i.e. 53 and highlight the DOM element with a different shade.
Q: How do you know which data points are already selected?
A: You can use chart.w.globals.selectedDataPoints
array which contains necessary information. In the example above, chart.w.globals.selectedDataPoints
will contain [undefined, [3]]
.
This also trigger the chart.dataPointSelection event