fix(bar): fix bar axis range when maximum data is small #13128
Brief Information
This pull request is in the type of:
- [x] bug fixing
- [ ] new feature
- [ ] others
What does this PR do?
When the max value of bar series is small enough (less than 1e^-10), the bar series is not displayed because the calculated axis extent is 0.
Fixed issues
#13128
Details
Before: What was the problem?
Bar series is not displayed.
After: How does it behave after the fixing?
Bar series is displayed and the axis extent is correct.
Document Info
One of the following should be checked.
- [x] This PR doesn't relate to document changes
- [ ] The document should be updated later
- [ ] The document changes have been made in apache/echarts-doc#xxx
Misc
ZRender Changes
- [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
Related test cases or examples to use the new APIs
N.A.
Others
Merging options
- [ ] Please squash the commits into a single one when merging.
Other information
ROUND_SUPPORTED_PRECISION_MAX is set to be 20, which means if the max data is less than 1e-20, we still have similar problems. But this PR is meaningful because when precision is not provided, we should not use 10 for default because this introduces another new concept and causes further confusions. Instead, we should use 20 to make the precision logic constant.
Thanks for your contribution! The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.
The pull request is marked to be PR: author is committer because you are a committer of this project.
(0.1 + 0.2).toFixed(ROUND_SUPPORTED_PRECISION_MAX) can't fix the rounding error.
@pissang
PlanA: If 0.30000000000000004 should be considered as 0.3, should 1e-11 be considered as 0, which makes the original issue not-a-bug?
PlanB: If a number is less than 1e-10, then the precision should be considered using ROUND_SUPPORTED_PRECISION_MAX, otherwise, 1e-10 is used.
Should we also provide an option on echarts.init to overrider ROUND_SUPPORTED_PRECISION_MAX?
@Ovilia In some of the echarts code we use the precision from the input data. For example. if input data is 0.1 and 0.3. Then the precision should be 1. If input data is 1e-11, then the precision is 11
@pissang But if the input data is 0.1 + 0.2, using 0.30000000000000004 as precision is not as expected, right?