Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Labels
bug Something isn't working

Comments

@PrzemyslawKlys
Copy link

PrzemyslawKlys commented Feb 23, 2021

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.

@karagog
Copy link

karagog commented May 10, 2021

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.

@gbenga504
Copy link

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"))
        }
      }
    },

@github-actions
Copy link

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.

@PrzemyslawKlys
Copy link
Author

Please fix, not close.

@PingoLee
Copy link

Please fix, not close2

@github-actions
Copy link

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.

@PrzemyslawKlys
Copy link
Author

Please fix not close.

@github-actions
Copy link

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.

@PrzemyslawKlys
Copy link
Author

Not stale.

@github-actions
Copy link

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.

@junedchhipa junedchhipa added bug Something isn't working and removed no-issue-activity labels Apr 26, 2022
@ayudh37
Copy link

ayudh37 commented Jul 6, 2022

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

@bn3t
Copy link

bn3t commented Jul 6, 2023

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

@KentuckyMC
Copy link

Same issue here, we will use the same 'solution' as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment