@@ -809,6 +809,63 @@ describe('Test select box and lasso per trace:', function() {
809
809
. then ( done ) ;
810
810
} ) ;
811
811
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
+
812
869
it ( 'should work for histogram traces' , function ( done ) {
813
870
var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'x' , 'y' ] ) ;
814
871
var assertRanges = makeAssertRanges ( ) ;
@@ -856,7 +913,7 @@ describe('Test select box and lasso per trace:', function() {
856
913
} ) ;
857
914
858
915
it ( 'should work for box traces' , function ( done ) {
859
- var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'y' ] ) ;
916
+ var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'y' , 'x' ] ) ;
860
917
var assertRanges = makeAssertRanges ( ) ;
861
918
var assertLassoPoints = makeAssertLassoPoints ( ) ;
862
919
@@ -875,9 +932,9 @@ describe('Test select box and lasso per trace:', function() {
875
932
[ [ 200 , 200 ] , [ 400 , 200 ] , [ 400 , 350 ] , [ 200 , 350 ] , [ 200 , 200 ] ] ,
876
933
function ( ) {
877
934
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' ]
881
938
] ) ;
882
939
assertLassoPoints ( [
883
940
[ 'day 1' , 'day 2' , 'day 2' , 'day 1' , 'day 1' ] ,
@@ -895,9 +952,9 @@ describe('Test select box and lasso per trace:', function() {
895
952
[ [ 200 , 200 ] , [ 400 , 350 ] ] ,
896
953
function ( ) {
897
954
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' ]
901
958
] ) ;
902
959
assertRanges ( [ [ 'day 1' , 'day 2' ] , [ 0.1875 , 0.71 ] ] ) ;
903
960
} ,
0 commit comments