1
This commit is contained in:
		@@ -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),
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user