@@ -1336,6 +1336,23 @@ def _construct_update_data(
1336
1336
# 1. Base case - there is an x-range specified in the front-end
1337
1337
start_matches = self ._re_matches (re .compile (r"xaxis\d*.range\[0]" ), cl_k )
1338
1338
stop_matches = self ._re_matches (re .compile (r"xaxis\d*.range\[1]" ), cl_k )
1339
+
1340
+ # When the user sets x range via update_xaxes and the number of points in
1341
+ # data exceeds the default_n_shown_samples, then after resetting the axes
1342
+ # the relayout may only have "xaxis.range", instead of "xaxis.range[0]" and
1343
+ # "xaxis.range[1]". If this happens, we need to manually add "xaxis.range[0]"
1344
+ # and "xaxis.range[1]", otherwise resetting axes wouldn't work.
1345
+ if not (start_matches and stop_matches ):
1346
+ range_matches = self ._re_matches (re .compile (r"xaxis\d*.range" ), cl_k )
1347
+ for range_match in range_matches :
1348
+ x_range = relayout_data [range_match ]
1349
+ start , stop = x_range
1350
+ start_match = range_match + "[0]"
1351
+ stop_match = range_match + "[1]"
1352
+ relayout_data [start_match ] = start
1353
+ relayout_data [stop_match ] = stop
1354
+ start_matches .append (start_match )
1355
+ stop_matches .append (stop_match )
1339
1356
if start_matches and stop_matches : # when both are not empty
1340
1357
for t_start_key , t_stop_key in zip (start_matches , stop_matches ):
1341
1358
# Check if the xaxis<NUMB> part of xaxis<NUMB>.[0-1] matches
0 commit comments