Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ fx.click = function(gd,evt){
if(gd._hoverdata && evt && evt.target) {
gd.emit('plotly_click', {points: gd._hoverdata});
// why do we get a double event without this???
evt.stopImmediatePropagation();
if(evt.stopImmediatePropagation) evt.stopImmediatePropagation();
Copy link
Contributor

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?

Copy link
Contributor Author

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 a stopImmediatePropagation method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great thanks.

}
};

Expand Down
9 changes: 8 additions & 1 deletion src/traces/pie/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ pie.plot = function(gd, cdpie) {
}
}

function handleClick (evt) {
gd._hoverdata = pt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is pt a plain object or an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 points that is returned with the plotly_click event matches scatter events, but it doesn't make sense in the context - there will only be element ever passed - the slice that's clicked on.

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator

Choose a reason for hiding this comment

The 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 = cd.trace;
Plotly.Fx.click(gd, { target: true });
}

slicePath.enter().append('path')
.classed('surface', true)
.style({'pointer-events': 'all'});
Expand 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;
Expand Down