Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cfe304d

Browse files
committedDec 14, 2015
Added click event on pie charts.
1 parent d06de72 commit cfe304d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎src/plots/cartesian/graph_interact.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ fx.click = function(gd,evt){
12761276
if(gd._hoverdata && evt && evt.target) {
12771277
gd.emit('plotly_click', {points: gd._hoverdata});
12781278
// why do we get a double event without this???
1279-
evt.stopImmediatePropagation();
1279+
if(evt.stopImmediatePropagation) evt.stopImmediatePropagation();
12801280
}
12811281
};
12821282

‎src/traces/pie/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ pie.plot = function(gd, cdpie) {
373373
}
374374
}
375375

376+
function handleClick (evt) {
377+
gd._hoverdata = pt;
378+
gd._hoverdata.trace = slices[0][0].__data__.trace;
379+
Plotly.Fx.click(gd, { target: true });
380+
}
381+
376382
slicePath.enter().append('path')
377383
.classed('surface', true)
378384
.style({'pointer-events': 'all'});
@@ -381,7 +387,8 @@ pie.plot = function(gd, cdpie) {
381387

382388
sliceTop
383389
.on('mouseover', handleMouseOver)
384-
.on('mouseout', handleMouseOut);
390+
.on('mouseout', handleMouseOut)
391+
.on('click', handleClick);
385392

386393
if(trace.pull) {
387394
var pull = +(Array.isArray(trace.pull) ? trace.pull[pt.i] : trace.pull) || 0;

0 commit comments

Comments
 (0)
Please sign in to comment.