@@ -630,6 +630,8 @@ describe('annotations autorange', function() {
630630describe ( 'annotation clicktoshow' , function ( ) {
631631 var gd ;
632632
633+ beforeEach ( function ( ) { gd = createGraphDiv ( ) ; } ) ;
634+
633635 afterEach ( destroyGraphDiv ) ;
634636
635637 function layout ( ) {
@@ -716,8 +718,6 @@ describe('annotation clicktoshow', function() {
716718 var allIndices = layout ( ) . annotations . map ( function ( v , i ) { return i ; } ) ;
717719
718720 it ( 'should select only clicktoshow annotations matching x, y, and axes of any point' , function ( done ) {
719- gd = createGraphDiv ( ) ;
720-
721721 // first try to select without adding clicktoshow, both visible and invisible
722722 Plotly . plot ( gd , data , layout ( ) )
723723 // clicktoshow is off initially, so it doesn't *expect* clicking will
@@ -754,6 +754,62 @@ describe('annotation clicktoshow', function() {
754754 . catch ( failTest )
755755 . then ( done ) ;
756756 } ) ;
757+
758+ it ( 'works on date and log axes' , function ( done ) {
759+ Plotly . plot ( gd , [ {
760+ x : [ '2016-01-01' , '2016-01-02' , '2016-01-03' ] ,
761+ y : [ 1 , 1 , 3 ]
762+ } ] , {
763+ yaxis : { type : 'log' } ,
764+ annotations : [ {
765+ x : '2016-01-02' ,
766+ y : 0 ,
767+ text : 'boo' ,
768+ showarrow : true ,
769+ clicktoshow : 'onoff' ,
770+ visible : false
771+ } ]
772+ } )
773+ . then ( function ( ) {
774+ expect ( gd . _fullLayout . xaxis . type ) . toBe ( 'date' ) ;
775+ expect ( gd . _fullLayout . yaxis . type ) . toBe ( 'log' ) ;
776+ } )
777+ . then ( clickAndCheck ( { newPts : [ [ '2016-01-02' , 1 ] ] , newCTS : true , on : [ 0 ] } ) )
778+ . catch ( failTest )
779+ . then ( done ) ;
780+ } ) ;
781+
782+ it ( 'works on category axes' , function ( done ) {
783+ Plotly . plot ( gd , [ {
784+ x : [ 'a' , 'b' , 'c' ] ,
785+ y : [ 1 , 2 , 3 ]
786+ } ] , {
787+ annotations : [ {
788+ x : 'b' ,
789+ y : 2 ,
790+ text : 'boo' ,
791+ showarrow : true ,
792+ clicktoshow : 'onout' ,
793+ visible : false
794+ } , {
795+ // you can also use category serial numbers
796+ x : 2 ,
797+ y : 3 ,
798+ text : 'hoo' ,
799+ showarrow : true ,
800+ clicktoshow : 'onout' ,
801+ visible : false
802+ } ]
803+ } )
804+ . then ( function ( ) {
805+ expect ( gd . _fullLayout . xaxis . type ) . toBe ( 'category' ) ;
806+ expect ( gd . _fullLayout . yaxis . type ) . toBe ( 'linear' ) ;
807+ } )
808+ . then ( clickAndCheck ( { newPts : [ [ 'b' , 2 ] ] , newCTS : true , on : [ 0 ] , step : 1 } ) )
809+ . then ( clickAndCheck ( { newPts : [ [ 'c' , 3 ] ] , newCTS : true , on : [ 1 ] , step : 2 } ) )
810+ . catch ( failTest )
811+ . then ( done ) ;
812+ } ) ;
757813} ) ;
758814
759815describe ( 'annotation dragging' , function ( ) {
0 commit comments