@@ -746,6 +746,55 @@ def test_hf_data_property_subplots_reload_data():
746746 )
747747
748748
749+ def test_hf_data_subplots_non_shared_xaxes ():
750+ fwr = FigureWidgetResampler (make_subplots (rows = 2 , cols = 1 , shared_xaxes = False ))
751+ n = 100_000
752+ x = np .arange (n )
753+ y = np .sin (x )
754+
755+ assert len (fwr .hf_data ) == 0
756+ fwr .add_trace (go .Scattergl (name = "test" ), hf_x = x , hf_y = y , row = 1 , col = 1 )
757+ fwr .add_trace (go .Scattergl (name = "test" ), hf_x = x , hf_y = y , row = 2 , col = 1 )
758+
759+ fwr .layout .update (
760+ {
761+ "xaxis2" : {"range" : [40_000 , 60_000 ]},
762+ "yaxis2" : {"range" : [- 10 , 3 ]},
763+ },
764+ overwrite = False ,
765+ )
766+ x_0 = fwr .data [0 ]['x' ]
767+ assert 0 <= x_0 [0 ] <= (n / 1000 )
768+ assert (n - 1000 ) <= x_0 [- 1 ] <= n - 1
769+ x_1 = fwr .data [1 ]['x' ]
770+ assert 40_000 <= x_1 [0 ] <= 40_000 + (20_000 / 1000 )
771+ assert (60_000 - 20_000 / 1_000 ) <= x_1 [- 1 ] <= 60_000
772+
773+
774+ def test_hf_data_subplots_non_shared_xaxes_row_col_none ():
775+ fwr = FigureWidgetResampler (make_subplots (rows = 2 , cols = 1 , shared_xaxes = False ))
776+ n = 100_000
777+ x = np .arange (n )
778+ y = np .sin (x )
779+
780+ assert len (fwr .hf_data ) == 0
781+ fwr .add_trace (go .Scattergl (name = "test" ), hf_x = x , hf_y = y )
782+ fwr .add_trace (go .Scattergl (name = "test" ), hf_x = x , hf_y = y , row = 2 , col = 1 )
783+
784+ fwr .layout .update (
785+ {
786+ "xaxis2" : {"range" : [40_000 , 60_000 ]},
787+ "yaxis2" : {"range" : [- 10 , 3 ]},
788+ },
789+ overwrite = False ,
790+ )
791+ x_0 = fwr .data [0 ]['x' ]
792+ assert 0 <= x_0 [0 ] <= (n / 1000 )
793+ assert (n - 1000 ) <= x_0 [- 1 ] <= n - 1
794+ x_1 = fwr .data [1 ]['x' ]
795+ assert 40_000 <= x_1 [0 ] <= 40_000 + (20_000 / 1000 )
796+ assert (60_000 - 20_000 / 1_000 ) <= x_1 [- 1 ] <= 60_000
797+
749798def test_updates_two_traces ():
750799 n = 1_000_000
751800 X = np .arange (n )
0 commit comments