Kaynağa Gözat

热力图bug 修复图形组件

liujiejie 7 ay önce
ebeveyn
işleme
b8d30f5137

+ 12 - 7
src/views/performance/components/custonAsCom/dragChart/components/chartConfig/form/chartLogic/modules/Heatmap.js

@@ -102,16 +102,22 @@ export function handleHeatmapPlotChartLogic(
     const heatmapData = [];
 
     for (let i = 0; i < yAxisData.length; i++) {
-      for (let j = 0; j < xAxisData.length; j++) {
+      for (let j = 0; j < item.Ydata.length; j++) {
+        console.log("i j", xAxisData, yAxisData, item.Ydata[j].label);
         // 对应 Ydata 中每个风机的数据,i 对应时间索引
-        const valueStr = item.Ydata[j]?.data[i]?.[item.Ydata[j].label];
-        const value =
-          valueStr !== undefined && valueStr !== "" ? Number(valueStr) : 0;
-        heatmapData.push([i, j, value]); // [yIndex, xIndex, value]
+        const xInd = xAxisData.findIndex(
+          (xval) => xval === item.Ydata[j].label
+        );
+        console.log(xInd, "xInd");
+        if (xInd !== -1) {
+          let indexVal = item.Ydata[j]?.data[i]?.[item.Ydata[j].label];
+          const value =
+            indexVal !== undefined && indexVal !== "" ? Number(indexVal) : 0;
+          heatmapData.push([xInd, i, value]); // [yIndex, xIndex, value]
+        }
       }
     }
 
-
     // 生成热力图数据
     item.option.series = [
       {
@@ -134,6 +140,5 @@ export function handleHeatmapPlotChartLogic(
         },
       },
     ];
-
   }
 }