Pārlūkot izejas kodu

时间戳转换格式修改

LiuShu_0203 5 mēneši atpakaļ
vecāks
revīzija
634327a6a5
1 mainītis faili ar 10 papildinājumiem un 5 dzēšanām
  1. 10 5
      src/App.vue

+ 10 - 5
src/App.vue

@@ -493,12 +493,18 @@ const progressbars = (datas: any) => {
         console.error('Invalid datas object or warnEchars is missing:', datas);
         return;
     }
-
+    // 打印原始时间戳数组
+    console.log(datas.warnEchars.echarsTime, '原始时间戳数组');
+    const time = [];
     // 将时间戳数组转换为格式化的日期时间字符串数组
-    const formattedTimeArray = datas.warnEchars.echarsTime.map((item: any) => {
-        moment(item).format('YYYY-MM-DD HH:mm:ss.SSS');
+    datas.warnEchars.echarsTime.forEach((item: any) => {
+        const formattedTimeArray = parseInt(item);
+        time.push(moment(formattedTimeArray).format('YYYY-MM-DD HH:mm:ss'));
     });
 
+    // 打印转换后的时间字符串数组
+    console.log(time, '格式化后的时间字符串数组');
+
     const chartElement = document.getElementById('chartstow');
 
     if (chartElement) {
@@ -521,7 +527,7 @@ const progressbars = (datas: any) => {
                 axisLabel: {
                     color: '#fff' // X轴字体颜色
                 },
-                data: formattedTimeArray.value
+                data: time
             },
             yAxis: {
                 x: 'center',
@@ -817,7 +823,6 @@ const handleMqttMessage = (topic: string, message: any) => {
     } else {
         try {
             const data = JSON.parse(message.toString());
-            console.log(topic, data);
             coalgasData.value = data.top;
             thawData.value = data.buttom.map((buttomItem: any) => {
                 // 处理 middleVo