@@ -710,3 +710,68 @@ describe('Test gl plot side effects', function() {
710710 } ) . then ( done ) ;
711711 } ) ;
712712} ) ;
713+
714+ describe ( 'gl2d interaction' , function ( ) {
715+ var gd ;
716+
717+ beforeAll ( function ( ) {
718+ jasmine . addMatchers ( customMatchers ) ;
719+ } ) ;
720+
721+ beforeEach ( function ( ) {
722+ gd = createGraphDiv ( ) ;
723+ } ) ;
724+
725+ afterEach ( function ( ) {
726+ Plotly . purge ( gd ) ;
727+ destroyGraphDiv ( ) ;
728+ } ) ;
729+
730+ it ( 'data-referenced annotations should update on drag' , function ( done ) {
731+
732+ function drag ( start , end ) {
733+ var opts = { buttons : 1 } ;
734+
735+ mouseEvent ( 'mousemove' , start [ 0 ] , start [ 1 ] , opts ) ;
736+ mouseEvent ( 'mousedown' , start [ 0 ] , start [ 1 ] , opts ) ;
737+ mouseEvent ( 'mousemove' , end [ 0 ] , end [ 1 ] , opts ) ;
738+ mouseEvent ( 'mouseup' , end [ 0 ] , end [ 1 ] , opts ) ;
739+ }
740+
741+ function assertAnnotation ( xy ) {
742+ var ann = d3 . select ( 'g.annotation-text-g' ) ;
743+ var x = + ann . attr ( 'x' ) ;
744+ var y = + ann . attr ( 'y' ) ;
745+
746+ expect ( [ x , y ] ) . toBeCloseToArray ( xy ) ;
747+ }
748+
749+ Plotly . plot ( gd , [ {
750+ type : 'scattergl' ,
751+ x : [ 1 , 2 , 3 ] ,
752+ y : [ 2 , 1 , 2 ]
753+ } ] , {
754+ annotations : [ {
755+ x : 2 ,
756+ y : 1 ,
757+ text : 'text'
758+ } ] ,
759+ dragmode : 'pan'
760+ } )
761+ . then ( function ( ) {
762+ assertAnnotation ( [ 340 , 334 ] ) ;
763+
764+ drag ( [ 250 , 200 ] , [ 150 , 300 ] ) ;
765+ assertAnnotation ( [ 410 , 264 ] ) ;
766+
767+ return Plotly . relayout ( gd , {
768+ 'xaxis.range' : [ 1.5 , 2.5 ] ,
769+ 'yaxis.range' : [ 1 , 1.5 ]
770+ } ) ;
771+ } )
772+ . then ( function ( ) {
773+ assertAnnotation ( [ 340 , 340 ] ) ;
774+ } )
775+ . then ( done ) ;
776+ } ) ;
777+ } ) ;
0 commit comments