Skip to content

Commit

Permalink
fixed issue #19187
Browse files Browse the repository at this point in the history
  • Loading branch information
mertokten committed Dec 13, 2023
1 parent 5b0c096 commit 41401b2
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 6 deletions.
14 changes: 8 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This pull request is in the type of:

- [ ] bug fixing
- [X] bug fixing
- [ ] new feature
- [ ] others

Expand All @@ -13,39 +13,41 @@ This pull request is in the type of:
### What does this PR do?

<!-- USE ONE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->

It fixes the bug occuring in test/min-max-axis.html test case.


### Fixed issues

<!--
- #xxxx: ...
-->

- [#19187](https://github.com/apache/echarts/issues/19187)

## Details

### Before: What was the problem?

<!-- DESCRIBE THE BUG OR REQUIREMENT HERE. -->

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.
<!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
<img width="822" alt="Screenshot 2023-12-08 at 11 45 55 AM" src="https://github.com/mertokten/ECE444-F2023-Assignment1/assets/31061207/0cc7491b-e72d-4caa-860a-33f9f0a17ab1">



### After: How does it behave after the fixing?

<!-- THE RESULT AFTER FIXING AND A SIMPLE EXPLANATION ABOUT HOW IT IS FIXED. -->

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.
<!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
<img width="803" alt="Screenshot 2023-12-08 at 11 48 04 AM" src="https://github.com/mertokten/ECE444-F2023-Assignment1/assets/31061207/807dc5bd-3640-4dfb-b313-705ecab4108c">



## Document Info

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

Expand Down
14 changes: 14 additions & 0 deletions src/coord/scaleRawExtentInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
57 changes: 57 additions & 0 deletions test/min-max-axis.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 41401b2

Please sign in to comment.