feat(axis): support dataMin and dataMax option for calculating a nice axis extent#20838
feat(axis): support dataMin and dataMax option for calculating a nice axis extent#20838Ovilia merged 2 commits intoapache:masterfrom
dataMin and dataMax option for calculating a nice axis extent#20838Conversation
|
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 |
|
I’ve experienced this problem as a user so interested to see how this PR progresses, I will say the naming here is a bit confusing, especially since ECharts already supports a different concept as: |
I intentionally use the terms
|
Neither approach works in this case. |
|
@Justin-ZS Can you further explain in which case should I set max value to be some rounded value larger than my given value, instead of not setting |
When comparing multiple similar charts. (like sales data from different stores, one chart for one store) |
Ovilia
left a comment
There was a problem hiding this comment.
It should be helpful to provide a feature to nice the min/max value of the axis. Thanks for the help! However, I don't think this should be the default behavior, and this also has a compatibility problem.
For the current implementation, when dataMax is larger than the actual data max, a niced value that is no smaller than the dataMax is used; while when dataMax is smaller than the actual data max, it's not used at all. This behavior seems really confusing to me.
I would suggest using max: 'niceDataMax' instead of providing a new option, and the data max is calculated to be a nice number automatically without providing a value. Does this satisfy your requirement?
Regarding compatibility, there should be no issues. To solve the use case, we need both:
With
|
|
At first glance, I originally thought the newly introduced |
d6ea40c to
1808e50
Compare
Ovilia
left a comment
There was a problem hiding this comment.
Thanks for your contribution!
Please make sure that we explained the logic clearly in the document and give some examples for the users to understand because this concept may not be intuitive to all users at the first glance.
|
Congratulations! Your PR has been merged. Thanks for your contribution! 👍 |
dataMin and dataMax option for calculating a nice axis extent
Brief Information
This pull request is in the type of:
What does this PR do?
Add
dataMinanddataMaxproperties for value axes to extend the axis range while preserving nice scale algorithm.Fixed issues
Details
Before: What was the problem?
Currently, ECharts provides two ways to set axis range:
min/maxto set fixed values, but this disables the nice scale algorithmThere was no way to ensure a specific data point would be included in the axis range while still benefiting from the nice scale algorithm.
After: How does it behave after the fixing?
With the new
dataMin/dataMaxproperties, users can:These properties are only effective for value axes (
value,log,time) and have no effect on category axes.Document Info
One of the following should be checked.
Misc
ZRender Changes
Related test cases or examples to use the new APIs
Test cases have been included in
test/axis-data-min-max.htmlto verify different scenarios including:Others
Merging options
Other information