Browse Source

柱状图加单位

Bella 2 năm trước cách đây
mục cha
commit
8096fbe1d0
1 tập tin đã thay đổi với 11 bổ sung0 xóa
  1. 11 0
      src/components/chart/BarChart.vue

+ 11 - 0
src/components/chart/BarChart.vue

@@ -39,6 +39,10 @@ export default {
       type: String,
       default: "A",
     },
+    unit: {
+      type: String,
+      default: "公顷",
+    },
   },
   mounted() {
     this.initEchart(
@@ -71,6 +75,13 @@ export default {
             // Use axis to trigger tooltip
             type: "shadow", // 'shadow' as default; can also be 'line' or 'shadow'
           },
+          formatter: function (params) {
+            let relVal = params[0].name;
+            for (let i = 0; i < params.length; i++) {
+              relVal += `<br/>${params[i].marker}${params[i].value}公顷`;
+            }
+            return relVal;
+          },
         },
         legend: {
           bottom: "0%",