@@ -809,6 +809,63 @@ describe('Test select box and lasso per trace:', function() {
809809 . then ( done ) ;
810810 } ) ;
811811
812+ it ( 'should work for date/category traces' , function ( done ) {
813+ var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'x' , 'y' ] ) ;
814+
815+ var fig = {
816+ data : [ {
817+ x : [ '2017-01-01' , '2017-02-01' , '2017-03-01' ] ,
818+ y : [ 'a' , 'b' , 'c' ]
819+ } , {
820+ type : 'bar' ,
821+ x : [ '2017-01-01' , '2017-02-02' , '2017-03-01' ] ,
822+ y : [ 'a' , 'b' , 'c' ]
823+ } ] ,
824+ layout : {
825+ dragmode : 'lasso' ,
826+ width : 400 ,
827+ height : 400
828+ }
829+ } ;
830+ addInvisible ( fig ) ;
831+
832+ var x0 = 100 ;
833+ var y0 = 100 ;
834+ var x1 = 250 ;
835+ var y1 = 250 ;
836+
837+ Plotly . plot ( gd , fig )
838+ . then ( function ( ) {
839+ return _run (
840+ [ [ x0 , y0 ] , [ x1 , y0 ] , [ x1 , y1 ] , [ x0 , y1 ] , [ x0 , y0 ] ] ,
841+ function ( ) {
842+ assertPoints ( [
843+ [ 0 , '2017-02-01' , 'b' ] ,
844+ [ 1 , '2017-02-02' , 'b' ]
845+ ] ) ;
846+ } ,
847+ null , LASSOEVENTS , 'date/category lasso'
848+ ) ;
849+ } )
850+ . then ( function ( ) {
851+ return Plotly . relayout ( gd , 'dragmode' , 'select' ) ;
852+ } )
853+ . then ( function ( ) {
854+ return _run (
855+ [ [ x0 , y0 ] , [ x1 , y1 ] ] ,
856+ function ( ) {
857+ assertPoints ( [
858+ [ 0 , '2017-02-01' , 'b' ] ,
859+ [ 1 , '2017-02-02' , 'b' ]
860+ ] ) ;
861+ } ,
862+ null , BOXEVENTS , 'date/category select'
863+ ) ;
864+ } )
865+ . catch ( fail )
866+ . then ( done ) ;
867+ } ) ;
868+
812869 it ( 'should work for histogram traces' , function ( done ) {
813870 var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'x' , 'y' ] ) ;
814871 var assertRanges = makeAssertRanges ( ) ;
@@ -856,7 +913,7 @@ describe('Test select box and lasso per trace:', function() {
856913 } ) ;
857914
858915 it ( 'should work for box traces' , function ( done ) {
859- var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'y' ] ) ;
916+ var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'y' , 'x' ] ) ;
860917 var assertRanges = makeAssertRanges ( ) ;
861918 var assertLassoPoints = makeAssertLassoPoints ( ) ;
862919
@@ -875,9 +932,9 @@ describe('Test select box and lasso per trace:', function() {
875932 [ [ 200 , 200 ] , [ 400 , 200 ] , [ 400 , 350 ] , [ 200 , 350 ] , [ 200 , 200 ] ] ,
876933 function ( ) {
877934 assertPoints ( [
878- [ 0 , 0.2 ] , [ 0 , 0.3 ] , [ 0 , 0.5 ] , [ 0 , 0.7 ] ,
879- [ 1 , 0.2 ] , [ 1 , 0.5 ] , [ 1 , 0.7 ] , [ 1 , 0.7 ] ,
880- [ 2 , 0.3 ] , [ 2 , 0.6 ] , [ 2 , 0.6 ]
935+ [ 0 , 0.2 , 'day 2' ] , [ 0 , 0.3 , 'day 2' ] , [ 0 , 0.5 , 'day 2' ] , [ 0 , 0.7 , 'day 2' ] ,
936+ [ 1 , 0.2 , 'day 2' ] , [ 1 , 0.5 , 'day 2' ] , [ 1 , 0.7 , 'day 2' ] , [ 1 , 0.7 , 'day 2' ] ,
937+ [ 2 , 0.3 , 'day 1' ] , [ 2 , 0.6 , 'day 1' ] , [ 2 , 0.6 , 'day 1' ]
881938 ] ) ;
882939 assertLassoPoints ( [
883940 [ 'day 1' , 'day 2' , 'day 2' , 'day 1' , 'day 1' ] ,
@@ -895,9 +952,9 @@ describe('Test select box and lasso per trace:', function() {
895952 [ [ 200 , 200 ] , [ 400 , 350 ] ] ,
896953 function ( ) {
897954 assertPoints ( [
898- [ 0 , 0.2 ] , [ 0 , 0.3 ] , [ 0 , 0.5 ] , [ 0 , 0.7 ] ,
899- [ 1 , 0.2 ] , [ 1 , 0.5 ] , [ 1 , 0.7 ] , [ 1 , 0.7 ] ,
900- [ 2 , 0.3 ] , [ 2 , 0.6 ] , [ 2 , 0.6 ]
955+ [ 0 , 0.2 , 'day 2' ] , [ 0 , 0.3 , 'day 2' ] , [ 0 , 0.5 , 'day 2' ] , [ 0 , 0.7 , 'day 2' ] ,
956+ [ 1 , 0.2 , 'day 2' ] , [ 1 , 0.5 , 'day 2' ] , [ 1 , 0.7 , 'day 2' ] , [ 1 , 0.7 , 'day 2' ] ,
957+ [ 2 , 0.3 , 'day 1' ] , [ 2 , 0.6 , 'day 1' ] , [ 2 , 0.6 , 'day 1' ]
901958 ] ) ;
902959 assertRanges ( [ [ 'day 1' , 'day 2' ] , [ 0.1875 , 0.71 ] ] ) ;
903960 } ,
0 commit comments