Fix interval constraint value normalization in contour traces by Lexachoc · Pull Request #8125 · plotly/plotly.js · GitHub
Skip to content

Fix interval constraint value normalization in contour traces - #8125

Open
Lexachoc wants to merge 4 commits into
plotly:mainfrom
Lexachoc:fix-constraint-contour
Open

Lexachoc wants to merge 4 commits into
plotly:mainfrom
Lexachoc:fix-constraint-contour

Conversation

@Lexachoc

Copy link
Copy Markdown
Contributor

Closes #8124

Fix incorrect normalization of contours.value for interval constraints.

This causes cases such as:

[]           -> [NaN, NaN]
[5]          -> [5, NaN]
[2,4,8,10]   -> [8,10]

This PR normalizes them as:

[]           -> [0,1]
[5]          -> [5,6]
[2,4,8,10]   -> [2,4]

The issue is in constraint_defaults.js, where the array length is checked against contours.length instead of contours.value.length, and arrays longer than two values are handled with slice(2) instead of slice(0, 2).

The relevant logic is this part:

This affects both contour and contourcarpet, since they share the same constraint defaults.

@camdecoster camdecoster self-assigned this Oct 15, 2026
@camdecoster

Copy link
Copy Markdown
Contributor

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.

[BUG]: Incorrect interval constraint normalization for contours.value in contour traces

2 participants