@@ -11,6 +11,7 @@ var getBinSpanLabelRound = require('@src/traces/histogram/bin_label_vals');
1111var createGraphDiv = require ( '../assets/create_graph_div' ) ;
1212var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
1313var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
14+ var failTest = require ( '../assets/fail_test' ) ;
1415
1516
1617describe ( 'Test histogram' , function ( ) {
@@ -690,7 +691,7 @@ describe('Test histogram', function() {
690691 expect ( trace . _autoBinFinished ) . toBeUndefined ( i ) ;
691692 } ) ;
692693 } )
693- . catch ( fail )
694+ . catch ( failTest )
694695 . then ( done ) ;
695696 } ) ;
696697
@@ -703,7 +704,42 @@ describe('Test histogram', function() {
703704 . then ( function ( ) {
704705 expect ( gd . _fullLayout . xaxis . range ) . toBeCloseToArray ( [ 2 , 4 ] , 3 ) ;
705706 } )
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 )
707743 . then ( done ) ;
708744 } ) ;
709745 } ) ;
0 commit comments