From e1e73b341d4c5ec5b5b094ed37bc6dc846cd1eeb Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 4 Jan 2024 16:44:15 +0800 Subject: [PATCH] update --- src/components/Common/TodayFaultType/index.jsx | 6 ++++-- .../EnergyCostAnalysis/ElectricityCost/index.jsx | 5 ++++- src/utils/energeChartOption.js | 16 ++++++++++------ src/utils/index.ts | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/Common/TodayFaultType/index.jsx b/src/components/Common/TodayFaultType/index.jsx index bf6bc4a..47e4d33 100644 --- a/src/components/Common/TodayFaultType/index.jsx +++ b/src/components/Common/TodayFaultType/index.jsx @@ -145,7 +145,7 @@ function getOptions(data, chart_type) { axisPointer: { type: "shadow", }, - className: 'xc-chart-tooltip' + className: "xc-chart-tooltip", // backgroundColor: '' }, xAxis: { @@ -207,7 +207,9 @@ function getOptions(data, chart_type) { fontSize: 10, color: "#fffc", }, - data: (dataList || []).map((item) => item.value), + data: (dataList || []).map((item) => + item.value == null || isNaN(+item.value) ? null : (+item.value).toFixed(2) + ), }, ], }; diff --git a/src/components/Modules/EnergyCostAnalysis/ElectricityCost/index.jsx b/src/components/Modules/EnergyCostAnalysis/ElectricityCost/index.jsx index 386f15a..1bacf6c 100644 --- a/src/components/Modules/EnergyCostAnalysis/ElectricityCost/index.jsx +++ b/src/components/Modules/EnergyCostAnalysis/ElectricityCost/index.jsx @@ -147,7 +147,10 @@ function getOptions(period, trend) { }, }, series: { - data: trend[period].map((item) => item.qty), + // !(item.value == null || isNaN(+item.value)) ? (+item.value).toFixed(2) : null + data: trend[period].map((item) => + item.qty == null || isNaN(+item.qty) ? null : (+item.qty).toFixed(2) + ), type: "line", symbol: "circle", symbolSize: 6, diff --git a/src/utils/energeChartOption.js b/src/utils/energeChartOption.js index e60a59d..c460fb6 100644 --- a/src/utils/energeChartOption.js +++ b/src/utils/energeChartOption.js @@ -4,7 +4,7 @@ export function lunarYear(year) { return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0); } -export function getOptions(period, source, trend, options={}) { +export function getOptions(period, source, trend, options = {}) { if (trend[period].length == 0) return null; const today = new Date(); const currentYear = today.getFullYear(); @@ -40,7 +40,7 @@ export function getOptions(period, source, trend, options={}) { .fill(1) .map((_, index) => { if (period == "week") { - const dtimestamp = today - (index+1) * 24 * 60 * 60 * 1000; + const dtimestamp = today - (index + 1) * 24 * 60 * 60 * 1000; return `${new Date(dtimestamp).getMonth() + 1}.${new Date( dtimestamp ).getDate()}`; @@ -65,7 +65,7 @@ export function getOptions(period, source, trend, options={}) { }, }, yAxis: { - name: source == 'elec' ? '单位/kWh' : "单位/Nm³", + name: source == "elec" ? "单位/kWh" : "单位/Nm³", nameTextStyle: { color: "#fff", fontSize: 10, @@ -96,10 +96,14 @@ export function getOptions(period, source, trend, options={}) { { data: source == "elec" - ? trend[period].map((item) => item.qty) + ? trend[period].map((item) => + item.qty == null || isNaN(+item.qty) + ? null + : (+item.qty).toFixed(2) + ) : trend[period], type: "line", - symbol: 'circle', + symbol: "circle", symbolSize: 6, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ @@ -119,6 +123,6 @@ export function getOptions(period, source, trend, options={}) { className: "xc-chart-tooltip", // backgroundColor: '' }, - ...options + ...options, }; } diff --git a/src/utils/index.ts b/src/utils/index.ts index ee986d2..c8c0f44 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -124,8 +124,8 @@ new XClient( new XClient( { url: "ws://10.70.2.2:8080/websocket/message?userId=ENERGY" + newUser, + // url: "ws://192.168.1.74:48080/websocket/message?userId=ENERGY" + newUser, name: "MES_DATA", - // "ws://192.168.1.74:48080/websocket/message?userId=ENERGY" + newUser, // "ws://192.168.1.74:48080/websocket/message?userId=ENERGY111", }, energeHandler