Jelajahi Sumber

双碳图表修改

tianyabing 2 tahun lalu
induk
melakukan
8357d0566c

+ 20 - 6
src/components/common/query.vue

@@ -72,7 +72,21 @@ export default {
         this.updateFormData(val);
       },
       deep: true
-    }
+    },
+    floorOptions: {
+      handler: function(val) {
+        this.floorData = val;
+        this.$forceUpdate()
+      },
+      deep: true
+    },
+    companyOptions: {
+      handler: function(val) {
+        this.companyData = val;
+        this.$forceUpdate()
+      },
+      deep: true
+    },
   },
   data() {
     return {
@@ -87,13 +101,13 @@ export default {
       formData: {},
       // 单位数据
       companyData: [
-        //{
-        //  label: '中讯邮电咨询设计院',
-        //  value: '1'
-        //},
+        {
+          label: '全部',
+          value: '0'
+        },
         {
           label: "北京电信规划院",
-          value: "0"
+          value: "1"
         }
         //{
         //  label: '上分',

+ 65 - 127
src/components/doubleCarbon/PV/charts/carbonPvEmissionChart.vue

@@ -1,32 +1,40 @@
 <script>
-import apiCarbonPrint from "@/api/carbon/apiCarbonPrint";
+import apiCarbonOverview from "@/api/carbon/apiCarbonOverview";
+import apiCarbonCar from "@/api/carbon/apiCarbonCar";
 import apiCarbonPv from "@/api/carbon/apiCarbonPv";
 
 export default {
   data() {
     return {
+      seriesData: {
+        name: '',
+        data: [],
+        type: 'line',
+        smooth: true,
+        showSymbol:false,
+        symbolSize: 1,
+        lineStyle: {
+          width: 1,
+        },
+        emphasis: {
+          scale:1.5
+        }
+      },
+      show: false,
       option: {
         legend: {
           data: [
-            '中迅',
-            '北京规划院',
-            '郑分',
-            '广分',
-            '上分',
-            '成分',
+
           ],
           selected: {
-            '中迅': false,
-            '北京规划院': true,
-            '郑分': false,
-            '广分': false,
-            '上分': false,
-            '成分': false,
-          }
+
+          },
+          type: "scroll",
+          width: '80%'
         },
         grid: {
           left: '0%', //默认10%
-          right: '1%', //默认10%
+          right: '20px', //默认10%
           bottom: '20px', //默认60
           top: '60px',
           containLabel: true
@@ -37,10 +45,10 @@ export default {
         },
         yAxis: [
           {
-            name: '排放量',
+            name: '排放量(tCO2e)',
             type: 'value',
             nameTextStyle: {
-              padding: [10, 0, 10, -12]
+              padding: [0, 0, 0, 50]
             },
           },
         ],
@@ -63,125 +71,22 @@ export default {
           },
           backgroundColor: 'rgba(0,0,0,0.8)',
         },
-        series: [
-          {
-            name: '中迅',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            symbolSize: 6,
-            lineStyle: {
-              color: "#FDB65B",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FDB65B"
-            },
-            emphasis: {
-              scale:1.5
-            }
-          },
-          {
-            name: '北京规划院',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#62CC97",
-              width: 3,
-            },
-            itemStyle: {
-              color: "#62CC97"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '郑分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4D94FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4D94FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '广分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4DF5FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4DF5FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '上分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#FF6E4D",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FF6E4D"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '成分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#8B4DFF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#8B4DFF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          }
-        ]
+        series: []
       },
     }
   },
   props: {
     height: Number,
-    queryData: Object
+    queryData: Object,
+    callBackCompanyOption: Function,
   },
   mounted() {
     this.$nextTick(()=>{
-      this.initChart();
+      this.init();
     })
   },
   methods: {
-    initChart() {
+    init() {
       let chart = this.$echarts.init(this.$refs.myChart)
       this.chart = chart;
       this.$util.chartsResize(this.chart);
@@ -190,7 +95,40 @@ export default {
     },
     getData() {
       return apiCarbonPv.getPhotovoltaicInfo(this.queryData).then(res=>{
-        let data = this.$util.dataUtil.covertDataToEcharts(res, ['zhongxun','guihuayuanBJ','zhengfen','guangfen','shangfen','chengfen'])
+        let names = [];
+        if (res.length>0) {
+          let obj = res[0].jsonObject;
+          for (const objKey in obj) {
+            names.push(objKey);
+          }
+        }
+        this.option.legend.data = names;
+        let series = [];
+        let selected = {};
+        let comoptions = [];
+        for (let i = 0; i < names.length; i++) {
+          let obj = JSON.parse(JSON.stringify(this.seriesData));
+          obj.name = names[i];
+          series.push(obj);
+
+          let opt = {
+            label: names[i],
+            value: i+1,
+          }
+          comoptions.push(opt)
+          selected[names[i]+''] = false;
+        }
+        if (this.queryData.companyId != '0') {
+          let name = names[Number(this.queryData.companyId)-1];
+          selected[name] = true;
+        } else {
+          let name = names[0];
+          selected[name] = true;
+        }
+        this.option.legend.selected = selected;
+        this.callBackCompanyOption(comoptions)
+        this.option.series = series;
+        let data = this.$util.dataUtil.covertDataToEcharts(res, names)
         this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
       })
     }
@@ -199,7 +137,7 @@ export default {
 </script>
 
 <template>
-  <div id="personTrendChart" style="width: 100%" :style="{height: height+'px'}" ref="myChart" ></div>
+  <div class="myChart" style="width: 100%" :style="{height: height+'px'}" ref="myChart" ></div>
 </template>
 
 <style lang="less" scoped>

+ 8 - 0
src/components/doubleCarbon/PV/charts/carbonPvQuotaChart.vue

@@ -102,6 +102,14 @@ export default {
     },
     getData() {
       return apiCarbonPv.getPhotovoltaicInfoOrder(this.queryData).then(res=>{
+        if (res) {
+          res.sort((a,b)=>{
+            if (a.jsonObject.Photovoltaic>b.jsonObject.Photovoltaic) {
+              return 1;
+            }
+            return -1;
+          })
+        }
         let data = this.$util.dataUtil.covertDataToEcharts(res, ['Photovoltaic'])
         this.option.yAxis.data = data.label;
         let arr = [];

+ 22 - 0
src/components/doubleCarbon/PV/doubleCarbonPv.vue

@@ -21,6 +21,12 @@ export default {
         companyId: "0",
         timeRange: this.$util.dateUtil.getNearlyMonthRange(),
       },
+      companyOptions: [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ],
       coreData: [
         {
           title: "光伏累计减排(tco2e/年内)",
@@ -91,6 +97,20 @@ export default {
         this.coreData[4].content = res.worthAttention;
       });
     },
+    callBackCompanyOption(options) {
+      this.companyOptions = [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ]
+      if (options) {
+        options.forEach(item=>{
+          this.companyOptions.push(item);
+        })
+      }
+      this.$forceUpdate()
+    },
   },
 };
 </script>
@@ -114,6 +134,7 @@ export default {
               :query-data.sync="queryData"
               :reset="reset"
               :search="search"
+              :company-options="companyOptions"
             ></Query>
           </div>
         </a-col>
@@ -136,6 +157,7 @@ export default {
                 <CarbonPvEmissionChart
                   ref="CarbonPvEmissionChart"
                   :query-data="queryData"
+                  :callBackCompanyOption="callBackCompanyOption"
                   :height="450"
                 />
               </div>

+ 64 - 126
src/components/doubleCarbon/car/charts/carbonCarEmissionChart.vue

@@ -1,31 +1,39 @@
 <script>
+import apiCarbonOverview from "@/api/carbon/apiCarbonOverview";
 import apiCarbonCar from "@/api/carbon/apiCarbonCar";
 
 export default {
   data() {
     return {
+      seriesData: {
+        name: '',
+        data: [],
+        type: 'line',
+        smooth: true,
+        showSymbol:false,
+        symbolSize: 1,
+        lineStyle: {
+          width: 1,
+        },
+        emphasis: {
+          scale:1.5
+        }
+      },
+      show: false,
       option: {
         legend: {
           data: [
-            '中迅',
-            '北京规划院',
-            '郑分',
-            '广分',
-            '上分',
-            '成分',
+
           ],
           selected: {
-            '中迅': false,
-            '北京规划院': true,
-            '郑分': false,
-            '广分': false,
-            '上分': false,
-            '成分': false,
-          }
+
+          },
+          type: "scroll",
+          width: '80%'
         },
         grid: {
           left: '0%', //默认10%
-          right: '1%', //默认10%
+          right: '20px', //默认10%
           bottom: '20px', //默认60
           top: '60px',
           containLabel: true
@@ -36,10 +44,10 @@ export default {
         },
         yAxis: [
           {
-            name: '排放量',
+            name: '排放量(tCO2e)',
             type: 'value',
             nameTextStyle: {
-              padding: [10, 0, 10, -12]
+              padding: [0, 0, 0, 50]
             },
           },
         ],
@@ -62,125 +70,22 @@ export default {
           },
           backgroundColor: 'rgba(0,0,0,0.8)',
         },
-        series: [
-          {
-            name: '中迅',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            symbolSize: 6,
-            lineStyle: {
-              color: "#FDB65B",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FDB65B"
-            },
-            emphasis: {
-              scale:1.5
-            }
-          },
-          {
-            name: '北京规划院',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#62CC97",
-              width: 3,
-            },
-            itemStyle: {
-              color: "#62CC97"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '郑分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4D94FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4D94FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '广分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4DF5FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4DF5FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '上分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#FF6E4D",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FF6E4D"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '成分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#8B4DFF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#8B4DFF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          }
-        ]
+        series: []
       },
     }
   },
   props: {
     height: Number,
-    queryData: Object
+    queryData: Object,
+    callBackCompanyOption: Function,
   },
   mounted() {
     this.$nextTick(()=>{
-      this.initChart();
+      this.init();
     })
   },
   methods: {
-    initChart() {
+    init() {
       let chart = this.$echarts.init(this.$refs.myChart)
       this.chart = chart;
       this.$util.chartsResize(this.chart);
@@ -189,7 +94,40 @@ export default {
     },
     getData() {
       return apiCarbonCar.getVehicleInfo(this.queryData).then(res=>{
-        let data = this.$util.dataUtil.covertDataToEcharts(res, ['zhongxun','guihuayuanBJ','zhengfen','guangfen','shangfen','chengfen'])
+        let names = [];
+        if (res.length>0) {
+          let obj = res[0].jsonObject;
+          for (const objKey in obj) {
+            names.push(objKey);
+          }
+        }
+        this.option.legend.data = names;
+        let series = [];
+        let selected = {};
+        let comoptions = [];
+        for (let i = 0; i < names.length; i++) {
+          let obj = JSON.parse(JSON.stringify(this.seriesData));
+          obj.name = names[i];
+          series.push(obj);
+
+          let opt = {
+            label: names[i],
+            value: i+1,
+          }
+          comoptions.push(opt)
+          selected[names[i]+''] = false;
+        }
+        if (this.queryData.companyId != '0') {
+          let name = names[Number(this.queryData.companyId)-1];
+          selected[name] = true;
+        } else {
+          let name = names[0];
+          selected[name] = true;
+        }
+        this.option.legend.selected = selected;
+        this.callBackCompanyOption(comoptions)
+        this.option.series = series;
+        let data = this.$util.dataUtil.covertDataToEcharts(res, names)
         this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
       })
     }
@@ -198,7 +136,7 @@ export default {
 </script>
 
 <template>
-  <div id="personTrendChart" style="width: 100%" :style="{height: height+'px'}" ref="myChart" ></div>
+  <div class="myChart" style="width: 100%" :style="{height: height+'px'}" ref="myChart" ></div>
 </template>
 
 <style lang="less" scoped>

+ 8 - 0
src/components/doubleCarbon/car/charts/carbonCarQuotaChart.vue

@@ -101,6 +101,14 @@ export default {
     },
     getData() {
       return apiCarbonCar.getVehicleInfoOrder(this.queryData).then(res=>{
+        if (res) {
+          res.sort((a,b)=>{
+            if (a.jsonObject.Vehicle>b.jsonObject.Vehicle) {
+              return 1;
+            }
+            return -1;
+          })
+        }
         let data = this.$util.dataUtil.covertDataToEcharts(res, ['Vehicle'])
         this.option.yAxis.data = data.label;
         let arr = [];

+ 23 - 3
src/components/doubleCarbon/car/doubleCarbonCar.vue

@@ -21,6 +21,12 @@ export default {
         companyId: '0',
         timeRange: this.$util.dateUtil.getNearlyMonthRange()
       },
+      companyOptions: [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ],
       coreData: [
         {
           title: '车辆总里程(km/天)',
@@ -91,7 +97,21 @@ export default {
         this.coreData[3].historyNum = res.list[3].compare
         this.coreData[4].content = res.worthAttention
       })
-    }
+    },
+    callBackCompanyOption(options) {
+      this.companyOptions = [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ]
+      if (options) {
+        options.forEach(item=>{
+          this.companyOptions.push(item);
+        })
+      }
+      this.$forceUpdate()
+    },
   }
 }
 </script>
@@ -109,7 +129,7 @@ export default {
             margin-bottom: 10px;
           ">
           <div style="width: 100%">
-            <Query :show="['company', 'time']" :query-data.sync="queryData" :reset="reset" :search="search"></Query>
+            <Query :show="['company', 'time']" :query-data.sync="queryData" :company-options="companyOptions" :reset="reset" :search="search"></Query>
           </div>
         </a-col>
         <a-col>
@@ -128,7 +148,7 @@ export default {
           <div class="ioc-card-content">
             <Card title="车辆排放分析">
               <div class="doubleCarbon-car-analyse">
-                <CarbonCarEmissionChart ref="CarbonCarEmissionChart" :query-data="queryData" :height="450"/>
+                <CarbonCarEmissionChart :call-back-company-option="callBackCompanyOption" ref="CarbonCarEmissionChart" :query-data="queryData" :height="450"/>
               </div>
             </Card>
           </div>

+ 59 - 123
src/components/doubleCarbon/overview/charts/carbonEmissionChart.vue

@@ -4,29 +4,35 @@ import apiCarbonOverview from "@/api/carbon/apiCarbonOverview";
 export default {
   data() {
     return {
+      seriesData: {
+        name: '',
+        data: [],
+        type: 'line',
+        smooth: true,
+        showSymbol:false,
+        symbolSize: 1,
+        lineStyle: {
+          width: 1,
+        },
+        emphasis: {
+          scale:1.5
+        }
+      },
       show: false,
       option: {
         legend: {
           data: [
-            '中迅',
-            '北京规划院',
-            '郑分',
-            '广分',
-            '上分',
-            '成分',
+
           ],
           selected: {
-            '中迅': false,
-            '北京规划院': true,
-            '郑分': false,
-            '广分': false,
-            '上分': false,
-            '成分': false,
-          }
+
+          },
+          type: "scroll",
+          width: '80%'
         },
         grid: {
           left: '0%', //默认10%
-          right: '1%', //默认10%
+          right: '20px', //默认10%
           bottom: '20px', //默认60
           top: '60px',
           containLabel: true
@@ -37,10 +43,10 @@ export default {
         },
         yAxis: [
           {
-            name: '排放量',
+            name: '排放量(tCO2e)',
             type: 'value',
             nameTextStyle: {
-              padding: [10, 0, 10, -12]
+              padding: [0, 0, 0, 30]
             },
           },
         ],
@@ -63,117 +69,14 @@ export default {
           },
           backgroundColor: 'rgba(0,0,0,0.8)',
         },
-        series: [
-          {
-            name: '中迅',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            symbolSize: 6,
-            lineStyle: {
-              color: "#FDB65B",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FDB65B"
-            },
-            emphasis: {
-              scale:1.5
-            }
-          },
-          {
-            name: '北京规划院',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#62CC97",
-              width: 3,
-            },
-            itemStyle: {
-              color: "#62CC97"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '郑分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4D94FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4D94FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '广分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4DF5FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4DF5FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '上分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#FF6E4D",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FF6E4D"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '成分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#8B4DFF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#8B4DFF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          }
-        ]
+        series: []
       },
     }
   },
   props: {
     height: Number,
-    queryData: Object
+    queryData: Object,
+    callBackCompanyOption: Function,
   },
   mounted() {
     this.$nextTick(()=>{
@@ -190,7 +93,40 @@ export default {
     },
     getData() {
       return apiCarbonOverview.getCarbonInfo(this.queryData).then(res=>{
-        let data = this.$util.dataUtil.covertDataToEcharts(res, ['zhongxun','guihuayuanBJ','zhengfen','guangfen','shangfen','chengfen'])
+        let names = [];
+        if (res.length>0) {
+          let obj = res[0].jsonObject;
+          for (const objKey in obj) {
+            names.push(objKey);
+          }
+        }
+        this.option.legend.data = names;
+        let series = [];
+        let selected = {};
+        let comoptions = [];
+        for (let i = 0; i < names.length; i++) {
+          let obj = JSON.parse(JSON.stringify(this.seriesData));
+          obj.name = names[i];
+          series.push(obj);
+
+          let opt = {
+            label: names[i],
+            value: i+1,
+          }
+          comoptions.push(opt)
+          selected[names[i]+''] = false;
+        }
+        if (this.queryData.companyId != '0') {
+          let name = names[Number(this.queryData.companyId)-1];
+          selected[name] = true;
+        } else {
+          let name = names[0];
+          selected[name] = true;
+        }
+        this.option.legend.selected = selected;
+        this.callBackCompanyOption(comoptions)
+        this.option.series = series;
+        let data = this.$util.dataUtil.covertDataToEcharts(res, names)
         this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
       })
     }

+ 21 - 1
src/components/doubleCarbon/overview/doubleCarbonOverview.vue

@@ -25,7 +25,12 @@ export default {
         companyId: "0",
         timeRange: this.$util.dateUtil.getNearlyMonthRange(),
       },
-      companyOptions: [],
+      companyOptions: [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ],
       coreData: [
         {
           title: "碳配额存量",
@@ -111,6 +116,20 @@ export default {
         this.newsData = res;
       });
     },
+    callBackCompanyOption(options) {
+      this.companyOptions = [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ]
+      if (options) {
+        options.forEach(item=>{
+          this.companyOptions.push(item);
+        })
+      }
+      this.$forceUpdate()
+    },
   },
 };
 </script>
@@ -157,6 +176,7 @@ export default {
                 <CarbonEmissionCharts
                   ref="CarbonEmissionCharts"
                   :query-data="queryData"
+                  :callBackCompanyOption="callBackCompanyOption"
                   :height="450"
                 />
               </div>

+ 64 - 126
src/components/doubleCarbon/print/charts/carbonPrintEmissionChart.vue

@@ -1,32 +1,40 @@
 <script>
+import apiCarbonOverview from "@/api/carbon/apiCarbonOverview";
 import apiCarbonCar from "@/api/carbon/apiCarbonCar";
 import apiCarbonPrint from "@/api/carbon/apiCarbonPrint";
 
 export default {
   data() {
     return {
+      seriesData: {
+        name: '',
+        data: [],
+        type: 'line',
+        smooth: true,
+        showSymbol:false,
+        symbolSize: 1,
+        lineStyle: {
+          width: 1,
+        },
+        emphasis: {
+          scale:1.5
+        }
+      },
+      show: false,
       option: {
         legend: {
           data: [
-            '中迅',
-            '北京规划院',
-            '郑分',
-            '广分',
-            '上分',
-            '成分',
+
           ],
           selected: {
-            '中迅': false,
-            '北京规划院': true,
-            '郑分': false,
-            '广分': false,
-            '上分': false,
-            '成分': false,
-          }
+
+          },
+          type: "scroll",
+          width: '80%'
         },
         grid: {
           left: '0%', //默认10%
-          right: '1%', //默认10%
+          right: '20px', //默认10%
           bottom: '20px', //默认60
           top: '60px',
           containLabel: true
@@ -37,10 +45,10 @@ export default {
         },
         yAxis: [
           {
-            name: '排放量',
+            name: '排放量(tCO2e)',
             type: 'value',
             nameTextStyle: {
-              padding: [10, 0, 10, -12]
+              padding: [0, 0, 0, 50]
             },
           },
         ],
@@ -63,125 +71,22 @@ export default {
           },
           backgroundColor: 'rgba(0,0,0,0.8)',
         },
-        series: [
-          {
-            name: '中迅',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            symbolSize: 6,
-            lineStyle: {
-              color: "#FDB65B",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FDB65B"
-            },
-            emphasis: {
-              scale:1.5
-            }
-          },
-          {
-            name: '北京规划院',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#62CC97",
-              width: 3,
-            },
-            itemStyle: {
-              color: "#62CC97"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '郑分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4D94FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4D94FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '广分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#4DF5FF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#4DF5FF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '上分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#FF6E4D",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#FF6E4D"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          },
-          {
-            name: '成分',
-            data: [],
-            type: 'line',
-            smooth: true,
-            showSymbol:false,
-            lineStyle: {
-              color: "#8B4DFF",
-              width: 1,
-            },
-            itemStyle: {
-              color: "#8B4DFF"
-            },
-            emphasis: {
-              scale:1.5
-            },
-          }
-        ]
+        series: []
       },
     }
   },
   props: {
     height: Number,
-    queryData: Object
+    queryData: Object,
+    callBackCompanyOption: Function,
   },
   mounted() {
     this.$nextTick(()=>{
-      this.initChart();
+      this.init();
     })
   },
   methods: {
-    initChart() {
+    init() {
       let chart = this.$echarts.init(this.$refs.myChart)
       this.chart = chart;
       this.$util.chartsResize(this.chart);
@@ -190,7 +95,40 @@ export default {
     },
     getData() {
       return apiCarbonPrint.getPrintInfo(this.queryData).then(res=>{
-        let data = this.$util.dataUtil.covertDataToEcharts(res, ['zhongxun','guihuayuanBJ','zhengfen','guangfen','shangfen','chengfen'])
+        let names = [];
+        if (res.length>0) {
+          let obj = res[0].jsonObject;
+          for (const objKey in obj) {
+            names.push(objKey);
+          }
+        }
+        this.option.legend.data = names;
+        let series = [];
+        let selected = {};
+        let comoptions = [];
+        for (let i = 0; i < names.length; i++) {
+          let obj = JSON.parse(JSON.stringify(this.seriesData));
+          obj.name = names[i];
+          series.push(obj);
+
+          let opt = {
+            label: names[i],
+            value: i+1,
+          }
+          comoptions.push(opt)
+          selected[names[i]+''] = false;
+        }
+        if (this.queryData.companyId != '0') {
+          let name = names[Number(this.queryData.companyId)-1];
+          selected[name] = true;
+        } else {
+          let name = names[0];
+          selected[name] = true;
+        }
+        this.option.legend.selected = selected;
+        this.callBackCompanyOption(comoptions)
+        this.option.series = series;
+        let data = this.$util.dataUtil.covertDataToEcharts(res, names)
         this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
       })
     }
@@ -199,7 +137,7 @@ export default {
 </script>
 
 <template>
-  <div id="personTrendChart" style="width: 100%" :style="{height: height+'px'}" ref="myChart" ></div>
+  <div class="myChart" style="width: 100%" :style="{height: height+'px'}" ref="myChart" ></div>
 </template>
 
 <style lang="less" scoped>

+ 8 - 0
src/components/doubleCarbon/print/charts/carbonPrintQuotaChart.vue

@@ -101,6 +101,14 @@ export default {
     },
     getData() {
       return apiCarbonPrint.getPrintInfoOrder(this.queryData).then(res=>{
+        if (res) {
+          res.sort((a,b)=>{
+            if (a.jsonObject.Print>b.jsonObject.Print) {
+              return 1;
+            }
+            return -1;
+          })
+        }
         let data = this.$util.dataUtil.covertDataToEcharts(res, ['Print'])
         this.option.yAxis.data = data.label;
         let arr = [];

+ 22 - 0
src/components/doubleCarbon/print/doubleCarbonPrint.vue

@@ -21,6 +21,12 @@ export default {
         companyId: "0",
         timeRange: this.$util.dateUtil.getNearlyMonthRange(),
       },
+      companyOptions: [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ],
       coreData: [
         {
           title: "文印累计排放(tco2e/)",
@@ -91,6 +97,20 @@ export default {
         this.coreData[4].content = res.worthAttention;
       });
     },
+    callBackCompanyOption(options) {
+      this.companyOptions = [
+        {
+          label: '全部',
+          value: '0'
+        }
+      ]
+      if (options) {
+        options.forEach(item=>{
+          this.companyOptions.push(item);
+        })
+      }
+      this.$forceUpdate()
+    },
   },
 };
 </script>
@@ -112,6 +132,7 @@ export default {
             <Query
               :show="['company', 'time']"
               :query-data.sync="queryData"
+              :company-options="companyOptions"
               :reset="reset"
               :search="search"
             ></Query>
@@ -136,6 +157,7 @@ export default {
                 <CarbonPrintEmissionChart
                   ref="CarbonPrintEmissionChart"
                   :query-data="queryData"
+                  :callBackCompanyOption="callBackCompanyOption"
                   :height="450"
                 />
               </div>