File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var Legend = require('@src/components/legend');
8
8
var pkg = require ( '../../../package.json' ) ;
9
9
var subroutines = require ( '@src/plot_api/subroutines' ) ;
10
10
11
+ var d3 = require ( 'd3' ) ;
11
12
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
12
13
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
13
14
@@ -779,6 +780,43 @@ describe('Test plot api', function() {
779
780
} ) ;
780
781
} ) ;
781
782
783
+ describe ( 'Plotly.redraw' , function ( ) {
784
+
785
+ afterEach ( destroyGraphDiv ) ;
786
+
787
+ it ( '' , function ( done ) {
788
+ var gd = createGraphDiv ( ) ,
789
+ initialData = [ ] ,
790
+ layout = { title : 'Redraw' } ;
791
+
792
+ Plotly . newPlot ( gd , initialData , layout ) ;
793
+
794
+ var trace1 = {
795
+ x : [ 1 , 2 , 3 , 4 ] ,
796
+ y : [ 4 , 1 , 5 , 3 ] ,
797
+ name : 'First Trace'
798
+ } ;
799
+ var trace2 = {
800
+ x : [ 1 , 2 , 3 , 4 ] ,
801
+ y : [ 14 , 11 , 15 , 13 ] ,
802
+ name : 'Second Trace'
803
+ } ;
804
+ var trace3 = {
805
+ x : [ 1 , 2 , 3 , 4 ] ,
806
+ y : [ 5 , 3 , 7 , 1 ] ,
807
+ name : 'Third Trace'
808
+ } ;
809
+
810
+ var newData = [ trace1 , trace2 , trace3 ] ;
811
+ gd . data = newData ;
812
+
813
+ Plotly . redraw ( gd ) . then ( function ( ) {
814
+ expect ( d3 . selectAll ( 'g.trace.scatter' ) . size ( ) ) . toEqual ( 3 ) ;
815
+ } )
816
+ . then ( done ) ;
817
+ } ) ;
818
+ } ) ;
819
+
782
820
describe ( 'cleanData' , function ( ) {
783
821
var gd ;
784
822
You can’t perform that action at this time.
0 commit comments