@@ -156,42 +156,49 @@ module.exports = function plot(gd, calcData) {
156
156
if ( gd . _fullLayout . hovermode === false ) return ;
157
157
var obj = d . link . trace . link ;
158
158
if ( obj . hoverinfo === 'none' || obj . hoverinfo === 'skip' ) return ;
159
- var rootBBox = gd . _fullLayout . _paperdiv . node ( ) . getBoundingClientRect ( ) ;
160
- var hoverCenterX ;
161
- var hoverCenterY ;
162
- if ( d . link . circular ) {
163
- hoverCenterX = ( d . link . circularPathData . leftInnerExtent + d . link . circularPathData . rightInnerExtent ) / 2 + d . parent . translateX ;
164
- hoverCenterY = d . link . circularPathData . verticalFullExtent + d . parent . translateY ;
165
- } else {
166
- var boundingBox = element . getBoundingClientRect ( ) ;
167
- hoverCenterX = boundingBox . left + boundingBox . width / 2 - rootBBox . left ;
168
- hoverCenterY = boundingBox . top + boundingBox . height / 2 - rootBBox . top ;
169
- }
170
159
171
- var hovertemplateLabels = { valueLabel : d3 . format ( d . valueFormat ) ( d . link . value ) + d . valueSuffix } ;
172
- d . link . fullData = d . link . trace ;
160
+ var hoverItems = [ ] ;
161
+
162
+ // For each related links, create a hoverItem
163
+ for ( var i = 0 ; i < d . flow . links . length ; i ++ ) {
164
+ var link = d . flow . links [ i ] ;
165
+ obj = link ;
166
+ var hoverCenterX ;
167
+ var hoverCenterY ;
168
+ if ( link . circular ) {
169
+ hoverCenterX = ( link . circularPathData . leftInnerExtent + link . circularPathData . rightInnerExtent ) / 2 + d . parent . translateX ;
170
+ hoverCenterY = link . circularPathData . verticalFullExtent + d . parent . translateY ;
171
+ } else {
172
+ hoverCenterX = ( link . source . x1 + link . target . x0 ) / 2 + d . parent . translateX ;
173
+ hoverCenterY = ( link . y0 + link . y1 ) / 2 + d . parent . translateY ;
174
+ }
173
175
174
- var tooltip = Fx . loneHover ( {
175
- x : hoverCenterX ,
176
- y : hoverCenterY ,
177
- name : hovertemplateLabels . valueLabel ,
178
- text : [
179
- d . link . label || '' ,
180
- sourceLabel + d . link . source . label ,
181
- targetLabel + d . link . target . label ,
182
- d . link . concentrationscale ? concentrationLabel + d3 . format ( '%0.2f' ) ( d . link . flow . labelConcentration ) : ''
183
- ] . filter ( renderableValuePresent ) . join ( '<br>' ) ,
184
- color : castHoverOption ( obj , 'bgcolor' ) || Color . addOpacity ( d . tinyColorHue , 1 ) ,
185
- borderColor : castHoverOption ( obj , 'bordercolor' ) ,
186
- fontFamily : castHoverOption ( obj , 'font.family' ) ,
187
- fontSize : castHoverOption ( obj , 'font.size' ) ,
188
- fontColor : castHoverOption ( obj , 'font.color' ) ,
189
- idealAlign : d3 . event . x < hoverCenterX ? 'right' : 'left' ,
176
+ var hovertemplateLabels = { valueLabel : d3 . format ( d . valueFormat ) ( link . value ) + d . valueSuffix } ;
177
+
178
+ hoverItems . push ( {
179
+ x : hoverCenterX ,
180
+ y : hoverCenterY ,
181
+ name : hovertemplateLabels . valueLabel ,
182
+ text : [
183
+ link . label || '' ,
184
+ sourceLabel + link . source . label ,
185
+ targetLabel + link . target . label ,
186
+ link . concentrationscale ? concentrationLabel + d3 . format ( '%0.2f' ) ( link . flow . labelConcentration ) : ''
187
+ ] . filter ( renderableValuePresent ) . join ( '<br>' ) ,
188
+ color : castHoverOption ( obj , 'bgcolor' ) || Color . addOpacity ( link . color , 1 ) ,
189
+ borderColor : castHoverOption ( obj , 'bordercolor' ) ,
190
+ fontFamily : castHoverOption ( obj , 'font.family' ) ,
191
+ fontSize : castHoverOption ( obj , 'font.size' ) ,
192
+ fontColor : castHoverOption ( obj , 'font.color' ) ,
193
+ idealAlign : d3 . event . x < hoverCenterX ? 'right' : 'left' ,
194
+
195
+ hovertemplate : obj . hovertemplate ,
196
+ hovertemplateLabels : hovertemplateLabels ,
197
+ eventData : [ link ]
198
+ } ) ;
199
+ }
190
200
191
- hovertemplate : obj . hovertemplate ,
192
- hovertemplateLabels : hovertemplateLabels ,
193
- eventData : [ d . link ]
194
- } , {
201
+ var tooltip = Fx . multiHovers ( hoverItems , {
195
202
container : fullLayout . _hoverlayer . node ( ) ,
196
203
outerContainer : fullLayout . _paper . node ( ) ,
197
204
gd : gd
0 commit comments