Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cfe304d

Browse filesBrowse files
committed
Added click event on pie charts.
1 parent d06de72 commit cfe304d
Copy full SHA for cfe304d

File tree

Expand file treeCollapse file tree

2 files changed

+9
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-2
lines changed

‎src/plots/cartesian/graph_interact.js

Copy file name to clipboardExpand all lines: src/plots/cartesian/graph_interact.js
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/traces/pie/index.js
+8-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.