Skip to content

Commit e50886c

Browse files
committed
fixup: don't support array value in sankey hoverlabel settings
- see 4d3ce92#r115788926 for rationale
1 parent 4d3ce92 commit e50886c

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/traces/sankey/plot.js

+18-12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var d3 = require('d3');
1212
var render = require('./render');
1313
var Fx = require('../../components/fx');
1414
var Color = require('../../components/color');
15+
var Lib = require('../../lib');
1516

1617
function renderableValuePresent(d) {return d !== '';}
1718

@@ -106,6 +107,13 @@ function linkNonHoveredStyle(d, sankey, visitNodes, sankeyLink) {
106107
}
107108
}
108109

110+
// does not support array values for now
111+
function castHoverOption(trace, attr) {
112+
var labelOpts = trace.hoverlabel || {};
113+
var val = Lib.nestedProperty(labelOpts, attr).get();
114+
return Array.isArray(val) ? false : val;
115+
}
116+
109117
module.exports = function plot(gd, calcData) {
110118

111119
var fullLayout = gd._fullLayout;
@@ -125,7 +133,6 @@ module.exports = function plot(gd, calcData) {
125133

126134
var linkHoverFollow = function(element, d) {
127135
var trace = gd._fullData[d.traceId];
128-
var ptNumber = d.originalIndex;
129136
var boundingBox = element.getBoundingClientRect();
130137
var hoverCenterX = boundingBox.left + boundingBox.width / 2;
131138
var hoverCenterY = boundingBox.top + boundingBox.height / 2;
@@ -139,11 +146,11 @@ module.exports = function plot(gd, calcData) {
139146
['Source:', d.link.source.label].join(' '),
140147
['Target:', d.link.target.label].join(' ')
141148
].filter(renderableValuePresent).join('<br>'),
142-
color: Fx.castHoverOption(trace, ptNumber, 'bgcolor') || Color.addOpacity(d.tinyColorHue, 1),
143-
borderColor: Fx.castHoverOption(trace, ptNumber, 'bordercolor'),
144-
fontFamily: Fx.castHoverOption(trace, ptNumber, 'font.family'),
145-
fontSize: Fx.castHoverOption(trace, ptNumber, 'font.size'),
146-
fontColor: Fx.castHoverOption(trace, ptNumber, 'font.color'),
149+
color: castHoverOption(trace, 'bgcolor') || Color.addOpacity(d.tinyColorHue, 1),
150+
borderColor: castHoverOption(trace, 'bordercolor'),
151+
fontFamily: castHoverOption(trace, 'font.family'),
152+
fontSize: castHoverOption(trace, 'font.size'),
153+
fontColor: castHoverOption(trace, 'font.color'),
147154
idealAlign: d3.event.x < hoverCenterX ? 'right' : 'left'
148155
}, {
149156
container: fullLayout._hoverlayer.node(),
@@ -177,7 +184,6 @@ module.exports = function plot(gd, calcData) {
177184

178185
var nodeHoverFollow = function(element, d) {
179186
var trace = gd._fullData[d.traceId];
180-
var ptNumber = d.originalIndex;
181187
var nodeRect = d3.select(element).select('.nodeRect');
182188
var boundingBox = nodeRect.node().getBoundingClientRect();
183189
var hoverCenterX0 = boundingBox.left - 2;
@@ -194,11 +200,11 @@ module.exports = function plot(gd, calcData) {
194200
['Incoming flow count:', d.node.targetLinks.length].join(' '),
195201
['Outgoing flow count:', d.node.sourceLinks.length].join(' ')
196202
].filter(renderableValuePresent).join('<br>'),
197-
color: Fx.castHoverOption(trace, ptNumber, 'bgcolor') || d.tinyColorHue,
198-
borderColor: Fx.castHoverOption(trace, ptNumber, 'bordercolor'),
199-
fontFamily: Fx.castHoverOption(trace, ptNumber, 'font.family'),
200-
fontSize: Fx.castHoverOption(trace, ptNumber, 'font.size'),
201-
fontColor: Fx.castHoverOption(trace, ptNumber, 'font.color'),
203+
color: castHoverOption(trace, 'bgcolor') || d.tinyColorHue,
204+
borderColor: castHoverOption(trace, 'bordercolor'),
205+
fontFamily: castHoverOption(trace, 'font.family'),
206+
fontSize: castHoverOption(trace, 'font.size'),
207+
fontColor: castHoverOption(trace, 'font.color'),
202208
idealAlign: 'left'
203209
}, {
204210
container: fullLayout._hoverlayer.node(),

0 commit comments

Comments
 (0)