fix(candlestick/boxplot): accept null and undefined data items. - #21734
Open
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Open
fix(candlestick/boxplot): accept null and undefined data items.#21734SEPURI-SAI-KRISHNA wants to merge 1 commit into
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Conversation
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
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.
Brief Information
This pull request is in the type of:
What does this PR do?
Stops
candlestickandboxplotfrom throwing when a data item is an empty value (null/undefined).Fixed issues
Details
Before: What was the problem?
Empty values are documented as
'-',null,undefinedorNaN, and every other series treats them interchangeably. Forcandlestickandboxplotonly'-'worked —nullandundefinedthrew before anything was rendered:Both series share
WhiskerBoxCommonMixin#getInitialData. When the base axis is a category axis, it walks the raw data to prepend the ordinal index to each item, and the second branch dereferencesitemwithout checking that it exists:'-'survives only because a string has novalueproperty;nullandundefinedcannot be read at all. The throw happens insidesetOption, so it takes down the whole chart rather than just the one item — a real problem for financial charts, where gaps in an OHLC series are routine.After: How does it behave after the fixing?
The branch now checks that
itemexists before readingitem.value, so an empty item falls through to the existingelseand is passed along untouched — exactly the path'-'already takes.The gap becomes an empty data item that is not drawn, and, importantly, the items after it keep their correct ordinal index (the index is derived from the loop position, not from a running counter), so the series stays aligned with the category axis.
Document Info
One of the following should be checked.
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
Added
test/ut/spec/series/whiskerBoxEmptyValue.test.ts:null/undefined/'-'items for both
candlestickandboxplot, plus a case asserting that the item aftera gap still maps to the third category and keeps its values.
The
'-'cases pass both before and after, and are kept as controls showing theinconsistency this PR removes. The
null/undefinedcases fail onmasterwithTypeError: Cannot read properties of null (reading 'value').npm run test,npx tsc --noEmitandeslinton the changed file all pass.Merging options
Other information
This touches
src/chart/helper/whiskerBoxCommon.ts, which #21727 also modifies, butthe two changes are in different functions and do not overlap.