@@ -12,6 +12,7 @@ var d3 = require('d3');
12
12
var render = require ( './render' ) ;
13
13
var Fx = require ( '../../components/fx' ) ;
14
14
var Color = require ( '../../components/color' ) ;
15
+ var Lib = require ( '../../lib' ) ;
15
16
16
17
function renderableValuePresent ( d ) { return d !== '' ; }
17
18
@@ -106,6 +107,13 @@ function linkNonHoveredStyle(d, sankey, visitNodes, sankeyLink) {
106
107
}
107
108
}
108
109
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
+
109
117
module . exports = function plot ( gd , calcData ) {
110
118
111
119
var fullLayout = gd . _fullLayout ;
@@ -125,7 +133,6 @@ module.exports = function plot(gd, calcData) {
125
133
126
134
var linkHoverFollow = function ( element , d ) {
127
135
var trace = gd . _fullData [ d . traceId ] ;
128
- var ptNumber = d . originalIndex ;
129
136
var boundingBox = element . getBoundingClientRect ( ) ;
130
137
var hoverCenterX = boundingBox . left + boundingBox . width / 2 ;
131
138
var hoverCenterY = boundingBox . top + boundingBox . height / 2 ;
@@ -139,11 +146,11 @@ module.exports = function plot(gd, calcData) {
139
146
[ 'Source:' , d . link . source . label ] . join ( ' ' ) ,
140
147
[ 'Target:' , d . link . target . label ] . join ( ' ' )
141
148
] . 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' ) ,
147
154
idealAlign : d3 . event . x < hoverCenterX ? 'right' : 'left'
148
155
} , {
149
156
container : fullLayout . _hoverlayer . node ( ) ,
@@ -177,7 +184,6 @@ module.exports = function plot(gd, calcData) {
177
184
178
185
var nodeHoverFollow = function ( element , d ) {
179
186
var trace = gd . _fullData [ d . traceId ] ;
180
- var ptNumber = d . originalIndex ;
181
187
var nodeRect = d3 . select ( element ) . select ( '.nodeRect' ) ;
182
188
var boundingBox = nodeRect . node ( ) . getBoundingClientRect ( ) ;
183
189
var hoverCenterX0 = boundingBox . left - 2 ;
@@ -194,11 +200,11 @@ module.exports = function plot(gd, calcData) {
194
200
[ 'Incoming flow count:' , d . node . targetLinks . length ] . join ( ' ' ) ,
195
201
[ 'Outgoing flow count:' , d . node . sourceLinks . length ] . join ( ' ' )
196
202
] . 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' ) ,
202
208
idealAlign : 'left'
203
209
} , {
204
210
container : fullLayout . _hoverlayer . node ( ) ,
0 commit comments