Open aditya119 opened 6 months ago
Hi,
Please use the OnDataPointSelection event.
Thanks @joadan . I am able to access the data point information using this event.
Now, the issue is that this same event is fired when clicking on relevant datapoint on chart and on the legend.
It is also not possible to identify if the event was fired by datapoint or legend by looking at the SelectedData<TItem>
object.
What I expected to achieve was providing drilldown functionality on chart click and out of the box chart filtering capability (click on legend and the relevant data gets highlighted on pie/donut and gets hidden when clicked on bar/line) on legend click. I have been doing that using ChartJS but unable to figure out how to achieve using ApexCharts.
Is it possible to develop such functionality or would it be an enhancement to the ApexCharts library?
Hi,
I'm sorry but I have a problem understanding what you are trying to achieve. In general I would recommend using the dedicated events OnDataPointSelection for the datapoint and the OnLegendClicked for the legend.
Will that work for you?
What I meant was that for a donut chart, both clicking on a section and clicking on a legend fire the OnDataPointSelection event. I was thinking that clicking on legend would just bring the relevant section in focus (which is the default behaviour without adding any events) and clicking on a section in the chart would fire the OnDataPointSelection.
But seems like OnDataPointSelection is fired for both these actions.
I have an issue where OnDataPointSelection seems to only be called once
I also experience the issue where OnDataPointSelection is fired both when clicking on the chart section and the legend. In my case it applies for both Pie and Donut charts.
Furthermore, when clicking on the legend, only the first element triggers the OnLegendClicked event. Any subsequent elements only call OnDataPointSelection, so it is impossible to discern whether the user clicked on the legend or the pie, even with more hacky approach like comparing whether OnLegendClicked has been triggered at all.
Using
OnClick
property ofApexChart
and usingSelectedData<TItem>
to fetch information. Information about the clicked section should be present.If this is not possible, is there a workaround on how to get what item in the donut chart was clicked?