@@ -25,8 +25,9 @@ function getAxId(ax) { return ax._id; }
25
25
module . exports = function prepSelect ( e , startX , startY , dragOptions , mode ) {
26
26
var zoomLayer = dragOptions . gd . _fullLayout . _zoomlayer ,
27
27
dragBBox = dragOptions . element . getBoundingClientRect ( ) ,
28
- xs = dragOptions . plotinfo . xaxis . _offset ,
29
- ys = dragOptions . plotinfo . yaxis . _offset ,
28
+ plotinfo = dragOptions . plotinfo ,
29
+ xs = plotinfo . xaxis . _offset ,
30
+ ys = plotinfo . yaxis . _offset ,
30
31
x0 = startX - dragBBox . left ,
31
32
y0 = startY - dragBBox . top ,
32
33
x1 = x0 ,
@@ -71,6 +72,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
71
72
searchInfo ,
72
73
selection = [ ] ,
73
74
eventData ;
75
+
74
76
for ( i = 0 ; i < gd . calcdata . length ; i ++ ) {
75
77
cd = gd . calcdata [ i ] ;
76
78
trace = cd [ 0 ] . trace ;
@@ -106,9 +108,41 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
106
108
107
109
function ascending ( a , b ) { return a - b ; }
108
110
111
+ // allow subplots to override fillRangeItems routine
112
+ var fillRangeItems ;
113
+
114
+ if ( plotinfo . fillRangeItems ) {
115
+ fillRangeItems = plotinfo . fillRangeItems ;
116
+ } else {
117
+ if ( mode === 'select' ) {
118
+ fillRangeItems = function ( eventData , poly ) {
119
+ var ranges = eventData . range = { } ;
120
+
121
+ for ( i = 0 ; i < allAxes . length ; i ++ ) {
122
+ var ax = allAxes [ i ] ;
123
+ var axLetter = ax . _id . charAt ( 0 ) ;
124
+
125
+ ranges [ ax . _id ] = [
126
+ ax . p2d ( poly [ axLetter + 'min' ] ) ,
127
+ ax . p2d ( poly [ axLetter + 'max' ] )
128
+ ] . sort ( ascending ) ;
129
+ }
130
+ } ;
131
+ } else {
132
+ fillRangeItems = function ( eventData , poly , pts ) {
133
+ var dataPts = eventData . lassoPoints = { } ;
134
+
135
+ for ( i = 0 ; i < allAxes . length ; i ++ ) {
136
+ var ax = allAxes [ i ] ;
137
+ dataPts [ ax . _id ] = pts . filtered . map ( axValue ( ax ) ) ;
138
+ }
139
+ } ;
140
+ }
141
+ }
142
+
109
143
dragOptions . moveFn = function ( dx0 , dy0 ) {
110
- var poly ,
111
- ax ;
144
+ var poly ;
145
+
112
146
x1 = Math . max ( 0 , Math . min ( pw , dx0 + x0 ) ) ;
113
147
y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ;
114
148
@@ -158,27 +192,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
158
192
}
159
193
160
194
eventData = { points : selection } ;
161
-
162
- if ( mode === 'select' ) {
163
- var ranges = eventData . range = { } ,
164
- axLetter ;
165
-
166
- for ( i = 0 ; i < allAxes . length ; i ++ ) {
167
- ax = allAxes [ i ] ;
168
- axLetter = ax . _id . charAt ( 0 ) ;
169
- ranges [ ax . _id ] = [
170
- ax . p2d ( poly [ axLetter + 'min' ] ) ,
171
- ax . p2d ( poly [ axLetter + 'max' ] ) ] . sort ( ascending ) ;
172
- }
173
- }
174
- else {
175
- var dataPts = eventData . lassoPoints = { } ;
176
-
177
- for ( i = 0 ; i < allAxes . length ; i ++ ) {
178
- ax = allAxes [ i ] ;
179
- dataPts [ ax . _id ] = pts . filtered . map ( axValue ( ax ) ) ;
180
- }
181
- }
195
+ fillRangeItems ( eventData , poly , pts ) ;
182
196
dragOptions . gd . emit ( 'plotly_selecting' , eventData ) ;
183
197
} ;
184
198
0 commit comments