feat(visualMap): add seriesTargets option for multiple series-dimension mappings#20703
feat(visualMap): add seriesTargets option for multiple series-dimension mappings#20703plainheart merged 6 commits intoapache:masterfrom
seriesTargets option for multiple series-dimension mappings#20703Conversation
|
Thanks for your contribution! Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the |
There was a problem hiding this comment.
I don't think it's intuitive to use dimension: [1,2] to represent seriesIndex: 0 -> 1, 1 -> 2, 2 -> 2. Instead, it's more like using both dimension 1 and 2.
I think the problem of #20662 should be best solved using the third demo @MatthiasMert gave. I would suggest closing this PR unless a more solid reason is given. Thanks for your contribution anyway.
Using the same visualMap on 2d dataset requires the dataset to be splitted looks overkill. |
Ovilia
left a comment
There was a problem hiding this comment.
It's true that using both dimension 1 and 2 is technically impossible. Even though, it's misleading to provide such API design. Again, I would suggest using the 3rd solution or avoid using dataset in your case. Adding a new feature should take a lot of things into consideration so I would say it's not quite a good design of API unless a better plan is proposed.
Again, the suggested workaround (splitting the dataset) is unacceptable in my use case. I understand your concerns about the API design. Even if user is misled into thinking it as if you insist, I will keep this PR open until a better solutiion is proposed. |
|
Why is the suggested workaround (splitting the dataset) unacceptable? |
It requires huge refactoring (tooltip, axis. series and so on) and maintaining two implementations. |
|
I don't think it should require huge work to refactor from dataset to not. And besides, you can try with AI to help. |
|
I think the basic requirement is reasonable. A visualMap component should be able to control multiple series, and the dimension for each series should be able to configured. But I'm afraid the current proposed API is not intuitive and seems hard to understand. For this requirement, in my opinion, the API can be designed as: option = {
visualMap: {
// Introduce a new option `target`.
// When `target` is provided, `visualMap.seriesIndex`, `visualMap.seriesId`, `visualMap.dimension`
// are ignored.
target: [{
seriesIndex: 3,
dimension: 2,
}, {
seriesId: 'xxx', // either seriesId or seriesIndex
dimension: 1,
},
...
]
}
}; |
f39fdbf to
2a234b3
Compare
VisualMap already has a |
|
The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20703@f6f7bdf |
| if (seriesTargets && zrUtil.isArray(seriesTargets)) { | ||
| each(seriesTargets, function (target) { | ||
| if (!zrUtil.isObject(target) || target.dimension == null) { | ||
| if (__DEV__) { |
There was a problem hiding this comment.
I noticed that this validation only outputs warnings during the development process. How about moving the __DEV__ check outside? - This helps reduce the distribution file size.
if (__DEV__) {
const seriesTargets = opt.seriesTargets;
if (seriesTargets && zrUtil.isArray(seriesTargets)) {
each(seriesTargets, function (target) {
if (!zrUtil.isObject(target) || target.dimension == null) {
console.warn('Each seriesTarget should have a dimension property');
}
if (target.seriesIndex == null && target.seriesId == null) {
console.warn('Each seriesTarget should have either seriesIndex or seriesId');
}
});
}
}| if (seriesTargets) { | ||
| // When seriesTargets is provided, collect all target series indices | ||
| const indices: number[] = []; | ||
| for (const target of seriesTargets) { |
There was a problem hiding this comment.
There seems to be no const of usage for the array iteration in the codebase. As the current coding style, maybe the zrUtil.each utility should be used here.
|
Congratulations! Your PR has been merged. Thanks for your contribution! 👍 |
seriesTargets option for multiple series-dimension mappings
Brief Information
This pull request is in the type of:
What does this PR do?
official demo
Fixed issues
#20662

#14346
Also fix #20347:
Details
Before: What was the problem?
Single visualMap cannot be used for 2d dataset.
After: How does it behave after the fixing?
mapping series to dimension by
seriesTargetsDocument Info
One of the following should be checked.
Misc
ZRender Changes
Related test cases or examples to use the new APIs
N.A.
Others
Merging options
Other information