You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2022/09/06 09:43:55 UTC

[echarts] 01/01: fix(bar): fix bar axis range when maximum data is small #13128

This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch fix-13128
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit e8bfbd35817b71b2db28bd05d34e96debec5beb3
Author: Ovilia <zw...@gmail.com>
AuthorDate: Tue Sep 6 17:42:43 2022 +0800

    fix(bar): fix bar axis range when maximum data is small #13128
---
 src/util/number.ts | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/util/number.ts b/src/util/number.ts
index bf5b2562f..47c574ba6 100644
--- a/src/util/number.ts
+++ b/src/util/number.ts
@@ -138,10 +138,12 @@ export function round(x: number | string, precision: number, returnStr: false):
 export function round(x: number | string, precision: number, returnStr: true): string;
 export function round(x: number | string, precision?: number, returnStr?: boolean): string | number {
     if (precision == null) {
-        precision = 10;
+        precision = ROUND_SUPPORTED_PRECISION_MAX;
+    }
+    else {
+        // Avoid range error
+        precision = Math.min(Math.max(0, precision), ROUND_SUPPORTED_PRECISION_MAX);
     }
-    // Avoid range error
-    precision = Math.min(Math.max(0, precision), ROUND_SUPPORTED_PRECISION_MAX);
     // PENDING: 1.005.toFixed(2) is '1.00' rather than '1.01'
     x = (+x).toFixed(precision);
     return (returnStr ? x : +x);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org