From 68ba3376731aa7a5760ba5fce1dc6ba0c80982b4 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 03 一月 2025 17:28:18 +0800
Subject: [PATCH] 调整网格文本样式

---
 src/model/Legend.js |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/model/Legend.js b/src/model/Legend.js
index e92ebd1..9d852d1 100644
--- a/src/model/Legend.js
+++ b/src/model/Legend.js
@@ -309,24 +309,16 @@
       };
     }
 
-    // if (data == min) {
-    //   console.log(data);
-    // }
-
-    var per = (max - min) / this._custom.length;
+    // 灏嗘暟鎹寜鐓ч鑹叉暟閲忓垎闅旓紝姹傚嚭姣忎竴娈电殑鏁版嵁鍋忕Щ閲�
+    var per = (max - min) / (this._custom.length - 1);
+    // 璁$畻褰撳墠鏁版嵁鎵�鍦ㄧ殑鍒嗘鑼冨洿
     var i = parseInt((data - min) / per);
-    var range = min + i * per
-    if (i >= this._custom.length - 1) {
-      i = this._custom.length - 2;
-      range = min + i * per
-    }
+    // 濡傛灉鏄渶澶у�硷紝鍚屾牱鍒嗗壊鍒版渶鍚庝竴娈�
+    if (i == this._custom.length - 1) i--;
+    var range = min + i * per;
 
     let nextIndex = i + 1;
-    let nextRange = min + nextIndex * per
-    if (nextIndex > this._custom.length - 1) {
-      nextIndex = this._custom.length - 1;
-      nextRange = min + nextIndex * per
-    }
+    let nextRange = min + nextIndex * per;
 
     return {
       color: this._custom[i],
@@ -334,7 +326,7 @@
       range,
       nextRange
     };
-  },
+  }
 };
 
 export { Legend };

--
Gitblit v1.9.3