Skip to content

Fix rangebreaks that overlap two or more located breaks - #8167

Open
Tornacyclo wants to merge 2 commits into
plotly:mainfrom
Tornacyclo:fix-rangebreaks-overlap
Open

Tornacyclo wants to merge 2 commits into
plotly:mainfrom
Tornacyclo:fix-rangebreaks-overlap

Conversation

@Tornacyclo

Copy link
Copy Markdown

Merge every located break that a new rangebreak overlaps, so that the located breaks never overlap.

Closes #7270. The same cause gives the symptoms in #5783 and in plotly/plotly.py#2998.

Cause: if a new break overlapped two located breaks, addBreak in ax.locateBreaks widened the two breaks but did not merge them. setScale and calcBreaksLength sum the break lengths, so they counted the overlap two times. A holiday between two overnight breaks thus adds 24 extra hours:

Fix: addBreak keeps the first overlapped break, extends it to the union, and removes the other overlapped breaks. If a new break overlaps zero or one located break, the output does not change.

Tests: a new spec in axes_test.js (*rangebreaks* > during setConvert) fails on main and passes with the fix. Other suites that use rangebreaks: range_slider, cartesian_interact, hover, draw_newshape, draw_newselection. The 24 image mocks with rangebreaks give the same located breaks before and after the fix, so no baseline changes.

Before (v4.2.0) After
image image
image image

addBreak widened every located break that a new break overlapped, but it
did not merge them. A holiday break between two overnight breaks thus
counted 24 hours two times in the axis scale and in the autorange break
length. The axis lost one day per holiday, or the l2p slope became
negative and the trace did not appear.
@KoolADE85
KoolADE85 self-requested a review November 10, 2026 20:30
@KoolADE85 KoolADE85 self-assigned this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plot does not appear in some cases if rangebreaks overlap

2 participants