fix(axis): allow stacking on value xAxis #19653
Open
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?
On cartesian charts when both X and Y axes have type
value
the stack dimension is selected incorrectly which leads to broken stacked charts. This PR prevents X-axis coord dimension when Y-axis coord dimension is also stackable which allows having stacked vertical charts while not changing the API.Further, to properly support stacked horizontal charts with both stackable axes, the API should be extended.
Minimal reproduction
ECharts supports stacking on the other continuous scale
time
so it would make sense to support it forvalue
as well. Multiple created issues requesting the feature validate the needs of the community.Why not to approximate it with the
category
scale?Approximating continuous
value
scale withcategory
one is not a great option because there is limitless set of sparse datasets which require adding many fake values to make the scale look continuous which affects performance. At the same time, the added fake empty values will be no distinguishable with real empty values coming from the dataset. This affectsconnectNulls
option. Finally, besides the inability to provide the same functionality and experience with the approximation, it also disproportionately complicates the client code: find gcd of each interval, consider number of intervals per pixel, handle x-axis ticks so it shows only "nice" values, etc.Fixed issues
Details
Before: What was the problem?
Stacking did not work on
value
xAxis. There are two stacked bar series on this screenshot:After: How does it behave after the fixing?
Stacking works correctly on
value
xAxis:Document 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
If I understand the code correctly, existing API of ECharts does not let explicitly define whether a 2d cartesian chart is vertical or horizontal. It is decided based on X and Y axes types: if X-axis is ordinal or time, then it is a vertical chart but if Y-axis is one of these types then it is a horizontal chart. This leads to the undefined behavior when both X and Y axes have value type and there should be an option to set it explicitly for such cases. This PR strives to provide a minimalistic fix without changing API and breaking any existing defined behavior. It follows already existing logic of giving preference to X-axis dimension as the one to be stacked on dimension.