From 53ead4788283fa4178150cf543d2e34e77b20011 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Tue, 30 Jan 2024 17:00:44 +0800 Subject: [PATCH] 1 --- src/components/datapage/HourChart.vue | 43 +--- src/components/datapage/LatestWeekYield.vue | 191 +++++++++++------- .../datapage/LatestWeekYieldOptions.js | 89 ++++---- src/pages/DataPage.vue | 4 +- 4 files changed, 179 insertions(+), 148 deletions(-) diff --git a/src/components/datapage/HourChart.vue b/src/components/datapage/HourChart.vue index de16b53..d8590d8 100644 --- a/src/components/datapage/HourChart.vue +++ b/src/components/datapage/HourChart.vue @@ -9,32 +9,17 @@ const store = useWsStore(); const chartChart = ref(null); const chart = ref(null); // 小时数据 -const hourData = ref([ - // { lineName: '001', hour: '00:00', num: 10 }, - // { lineName: '002', hour: '00:20', num: 20 }, - // { lineName: '003', hour: '00:30', num: 30 }, - // { lineName: '004', hour: '00:40', num: 14 }, - // { lineName: '005', hour: '00:50', num: 50 } -]); +const hourData = ref([]); store.$subscribe((mutation, state) => { - // console.log("[HourChart] =======>", state.data2.lineHourList?.length); if ( state.data2.lineHourList == undefined || state.data2.lineHourList?.length == 0 ) { - // console.log("[HourChart] 清除数据"); hourData.value.splice(0); if (chart.value) chart.value.dispose(); return; } - // console.log("[HourChart] ===> 有数据: ", state.data2.lineHourList); - hourData.value = (state.data2?.lineHourList ?? [ - // { lineName: '001', hour: '00:00', num: 10 }, - // { lineName: '002', hour: '00:20', num: 20 }, - // { lineName: '003', hour: '00:30', num: 30 }, - // { lineName: '004', hour: '00:40', num: 14 }, - // { lineName: '005', hour: '00:50', num: 50 }, - ]).map((item, index) => ({ + hourData.value = (state.data2?.lineHourList ?? []).map((item, index) => ({ id: `${item.lineName}_${index}`, hour: item.hour || `${index}`.padStart(2, "0"), data: item.num || Math.floor(Math.random() * 100), @@ -46,29 +31,12 @@ function setupChart() { if (chart.value) chart.value.dispose(); nextTick(() => { chart.value = echarts.init(chartChart.value); - // console.log("[HourChart] ===> 设置chart: ", chart.value, hourData.value.map((item) => item.hour), hourData.value.map((item) => item.data)); chartSetup( chart.value, hourData.value.map((item) => item.hour), hourData.value.map((item) => item.data) ); }); - - // chart.value.setOption({ - // xAxis: { - // type: "category", - // data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], - // }, - // yAxis: { - // type: "value", - // }, - // series: [ - // { - // data: [150, 230, 224, 218, 135, 147, 260], - // type: "line", - // }, - // ], - // }); } onMounted(() => { @@ -78,7 +46,11 @@ onMounted(() => {