10
10
'use strict' ;
11
11
12
12
var polybool = require ( 'polybooljs' ) ;
13
+
14
+ var Registry = require ( '../../registry' ) ;
15
+ var Color = require ( '../../components/color' ) ;
16
+ var Fx = require ( '../../components/fx' ) ;
17
+
13
18
var polygon = require ( '../../lib/polygon' ) ;
14
19
var throttle = require ( '../../lib/throttle' ) ;
15
- var color = require ( '../../components/color' ) ;
16
20
var makeEventData = require ( '../../components/fx/helpers' ) . makeEventData ;
17
- var Fx = require ( '../../components/fx' ) ;
21
+ var getFromId = require ( './axis_ids' ) . getFromId ;
22
+ var sortModules = require ( '../sort_modules' ) . sortModules ;
18
23
19
- var axes = require ( './axes' ) ;
20
24
var constants = require ( './constants' ) ;
25
+ var MINSELECT = constants . MINSELECT ;
21
26
22
27
var filteredPolygon = polygon . filter ;
23
28
var polygonTester = polygon . tester ;
24
29
var multipolygonTester = polygon . multitester ;
25
- var MINSELECT = constants . MINSELECT ;
26
30
27
31
function getAxId ( ax ) { return ax . _id ; }
28
32
@@ -89,8 +93,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
89
93
var corners = zoomLayer . append ( 'path' )
90
94
. attr ( 'class' , 'zoombox-corners' )
91
95
. style ( {
92
- fill : color . background ,
93
- stroke : color . defaultLine ,
96
+ fill : Color . background ,
97
+ stroke : Color . defaultLine ,
94
98
'stroke-width' : 1
95
99
} )
96
100
. attr ( 'transform' , 'translate(' + xs + ', ' + ys + ')' )
@@ -114,21 +118,19 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
114
118
trace . geo === dragOptions . subplot
115
119
) {
116
120
searchTraces . push ( {
117
- selectPoints : trace . _module . selectPoints ,
118
- style : trace . _module . style ,
121
+ _module : trace . _module ,
119
122
cd : cd ,
120
123
xaxis : dragOptions . xaxes [ 0 ] ,
121
124
yaxis : dragOptions . yaxes [ 0 ]
122
125
} ) ;
123
126
}
124
- } else if ( trace . type === 'splom' ) {
127
+ } else if (
128
+ trace . type === 'splom' &&
125
129
// FIXME: make sure we don't have more than single axis for splom
126
- if ( trace . xaxes . indexOf ( xAxisIds [ 0 ] ) === - 1 ) continue ;
127
- if ( trace . yaxes . indexOf ( yAxisIds [ 0 ] ) === - 1 ) continue ;
128
-
130
+ trace . _xaxes [ xAxisIds [ 0 ] ] && trace . _yaxes [ yAxisIds [ 0 ] ]
131
+ ) {
129
132
searchTraces . push ( {
130
- selectPoints : trace . _module . selectPoints ,
131
- style : trace . _module . style ,
133
+ _module : trace . _module ,
132
134
cd : cd ,
133
135
xaxis : dragOptions . xaxes [ 0 ] ,
134
136
yaxis : dragOptions . yaxes [ 0 ]
@@ -138,11 +140,10 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
138
140
if ( yAxisIds . indexOf ( trace . yaxis ) === - 1 ) continue ;
139
141
140
142
searchTraces . push ( {
141
- selectPoints : trace . _module . selectPoints ,
142
- style : trace . _module . style ,
143
+ _module : trace . _module ,
143
144
cd : cd ,
144
- xaxis : axes . getFromId ( gd , trace . xaxis ) ,
145
- yaxis : axes . getFromId ( gd , trace . yaxis )
145
+ xaxis : getFromId ( gd , trace . xaxis ) ,
146
+ yaxis : getFromId ( gd , trace . yaxis )
146
147
} ) ;
147
148
}
148
149
}
@@ -265,7 +266,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
265
266
for ( i = 0 ; i < searchTraces . length ; i ++ ) {
266
267
searchInfo = searchTraces [ i ] ;
267
268
268
- traceSelection = searchInfo . selectPoints ( searchInfo , testPoly ) ;
269
+ traceSelection = searchInfo . _module . selectPoints ( searchInfo , testPoly ) ;
269
270
traceSelections . push ( traceSelection ) ;
270
271
271
272
thisSelection = fillSelectionItem ( traceSelection , searchInfo ) ;
@@ -296,7 +297,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
296
297
outlines . remove ( ) ;
297
298
for ( i = 0 ; i < searchTraces . length ; i ++ ) {
298
299
searchInfo = searchTraces [ i ] ;
299
- searchInfo . selectPoints ( searchInfo , false ) ;
300
+ searchInfo . _module . selectPoints ( searchInfo , false ) ;
300
301
}
301
302
302
303
updateSelectedState ( gd , searchTraces ) ;
@@ -333,7 +334,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
333
334
} ;
334
335
335
336
function updateSelectedState ( gd , searchTraces , eventData ) {
336
- var i , searchInfo , trace ;
337
+ var i , j , searchInfo , trace ;
337
338
338
339
if ( eventData ) {
339
340
var pts = eventData . points || [ ] ;
@@ -365,6 +366,7 @@ function updateSelectedState(gd, searchTraces, eventData) {
365
366
delete trace . _input . selectedpoints ;
366
367
367
368
// delete scattergl selection
369
+ // TODO commenting out, doesn't do anything
368
370
if ( searchTraces [ i ] . cd [ 0 ] . t && searchTraces [ i ] . cd [ 0 ] . t . scene ) {
369
371
searchTraces [ i ] . cd [ 0 ] . t . scene . clearSelect ( ) ;
370
372
}
@@ -374,9 +376,40 @@ function updateSelectedState(gd, searchTraces, eventData) {
374
376
gd . _fullLayout . _zoomlayer . selectAll ( '.select-outline' ) . remove ( ) ;
375
377
}
376
378
379
+ var lookup = { } ;
380
+
377
381
for ( i = 0 ; i < searchTraces . length ; i ++ ) {
378
382
searchInfo = searchTraces [ i ] ;
379
- if ( searchInfo . style ) searchInfo . style ( gd , searchInfo . cd ) ;
383
+
384
+ var name = searchInfo . _module . name ;
385
+ if ( lookup [ name ] ) {
386
+ lookup [ name ] . push ( searchInfo ) ;
387
+ } else {
388
+ lookup [ name ] = [ searchInfo ] ;
389
+ }
390
+ }
391
+
392
+ var keys = Object . keys ( lookup ) . sort ( sortModules ) ;
393
+
394
+ for ( i = 0 ; i < keys . length ; i ++ ) {
395
+ var items = lookup [ keys [ i ] ] ;
396
+ var len = items . length ;
397
+ var item0 = items [ 0 ] ;
398
+ var trace0 = item0 . cd [ 0 ] . trace ;
399
+
400
+ if ( Registry . traceIs ( trace0 , 'regl' ) ) {
401
+ // plot regl traces per module
402
+ var cds = new Array ( len ) ;
403
+ for ( j = 0 ; j < len ; j ++ ) {
404
+ cds [ j ] = items [ j ] . cd ;
405
+ }
406
+ item0 . _module . style ( gd , cds ) ;
407
+ } else {
408
+ // plot svg trace per trace
409
+ for ( j = 0 ; j < len ; j ++ ) {
410
+ item0 . _module . style ( gd , items [ j ] . cd ) ;
411
+ }
412
+ }
380
413
}
381
414
}
382
415
0 commit comments