Skip to content

onClick event handler doesn't take into account a right-click for Pie Charts. #6633

New issue

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

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

Already on GitHub? # to your account

Open
dustinstender opened this issue Jun 8, 2023 · 3 comments
Labels
bug something broken P3 backlog

Comments

@dustinstender
Copy link

Reproduction of bug - https://codepen.io/dstender/pen/LYXEGYZ

Simple code example:

var myPlot = document.getElementById('myDiv'),
    data = [{
  values: [19, 26, 55],
  labels: ['Residential', 'Non-Residential', 'Utility'],
  type: 'pie'
}],
    layout = {hovermode:'closest',
              title:'Click on Points'
     };

Plotly.newPlot('myDiv', data, layout);

myPlot.on('plotly_click', function(){
    alert('You clicked this Plotly chart!');
});

I discovered this issue while using the react-plotly.js library. I wanted to handle the left and right clicking of a slice of a pie chart in the same manner. However, I noticed that the onClick event doesn't catch a right click. This is not the case for other charts (Line, Bar, etc...).

It seems to me that this is related to plotly.js rather than react-plotly.js but of course I could be wrong. If this is a legit bug are there any workarounds?

@dustinstender
Copy link
Author

dustinstender commented Jun 20, 2023

I looked a bit into the codebase and it seems to me that according to this test this behavior is intentional.

Is there a specific reason for this?

@alexcjohnson
Copy link
Collaborator

Thanks @dustinstender - the TODO in that test makes it look like we just never completed this behavior for pie charts, so we removed the broken behavior, but we would prefer the feature to be completed. @archmoj is that how you understand this too?

@dustinstender
Copy link
Author

Thanks for getting back @alexcjohnson. I noticed here that this does seem to be the case.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

3 participants