Repository navigation
Fix interval constraint value normalization in contour traces - #8125
Merged
Merged
Conversation
Contributor
|
Thanks for putting this together. I'll review and follow up with you. |
camdecoster
reviewed
Nov 18, 2026
camdecoster
left a comment
Contributor
There was a problem hiding this comment.
This is a good bug fix. Could you please address my comments? With that, it should be ready to approve.
Comment on lines
59
to
71
Contributor
There was a problem hiding this comment.
It's not your fault, but this logic seems confusing. What do you think of this as an alternative?
} else {
switch (contours.value.length) {
case 0:
contours.value = [0, 1];
break;
case 1:
zvalue = parseFloat(contours.value[0]);
contours.value = [zvalue, zvalue + 1];
break;
default:
// Keep only the first two values
contours.value = [parseFloat(contours.value[0]), parseFloat(contours.value[1])];
}
}
Contributor
Author
There was a problem hiding this comment.
Yeah, it's much cleaner this way. I've made the changes based on your suggestion.
Comment on lines
+134
to
+135
| value: [10, 20, 30], | ||
| expected: [10, 20] |
Contributor
There was a problem hiding this comment.
Could you update this case to use float values to check the call to parseFloat?
| expect(traceOut.ycalendar).toBe('ethiopian'); | ||
| }); | ||
|
|
||
| it('should coerce constraint interval values to two numbers', function() { |
Contributor
There was a problem hiding this comment.
Could you add a case that checks a float array?
camdecoster
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8124
Fix incorrect normalization of
contours.valuefor interval constraints.This causes cases such as:
This PR normalizes them as:
The issue is in constraint_defaults.js, where the array length is checked against
contours.lengthinstead ofcontours.value.length, and arrays longer than two values are handled withslice(2)instead ofslice(0, 2).The relevant logic is this part:
plotly.js/src/traces/contour/constraint_defaults.js
Lines 59 to 71 in 1ef3c78
This affects both
contourandcontourcarpet, since they share the same constraint defaults.