Skip to content

Commit 5c6ef80

Browse files
committed
sankey: add modebar button to compare on hover
1 parent 3007ac2 commit 5c6ef80

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/components/modebar/manage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) {
8686
var hasTernary = fullLayout._has('ternary');
8787
var hasMapbox = fullLayout._has('mapbox');
8888
var hasPolar = fullLayout._has('polar');
89+
var hasSankey = fullLayout._has('sankey');
8990
var allAxesFixed = areAllAxesFixed(fullLayout);
9091

9192
var groups = [];
@@ -139,6 +140,9 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) {
139140
else if(hasPie) {
140141
hoverGroup = ['hoverClosestPie'];
141142
}
143+
else if(hasSankey) {
144+
hoverGroup = ['hoverClosestCartesian', 'hoverCompareCartesian'];
145+
}
142146
else { // hasPolar, hasTernary
143147
// always show at least one hover icon.
144148
hoverGroup = ['toggleHover'];

src/traces/sankey/plot.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ module.exports = function plot(gd, calcData) {
162162
// For each related links, create a hoverItem
163163
for(var i = 0; i < d.flow.links.length; i++) {
164164
var link = d.flow.links[i];
165+
if(gd._fullLayout.hovermode === 'closest' && d.link.pointNumber !== link.pointNumber) continue;
165166
link.fullData = link.trace;
166167
obj = d.link.trace.link;
167168
var hoverCenterX;

test/image/mocks/sankey_link_concentration.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"layout": {
7171
"title": "Sankey diagram with links colored based on their concentration within a flow",
7272
"width": 800,
73-
"height": 800
73+
"height": 800,
74+
"hovermode": "x"
7475
}
7576
}

0 commit comments

Comments
 (0)