@@ -32,7 +32,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
32
32
pw = dragOptions . xaxes [ 0 ] . _length ,
33
33
ph = dragOptions . yaxes [ 0 ] . _length ,
34
34
xAxisIds = dragOptions . xaxes . map ( getAxId ) ,
35
- yAxisIds = dragOptions . yaxes . map ( getAxId ) ;
35
+ yAxisIds = dragOptions . yaxes . map ( getAxId ) ,
36
+ allAxes = dragOptions . xaxes . concat ( dragOptions . yaxes ) ;
36
37
37
38
if ( mode === 'lasso' ) {
38
39
var pts = filteredPolygon ( [ [ x0 , y0 ] ] , constants . BENDPX ) ;
@@ -80,8 +81,14 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
80
81
} ) ;
81
82
}
82
83
84
+ function axValue ( ax ) {
85
+ var index = ( ax . _id . charAt ( 0 ) === 'y' ) ? 1 : 0 ;
86
+ return function ( v ) { return ax . p2d ( v [ index ] ) ; } ;
87
+ }
88
+
83
89
dragOptions . moveFn = function ( dx0 , dy0 ) {
84
- var poly ;
90
+ var poly ,
91
+ ax ;
85
92
x1 = Math . max ( 0 , Math . min ( pw , dx0 + x0 ) ) ;
86
93
y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ;
87
94
@@ -129,6 +136,27 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
129
136
}
130
137
131
138
eventData = { points : selection } ;
139
+
140
+ if ( mode === 'select' ) {
141
+ var ranges = eventData . range = { } ,
142
+ axLetter ;
143
+
144
+ for ( i = 0 ; i < allAxes . length ; i ++ ) {
145
+ ax = allAxes [ i ] ;
146
+ axLetter = ax . _id . charAt ( 0 ) ;
147
+ ranges [ ax . _id ] = [
148
+ ax . p2d ( poly [ axLetter + 'min' ] ) ,
149
+ ax . p2d ( poly [ axLetter + 'max' ] ) ] . sort ( ) ;
150
+ }
151
+ }
152
+ else {
153
+ var dataPts = eventData . lassoPoints = { } ;
154
+
155
+ for ( i = 0 ; i < allAxes . length ; i ++ ) {
156
+ ax = allAxes [ i ] ;
157
+ dataPts [ ax . _id ] = pts . filtered . map ( axValue ( ax ) ) ;
158
+ }
159
+ }
132
160
dragOptions . gd . emit ( 'plotly_selecting' , eventData ) ;
133
161
} ;
134
162
0 commit comments