fix(custom): resolve api.value() NaN issue for key-value data format#21342
Open
Srajan-Sanjay-Saxena wants to merge 1 commit intoapache:masterfrom
Open
fix(custom): resolve api.value() NaN issue for key-value data format#21342Srajan-Sanjay-Saxena wants to merge 1 commit intoapache:masterfrom
Srajan-Sanjay-Saxena wants to merge 1 commit intoapache:masterfrom
Conversation
- Fixed CustomView.ts value() function to handle key-value data [{x:100, y:200}]
- Added fallback to raw data access when store access fails for object format
- Maintains backward compatibility with array format [[100, 200]]
- Supports both string ('x') and numeric (0) dimension access
- Added comprehensive test coverage for edge cases and data formats
Resolves issue where api.value() returned NaN for object-based data while
array-based data worked correctly in custom series renderItem function.
|
Thanks for your contribution! To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: This message is shown because the PR description doesn't contain the document related template. |
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.
Resolves critical issue where api.value() returned NaN for object-based data while array-based data worked correctly in custom series renderItem function.
Brief Information
This pull request is in the type of:
What does this PR do?
Fixes api.value() function in custom series to properly handle key-value data format [{x:100, y:200}] by adding fallback to raw data access when internal store access fails.
Fixed issues
Critical bug where custom series api.value() returned NaN for key-value object data format while array format worked correctly.
Details
Before: What was the problem?
Root Cause: The
valuefunction insrc/chart/custom/CustomView.ts(lines 755-783) only attempted to access ECharts' internal data store viadata.getItemModel(dataIndex).get(dim). For key-value data format[{x: 100, y: 200}], the dimension mapping failed in the store, causingapi.value('x')andapi.value(0)to returnNaN.Technical Issue:
{x: 100, y: 200}weren't properly mapped to store dimensions[[100, 200]]worked because store mapping succeededImpact:
api.value('x')returnedNaNinstead of100api.value(0)returnedNaNinstead of100After: How does it behave after the fixing?
Solution: Enhanced the
valuefunction with intelligent fallback mechanism:data.getItemModel(dataIndex).get(dim)api.value('x')→ searches raw object keysapi.value(0)→ maps to dimension order for objectsTechnical Implementation: