Fix: Respect encode.value in visualMap for multi-column datasets #21405
+95
−0
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?
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: