Explorar el Código

fix:修改地图颜色字段

wangsisi hace 1 día
padre
commit
d049fc34b0

+ 4 - 21
src/views/warningHome/components/chart_components/chartList.vue

@@ -229,28 +229,11 @@ const fetchYieldChartData = () => {
                     values,
                 };
 
-                // 找到最大和最小占比的项
-                let maxValue = 0;
-                let maxName = "";
-                let minValue = Infinity;
-                let minName = "";
-                res.data.forEach((item) => {
-                    if (item.plantArea > maxValue) {
-                        maxValue = item.plantArea;
-                        maxName = item.name;
-                    }
-                    if (item.plantArea < minValue) {
-                        minValue = item.plantArea;
-                        minName = item.name;
-                    }
+                // 生成摘要文字,显示每一项的数据
+                const summaryItems = res.data.map((item) => {
+                    return `${item.name}: ${item.plantArea.toFixed(1)}亩`;
                 });
-
-                // 更新摘要文字
-                if (maxName) {
-                    yieldSummaryText.value = `当前${maxName}的面积占有${maxValue.toFixed(1)}亩`;
-                } else {
-                    yieldSummaryText.value = "暂无数据";
-                }
+                yieldSummaryText.value = summaryItems.join(", ");
             } else {
                 // 接口返回空数据时,清空图表数据
                 yieldChartData.value = {

+ 1 - 1
src/views/warningHome/map/distributionLayer.js

@@ -266,7 +266,7 @@ class DistributionLayer {
         for (let item of data) {
             // 面数据(区域多边形)
             if (item.geom) {
-                item.color = item.speciesColor || "#2199F8";
+                item.color = item.color || "#2199F8";
                 this.distributionLayer.source.addFeature(newPolymerFeature(item));
             }
         }