<script>
import apiCarbonPrint from "@/api/carbon/apiCarbonPrint";
import apiCarbonPv from "@/api/carbon/apiCarbonPv";

export default {
  data() {
    return {
      option: {
        legend: {
          data: [
            '中迅',
            '北京规划院',
            '郑分',
            '广分',
            '上分',
            '成分',
          ]
        },
        grid: {
          left: '0%', //默认10%
          right: '1%', //默认10%
          bottom: '15%', //默认60
          top: '15%',
          containLabel: true
          //grid区域是否包含坐标轴的刻度标签
        },
        xAxis: {
          data: []
        },
        yAxis: [
          {
            name: '排放量',
            type: 'value',
            nameTextStyle: {
              padding: [10, 0, 10, -12]
            },
          },
        ],
        dataZoom: [
          {
            type: 'slider',
            start: 0,
            end: 100,
            height: 12,
          },
          {
            type: 'inside',
            start: 0,
            end: 100,
          }
        ],
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
          textStyle: {
            color: '#fff',
            align: 'left',
            fontSize: 14
          },
          axisLine: {//x坐标轴轴线
            show: true,
            lineStyle: {//x坐标轴轴线样式
              color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)'，设置标签颜色
            }
          },
          backgroundColor: 'rgba(0,0,0,0.8)',
        },
        series: [
          {
            name: '中迅',
            data: [],
            type: 'line',
            smooth: true,
            showSymbol:false,
            symbolSize: 6,
            lineStyle: {
              color: "#FDB65B",
              width: 4,
            },
            itemStyle: {
              color: "#FDB65B"
            },
            emphasis: {
              scale:1.5
            }
          },
          {
            name: '北京规划院',
            data: [],
            type: 'line',
            smooth: true,
            showSymbol:false,
            lineStyle: {
              color: "#62CC97",
              width: 1,
            },
            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
            },
          }
        ]
      },
    }
  },
  props: {
    height: Number,
  },
  mounted() {
    this.$nextTick(()=>{
      this.initChart();
    })
  },
  methods: {
    initChart() {
      let chart = this.$echarts.init(this.$refs.myChart)
      this.chart = chart;
      chart.setOption(this.option)
      this.getData()
    },
    getData() {
      apiCarbonPv.getPhotovoltaicInfo({}).then(res=>{
        let data = this.$util.dataUtil.covertDataToEcharts(res, ['zhongxun','guihuayuanBJ','zhengfen','guangfen','shangfen','chengfen'])
        this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
      })
    }
  }
}
</script>

<template>
  <div id="personTrendChart" style="width: 100%" :style="{height: height+'px'}" ref="myChart" ></div>
</template>

<style lang="less" scoped>

</style>