apexcharts / Blazor-ApexCharts

A blazor wrapper for ApexCharts.js
https://apexcharts.github.io/Blazor-ApexCharts
MIT License
803 stars 92 forks source link

[Bug] Donut/Pie Chart click event does not capture data in DataPoint, DataPointIndex, Series and SeriesIndex #442

Open aditya119 opened 6 months ago

aditya119 commented 6 months ago

Using OnClick property of ApexChart and using SelectedData<TItem> to fetch information. Information about the clicked section should be present. image

If this is not possible, is there a workaround on how to get what item in the donut chart was clicked?

joadan commented 6 months ago

Hi,

Please use the OnDataPointSelection event.

joadan commented 6 months ago

Example at: https://apexcharts.github.io/Blazor-ApexCharts/events/data-point-selection

aditya119 commented 5 months ago

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?

joadan commented 5 months ago

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?

aditya119 commented 5 months ago

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.

seanjbsol commented 4 months ago

I have an issue where OnDataPointSelection seems to only be called once

Vunlinur commented 4 months ago

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.