Fix: Respect encode.value in visualMap for multi-column datasets#21405
Fix: Respect encode.value in visualMap for multi-column datasets#21405Adityakashyap1011 wants to merge 1 commit intoapache:masterfrom
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. |
|
Thanks for the PR! A few concerns:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where visualMap ignored the series encode.value configuration when working with datasets containing multiple value columns. Previously, visualMap used a backward search algorithm that always selected the last non-coordinate dimension, regardless of the encode.value setting. The fix modifies the dimension resolution logic to respect the encoded value dimension before falling back to the original behavior.
Key Changes:
- Modified
getDataDimensionIndex()to check for encoded 'value' dimension usingdata.mapDimension('value')before performing backward search - Added test case demonstrating the fix with a heatmap using multiple value columns
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/component/visualMap/VisualMapModel.ts | Added logic to respect series encode configuration by checking data.mapDimension('value') before falling back to backward dimension search |
| test/heatmap-encode-value-fix.html | Added test case demonstrating the fix with a heatmap that has multiple value columns and uses encode.value to specify which column to use for visual mapping |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Brief Information
This pull request is in the type of:
What does this PR do?
Fixes visualMap to respect the series encode.value configuration when determining which dimension to use for visual mapping.
Fixed issues
Details
Before: What was the problem?
When a series (e.g., heatmap with matrix coordinate system) has multiple value columns in the dataset and uses encode to specify which dimension should be mapped as 'value', the visualMap component was ignoring this configuration. Instead, it used a backward search algorithm that always picked the last non-coordinate dimension.
Example:
dataset: {
source: [
['x', 'y', 'value1', 'value2', 'value3'],
['A', 'X', 0.1, 0.5, 0.9],
['A', 'Y', 0.2, 0.6, 0.8],
['B', 'X', 0.3, 0.7, 0.7],
['B', 'Y', 0.4, 0.8, 0.6]
]
},
series: [{
type: 'heatmap',
coordinateSystem: 'matrix',
encode: {
x: 'x',
y: 'y',
value: 'value1'
}
}]
The visualMap would incorrectly use 'value3' (last column) instead of 'value1' for color mapping, producing an inverted gradient.
After: How does it behave after the fixing?
Modified getDataDimensionIndex() in src/component/visualMap/VisualMapModel.ts to:
Now when encode: { value: 'value1' } is specified, the visualMap correctly uses 'value1' for color mapping, producing the expected visual gradient.
Document Info
One of the following should be checked.
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
Test file: test/heatmap-encode-value-fix.html demonstrates the fix with a heatmap using matrix coordinate system and multiple value columns.
Merging options
Other information
Files modified: