From 87e19b5a396ac8fed6a551828b87d263f6425c31 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 16 十月 2025 10:26:12 +0800
Subject: [PATCH] 2025.10.16 修改季度报告生成逻辑
---
src/model/Legend.js | 106 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 84 insertions(+), 22 deletions(-)
diff --git a/src/model/Legend.js b/src/model/Legend.js
index 9dfbcc4..1492cbf 100644
--- a/src/model/Legend.js
+++ b/src/model/Legend.js
@@ -10,7 +10,7 @@
_legend_r: {
NO: [0, 100, 200, 700, 1200, 2340],
NO2: [0, 100, 200, 700, 1200, 2340],
- CO: [0, 5, 10, 35, 60, 90],
+ CO: [0, 5000, 10000, 35000, 60000, 90000],
H2S: [0, 150, 500, 650, 800, 1600],
SO2: [0, 150, 500, 650, 800, 1600],
O3: [0, 160, 200, 300, 400, 800],
@@ -142,21 +142,13 @@
]
},
- // _custom: [
- // [0.05, 0.9, 0.03, 0.75],
- // [0.3, 0.65, 0.02, 0.75],
- // [0.87, 0.92, 0.03, 0.75],
- // [0.8, 0.67, 0.04, 0.75],
- // [0.92, 0.28, 0.07, 0.75],
- // [0.6, 0.05, 0.05, 0.75]
- // ],
_custom: [
- [0, 0.89, 0, 0.75],
- [1, 1, 0, 0.75],
- [1, 0.49, 0, 0.75],
- [1, 0, 0, 0.75],
- [0.6, 0, 0.3, 0.75],
- [0.49, 0, 0.14, 0.75]
+ [0.05, 0.9, 0.03, 0.75],
+ [0.3, 0.65, 0.02, 0.75],
+ [0.87, 0.92, 0.03, 0.75],
+ [0.8, 0.67, 0.04, 0.75],
+ [0.92, 0.28, 0.07, 0.75],
+ [0.96, 0.05, 0.05, 0.75]
],
getStandardRange: function (name) {
@@ -172,15 +164,14 @@
// }
// max = parseInt(key)
// }
- if (name == 'CO') {
- min *= 1000;
- max *= 1000;
- }
return [min, max];
},
getColor: function (name, type, data, min, max) {
+ if (!data) {
+ return [0, 0, 0, 0];
+ }
if (type == this.S_TYPE) {
return this.getStandardColor(name, data);
} else {
@@ -228,9 +219,6 @@
for (let i = 0; i < range.length; i++) {
const d = range[i];
let d1 = d;
- if (name == 'CO') {
- d1 *= 1000;
- }
if (data >= d1) {
selected = i;
} else {
@@ -247,6 +235,51 @@
return colors[selected];
},
+ getStandardColorAndNext: function (name, data) {
+ if (!data) {
+ return {
+ color: [0, 0, 0, 0],
+ nextColor: [0, 0, 0, 0],
+ range: 0,
+ nextRange: 0
+ };
+ }
+ let range = this._legend_r[name];
+ let colors = this._legend_c[name];
+ if (range == undefined) {
+ range = this._legend_r['PM25'];
+ colors = this._legend_c['PM25'];
+ }
+
+ let selected = undefined;
+ for (let i = 0; i < range.length; i++) {
+ const d = range[i];
+ let d1 = d;
+ if (data >= d1) {
+ selected = i;
+ } else {
+ break;
+ }
+ }
+
+ // 閬垮厤涓嬫爣瓒婄晫
+ if (selected >= colors.length) {
+ selected = colors.length - 1;
+ }
+
+ let nextIndex = selected + 1;
+ if (nextIndex >= colors.length) {
+ nextIndex = colors.length - 1;
+ }
+
+ return {
+ color: colors[selected],
+ nextColor: colors[nextIndex],
+ range: range[selected],
+ nextRange: range[nextIndex]
+ };
+ },
+
getCustomColor: function (data, min, max) {
var per = (max - min) / this._custom.length;
var i = parseInt((data - min) / per);
@@ -254,6 +287,35 @@
i = this._custom.length - 1;
}
return this._custom[i];
+ },
+
+ getCustomColorAndNext: function (data, min, max) {
+ if (!data) {
+ return {
+ color: [0, 0, 0, 0],
+ nextColor: [0, 0, 0, 0],
+ range: 0,
+ nextRange: 0
+ };
+ }
+
+ // 灏嗘暟鎹寜鐓ч鑹叉暟閲忓垎闅旓紝姹傚嚭姣忎竴娈电殑鏁版嵁鍋忕Щ閲�
+ var per = (max - min) / (this._custom.length - 1);
+ // 璁$畻褰撳墠鏁版嵁鎵�鍦ㄧ殑鍒嗘鑼冨洿
+ var i = parseInt((data - min) / per);
+ // 濡傛灉鏄渶澶у�硷紝鍚屾牱鍒嗗壊鍒版渶鍚庝竴娈�
+ if (i == this._custom.length - 1) i--;
+ var range = min + i * per;
+
+ let nextIndex = i + 1;
+ let nextRange = min + nextIndex * per;
+
+ return {
+ color: this._custom[i],
+ nextColor: this._custom[nextIndex],
+ range,
+ nextRange
+ };
}
};
--
Gitblit v1.9.3