@@ -11,6 +11,7 @@ var getBinSpanLabelRound = require('@src/traces/histogram/bin_label_vals');
11
11
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
12
12
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
13
13
var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
14
+ var failTest = require ( '../assets/fail_test' ) ;
14
15
15
16
16
17
describe ( 'Test histogram' , function ( ) {
@@ -690,7 +691,7 @@ describe('Test histogram', function() {
690
691
expect ( trace . _autoBinFinished ) . toBeUndefined ( i ) ;
691
692
} ) ;
692
693
} )
693
- . catch ( fail )
694
+ . catch ( failTest )
694
695
. then ( done ) ;
695
696
} ) ;
696
697
@@ -703,7 +704,42 @@ describe('Test histogram', function() {
703
704
. then ( function ( ) {
704
705
expect ( gd . _fullLayout . xaxis . range ) . toBeCloseToArray ( [ 2 , 4 ] , 3 ) ;
705
706
} )
706
- . catch ( fail )
707
+ . catch ( failTest )
708
+ . then ( done ) ;
709
+ } ) ;
710
+
711
+ it ( 'can recalc after the first trace is hidden' , function ( done ) {
712
+ function assertTraceCount ( n ) {
713
+ expect ( gd . querySelectorAll ( '.trace' ) . length ) . toBe ( n ) ;
714
+ }
715
+
716
+ Plotly . newPlot ( gd , [ {
717
+ x : [ 1 , 2 , 3 ] , type : 'histogram'
718
+ } , {
719
+ x : [ 1 , 2 , 3 ] , type : 'histogram'
720
+ } , {
721
+ x : [ 1 , 2 , 3 ] , type : 'histogram'
722
+ } ] )
723
+ . then ( function ( ) {
724
+ assertTraceCount ( 3 ) ;
725
+ return Plotly . restyle ( gd , 'visible' , 'legendonly' ) ;
726
+ } )
727
+ . then ( function ( ) {
728
+ assertTraceCount ( 0 ) ;
729
+ return Plotly . restyle ( gd , 'visible' , true , [ 1 ] ) ;
730
+ } )
731
+ . then ( function ( ) {
732
+ assertTraceCount ( 1 ) ;
733
+ return Plotly . restyle ( gd , 'visible' , true , [ 2 ] ) ;
734
+ } )
735
+ . then ( function ( ) {
736
+ assertTraceCount ( 2 ) ;
737
+ return Plotly . restyle ( gd , 'visible' , true ) ;
738
+ } )
739
+ . then ( function ( ) {
740
+ assertTraceCount ( 3 ) ;
741
+ } )
742
+ . catch ( failTest )
707
743
. then ( done ) ;
708
744
} ) ;
709
745
} ) ;
0 commit comments