AaronBruin 1 tháng trước cách đây
mục cha
commit
06275fb487
1 tập tin đã thay đổi với 17 bổ sung3 xóa
  1. 17 3
      src/views/index/curve.vue

+ 17 - 3
src/views/index/curve.vue

@@ -40,7 +40,7 @@ const handleResize = () => {
 onMounted(() => {
     initChart();
 });
-const initChart = (dates, EPE, typeName) => {
+const initChart = (dates, EPE, typeName, unitType) => {
     if (chartRef.value) {
         chart = echarts.init(chartRef.value);
         // 生成 24 小时的时间数据
@@ -73,7 +73,7 @@ const initChart = (dates, EPE, typeName) => {
                 formatter: function (params) {
                     let result = params[0].axisValue + '<br/>';
                     params.forEach(item => {
-                        result += item.marker + item.seriesName + ':' + item.data + ' m3<br/>';
+                        result += item.marker + item.seriesName + ':' + item.data + `${unitType}<br/>`;
                     });
                     return result;
                 }
@@ -151,19 +151,24 @@ const getChartData = (electricityCount) => {
 };
 watch(() => props.resultData, (newVal) => {
     let typeName = ''
+    let unitType = ''
     if (props.curveType === 'temperature') {
         typeName = '温度'
+        unitType = '℃'
     } else if (props.curveType === 'humidity') {
         typeName = '湿度'
+        unitType = '%RH'
     } else if (props.curveType === 'pressure') {
         typeName = '压力'
+        unitType = 'MPa'
     } else if (props.curveType === 'total_flow') {
         typeName = '流量'
+        unitType = 'm³'
     }
     const { dates, EPE, EPE_forecast } = getChartData(newVal);
     if (newVal && chart == null) {
         nextTick(() => {
-            initChart(dates, EPE, typeName);
+            initChart(dates, EPE, typeName, unitType);
         });
     }
     if (chart) {
@@ -171,6 +176,15 @@ watch(() => props.resultData, (newVal) => {
             xAxis: {
                 data: dates,
             },
+            tooltip: {
+                formatter: function (params) {
+                    let result = params[0].axisValue + '<br/>';
+                    params.forEach(item => {
+                        result += item.marker + item.seriesName + ':' + item.data + `${unitType} <br/>`;
+                    });
+                    return result;
+                }
+            },
             series: [{
                 name: typeName,
                 type: 'line',