@@ -32,7 +32,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
3232 pw = dragOptions . xaxes [ 0 ] . _length ,
3333 ph = dragOptions . yaxes [ 0 ] . _length ,
3434 xAxisIds = dragOptions . xaxes . map ( getAxId ) ,
35- yAxisIds = dragOptions . yaxes . map ( getAxId ) ;
35+ yAxisIds = dragOptions . yaxes . map ( getAxId ) ,
36+ allAxes = dragOptions . xaxes . concat ( dragOptions . yaxes ) ;
3637
3738 if ( mode === 'lasso' ) {
3839 var pts = filteredPolygon ( [ [ x0 , y0 ] ] , constants . BENDPX ) ;
@@ -80,8 +81,14 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
8081 } ) ;
8182 }
8283
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+
8389 dragOptions . moveFn = function ( dx0 , dy0 ) {
84- var poly ;
90+ var poly ,
91+ ax ;
8592 x1 = Math . max ( 0 , Math . min ( pw , dx0 + x0 ) ) ;
8693 y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ;
8794
@@ -129,6 +136,27 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
129136 }
130137
131138 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+ }
132160 dragOptions . gd . emit ( 'plotly_selecting' , eventData ) ;
133161 } ;
134162
0 commit comments