This commit is contained in:
DESKTOP-FUDKNA8\znjsz 2024-03-13 16:08:09 +08:00
parent d56efd1c2f
commit f9fc8e8c66
2 changed files with 4 additions and 8 deletions

View File

@ -17,17 +17,14 @@ const hourData = ref([
// { lineName: "005", hour: "00:50", num: 50 },
]);
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 },
@ -36,8 +33,8 @@ store.$subscribe((mutation, state) => {
// { lineName: '005', hour: '00:50', num: 50 },
]).map((item, index) => ({
id: `${item.lineName}_${index}`,
hour: item.hour || `${index}`.padStart(2, "0"),
data: item.num || Math.floor(Math.random() * 100),
hour: item.hour || '__',
data: item.num || 0,
}));
setupChart();
});
@ -46,7 +43,6 @@ 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),

View File

@ -30,8 +30,8 @@ store.$subscribe((mutation, state) => {
}
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),
hour: item.hour || `__`,
data: item.num || 0,
}));
setupChart();
});