Skip to content

Commit 7a7a68f

Browse files
committed
Merge pull request #111 from plotly/pie-click
Added click event on pie charts.
2 parents 7992cb9 + 0800e15 commit 7a7a68f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/plots/cartesian/graph_interact.js

+1-1
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

+8-1
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 = cd.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)