apexcharts.js icon indicating copy to clipboard operation
apexcharts.js copied to clipboard

Click events doesn't generate dataPointIndex and seriesIndex for Pie Charts

Open PrzemyslawKlys opened this issue 4 years ago • 11 comments

Bug report

Codepen

https://codepen.io/MadBoyEvo/pen/ExNbVeo

Explanation

  • What is the behavior you expect?

Both dataPointSelection and click event should return dataPointindex or/and series for all types of events correctly.

  • What is happening instead?

Following code behaves differently for different charts. For Pie charts only dataPointSelection provides dataPointIndex, but click event always return -1, -1. Click event for bar chart works correctly so I'm assuming this is a bug, not a feature. Maybe other chart types have the same issue.

events: {
    dataPointSelection: function (event, chartContext, config) {
        console.log(config.dataPointIndex + " " + config.seriesIndex);
    },
    click: function (event, chartContext, config) {
        console.log(config.dataPointIndex + " " + config.seriesIndex);
    }
}
  • What error message are you getting?

No error message.

PrzemyslawKlys avatar Feb 23 '21 08:02 PrzemyslawKlys

This issue is also preventing me from detecting double-click events on a pie chart, since I apparently can't access the data point index that was clicked.

karagog avatar May 10 '21 19:05 karagog

Yeah this is a bug. I think you can get around this by using event.target.parentElement.getAttribute("data:realIndex")

i.e

 chart: {
      type: 'pie',
      events: {
        click: function(event, chartContext, config) {
            console.log(event.target.parentElement.getAttribute("data:realIndex"))
        }
      }
    },

gbenga504 avatar Aug 24 '21 07:08 gbenga504

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Oct 23 '21 14:10 github-actions[bot]

Please fix, not close.

PrzemyslawKlys avatar Oct 24 '21 13:10 PrzemyslawKlys

Please fix, not close2

PingoLee avatar Oct 24 '21 20:10 PingoLee

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 24 '21 14:12 github-actions[bot]

Please fix not close.

PrzemyslawKlys avatar Dec 24 '21 14:12 PrzemyslawKlys

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Feb 24 '22 14:02 github-actions[bot]

Not stale.

PrzemyslawKlys avatar Feb 24 '22 14:02 PrzemyslawKlys

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 26 '22 14:04 github-actions[bot]

any idea? I'm getting config.dataPointIndex as -1 while hovering over a line graph

ayudh37 avatar Jul 06 '22 09:07 ayudh37

I have the same issue but I will use the trick with event.target.parentElement.getAttribute("data:realIndex")

bn3t avatar Jul 06 '23 14:07 bn3t