@@ -153,6 +153,81 @@ exports.loneHover = function loneHover(hoverItem, opts) {
153
153
return hoverLabel . node ( ) ;
154
154
} ;
155
155
156
+ exports . multiHovers = function multiHovers ( hoverItems , opts ) {
157
+
158
+ if ( ! Array . isArray ( hoverItems ) ) {
159
+ hoverItems = [ hoverItems ] ;
160
+ }
161
+
162
+ var pointsData = hoverItems . map ( function ( hoverItem ) {
163
+ return {
164
+ color : hoverItem . color || Color . defaultLine ,
165
+ x0 : hoverItem . x0 || hoverItem . x || 0 ,
166
+ x1 : hoverItem . x1 || hoverItem . x || 0 ,
167
+ y0 : hoverItem . y0 || hoverItem . y || 0 ,
168
+ y1 : hoverItem . y1 || hoverItem . y || 0 ,
169
+ xLabel : hoverItem . xLabel ,
170
+ yLabel : hoverItem . yLabel ,
171
+ zLabel : hoverItem . zLabel ,
172
+ text : hoverItem . text ,
173
+ name : hoverItem . name ,
174
+ idealAlign : hoverItem . idealAlign ,
175
+
176
+ // optional extra bits of styling
177
+ borderColor : hoverItem . borderColor ,
178
+ fontFamily : hoverItem . fontFamily ,
179
+ fontSize : hoverItem . fontSize ,
180
+ fontColor : hoverItem . fontColor ,
181
+
182
+ // filler to make createHoverText happy
183
+ trace : {
184
+ index : 0 ,
185
+ hoverinfo : ''
186
+ } ,
187
+ xa : { _offset : 0 } ,
188
+ ya : { _offset : 0 } ,
189
+ index : 0
190
+ } ;
191
+ } ) ;
192
+
193
+
194
+ var container3 = d3 . select ( opts . container ) ,
195
+ outerContainer3 = opts . outerContainer ?
196
+ d3 . select ( opts . outerContainer ) : container3 ;
197
+
198
+ var fullOpts = {
199
+ hovermode : 'closest' ,
200
+ rotateLabels : false ,
201
+ bgColor : opts . bgColor || Color . background ,
202
+ container : container3 ,
203
+ outerContainer : outerContainer3
204
+ } ;
205
+
206
+ var hoverLabel = createHoverText ( pointsData , fullOpts , opts . gd ) ;
207
+
208
+ // Fix vertical overlap
209
+ var tooltipSpacing = 5 ;
210
+ var lastBottomY = 0 ;
211
+ hoverLabel
212
+ . sort ( function ( a , b ) { return a . y0 - b . y0 ; } )
213
+ . each ( function ( d ) {
214
+ var topY = d . y0 - d . by / 2 ;
215
+
216
+ if ( ( topY - tooltipSpacing ) < lastBottomY ) {
217
+ d . offset = ( lastBottomY - topY ) + tooltipSpacing ;
218
+ } else {
219
+ d . offset = 0 ;
220
+ }
221
+
222
+ lastBottomY = topY + d . by + d . offset ;
223
+ } ) ;
224
+
225
+
226
+ alignHoverText ( hoverLabel , fullOpts . rotateLabels ) ;
227
+
228
+ return hoverLabel . node ( ) ;
229
+ } ;
230
+
156
231
// The actual implementation is here:
157
232
function _hover ( gd , evt , subplot , noHoverEvent ) {
158
233
if ( ! subplot ) subplot = 'xy' ;
@@ -396,6 +471,10 @@ function _hover(gd, evt, subplot, noHoverEvent) {
396
471
if ( fullLayout [ subplotId ] ) {
397
472
pointData . subplot = fullLayout [ subplotId ] . _subplot ;
398
473
}
474
+ // add ref to splom scene
475
+ if ( fullLayout . _splomScenes && fullLayout . _splomScenes [ trace . uid ] ) {
476
+ pointData . scene = fullLayout . _splomScenes [ trace . uid ] ;
477
+ }
399
478
400
479
closedataPreviousLength = hoverData . length ;
401
480
0 commit comments