-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Added click event on pie charts. #111
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,6 +373,12 @@ pie.plot = function(gd, cdpie) { | |
} | ||
} | ||
|
||
function handleClick (evt) { | ||
gd._hoverdata = pt; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an object. We could wrap it in an array so that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd vote for returning an array of length 1 for consistency, even though as you said there will always be only one pt in that array. cc @alexcjohnson thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes please, make it an array. For consistency with other types, as @etpinard says, but also with the converse operation for the same type - displaying hover data - which could still include multiple slices that you want to highlight. |
||
gd._hoverdata.trace = slices[0][0].__data__.trace; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the first slice in the array contains the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. My mistake. Try to grab a ref to the trace. |
||
Plotly.Fx.click(gd, { target: true }); | ||
} | ||
|
||
slicePath.enter().append('path') | ||
.classed('surface', true) | ||
.style({'pointer-events': 'all'}); | ||
|
@@ -381,7 +387,8 @@ pie.plot = function(gd, cdpie) { | |
|
||
sliceTop | ||
.on('mouseover', handleMouseOver) | ||
.on('mouseout', handleMouseOut); | ||
.on('mouseout', handleMouseOut) | ||
.on('click', handleClick); | ||
|
||
if(trace.pull) { | ||
var pull = +(Array.isArray(trace.pull) ? trace.pull[pt.i] : trace.pull) || 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdtusz could you elaborate on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event from
pie/index.js
does not have astopImmediatePropagation
method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great thanks.