diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 1f02a0e753a..4834f224190 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,7 +4,7 @@ This pull request is in the type of: -- [ ] bug fixing +- [X] bug fixing - [ ] new feature - [ ] others @@ -13,7 +13,7 @@ This pull request is in the type of: ### What does this PR do? - +It fixes the bug occuring in test/min-max-axis.html test case. ### Fixed issues @@ -21,23 +21,25 @@ This pull request is in the type of: - +- [#19187](https://github.com/apache/echarts/issues/19187) ## Details ### Before: What was the problem? - +The bar-chart ignores the yAxis.min setting and instead seems to use the auto-calculated value. In min-max-axis.html test case as you can see, the max is not set so it fails auto-calculating the axis labels. + ### After: How does it behave after the fixing? - +The yAxis minimum value should be as specified. (yAxis min is set 5 in our case). It was fixed by when either one is fixed and the other is not,by making sure that the min is always smaller than the max and also the vice versa. Finally after adjusting the min and max we set the minFixed or maxFixed to true so that it won't auto calculate a wrong axis label. + @@ -45,7 +47,7 @@ This pull request is in the type of: One of the following should be checked. -- [ ] This PR doesn't relate to document changes +- [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 diff --git a/src/coord/scaleRawExtentInfo.ts b/src/coord/scaleRawExtentInfo.ts index 52f6b8d062e..658c3e2e172 100644 --- a/src/coord/scaleRawExtentInfo.ts +++ b/src/coord/scaleRawExtentInfo.ts @@ -234,6 +234,20 @@ export class ScaleRawExtentInfo { maxFixed = true; } + // Use this where only one of the min or max is fixed and the other not. + // You can see the usage of this when testing min-max-axis.html that I created as a test case. + // (https://github.com/apache/echarts/issues/19187) + if ((!maxFixed && minFixed) || (!minFixed && maxFixed)) { + if (min > max) { + max = min + 10; + maxFixed = true; + } + else if (max < min) { + min = max - 10; + minFixed = true; + } + } + // Ensure min/max be finite number or NaN here. (not to be null/undefined) // `NaN` means min/max axis is blank. return { diff --git a/test/min-max-axis.html b/test/min-max-axis.html new file mode 100644 index 00000000000..81a04faf516 --- /dev/null +++ b/test/min-max-axis.html @@ -0,0 +1,57 @@ + + +
+ + + + + + + + + + + + + + + + + +