diff --git a/src/coord/scaleRawExtentInfo.ts b/src/coord/scaleRawExtentInfo.ts index 52f6b8d062..658c3e2e17 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 0000000000..81a04faf51 --- /dev/null +++ b/test/min-max-axis.html @@ -0,0 +1,57 @@ + + +
+ + + + + + + + + + + + + + + + + +