Repository navigation
Accept 3-element zmin and zmax for rgb and hsl image traces - #8203
Open
RuslanGrigoryev wants to merge 2 commits into
Open
RuslanGrigoryev wants to merge 2 commits into
RuslanGrigoryev wants to merge 2 commits into
Conversation
The rgb and hsl colormodels have 3 components, but the schema declared zmin and zmax as exactly 4 elements. Plotly.validate and the validators generated from the schema rejected valid 3-element arrays. Setting freeLength accepts 3 and 4 elements.
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.
Fixes #8182
Set
freeLength: trueonzminandzmaxof theimagetrace. Thergbandhslcolormodels have 3 components, soPlotly.validateand the plotly.py validators now accept 3-element arrays.Why the change is correct
The schema declared
zminandzmaxasinfo_arraywith 4 fixed items.Lib.validaterejects an array when its length differs fromitems.lengthandfreeLengthis not set.src/traces/image/constants.tsdefines 3-element ranges forrgbandhsl. A validator cannot read thecolormodelof the trace, so it must accept 3 or 4 elements.Trace defaults already handle short arrays.
image/defaults.jsfills missing elements from the colormodel defaults, so rendering does not change.Trade-offs
freeLengthalso accepts arrays with 0 to 2 elements, as it does for otherinfo_arrayattributesPlotly.validatereports a value with more than 4 elements asunused, and a non-number asvalue. The new test covers the two cases.itemsarray, so the generated type changes from a 4-tuple tonumber[]. A single-objectitemswould change the schema more.Lib.validatecall on a value with more than 4 elements throws, becauseitems[4]is undefined. The same shape exists forparcoordsconstraintrange.Plotly.validatedoes not reach that call. I did not change it.Tests
validate(test/jasmine/tests/validate_test.js), two new testsnpm run lint,npm run typecheck,npm run test-syntax,npm run schema-typegen-diff-checkGenerated files
npm run schemaregeneratedtest/plot-schema.jsonandsrc/types/generated/schema.d.ts.Maintainer note
KoolADE85 approved a plotly.js fix in plotly/plotly.py#5869. The issue asks which form of
itemsthe maintainers prefer. Please confirm before merge.