<template>
  <div id="centreLeft1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span style="color:#5cd9e8">
          <icon name="chart-bar"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">发电机趋势</span>
          <dv-decoration-3 style="width:1.25rem;height:.25rem; position:relative;top:-.0375rem;" />
        </div>
      </div>
      <div class="d-flex chartStyle" @click="openchart1">
        <!--渐变折线图-->
        <span style="padding-left:10px;">Unit:(MW)</span>
        <div id="oneGTGyChart" style="width:100%;height:2rem;"></div>
      </div>
      <div class="d-flex chartStyle" @click="openchart2">
        <!--渐变折线图-->
        <span style="padding-left:10px;">Unit:(MW)</span>
        <div id="twoGTGyChart" style="width:100%;height:2rem;"></div>
      </div>
      <div class="d-flex chartStyle" @click="openchart3">
        <span style="padding-left:10px;">Unit:(MW)</span>
        <!--渐变折线图-->
        <div id="threeGTGyChart" style="width:100%;height:2rem;"></div>
      </div>
      <div class="d-flex chartStyle" @click="openchart4">
        <!--渐变折线图-->
        <span style="padding-left:10px;">Unit:(MW)</span>
        <div id="fourGTGyChart" style="width:100%;height:2rem;"></div>
      </div>
    </div>
      <el-dialog  :close-on-click-modal="false" class="my-info-dialog" :visible.sync="openChartOne" title="3#GTG" @open="open1" width="1600px" destroy-on-close append-to-body>
        <div id="oneGTGyChart1" style="width:100%;height:600px;"></div>
      </el-dialog>
    <el-dialog  :close-on-click-modal="false" class="my-info-dialog" :visible.sync="openChartTwo" title="STG" @open="open2" width="1600px" destroy-on-close append-to-body>
      <div id="twoGTGyChart1" style="width:100%;height:600px;"></div>
    </el-dialog>
    <el-dialog  :close-on-click-modal="false" class="my-info-dialog" :visible.sync="openChartThree" title="1#GTG" @open="open3" width="1600px" destroy-on-close append-to-body>
      <div id="threeGTGyChart1" style="width:100%;height:600px;"></div>
    </el-dialog>
    <el-dialog  :close-on-click-modal="false" class="my-info-dialog" :visible.sync="openChartFour" title="2#GTG" @open="open4" width="1600px" destroy-on-close append-to-body>
      <div id="fourGTGyChart1" style="width:100%;height:600px;"></div>
    </el-dialog>
  </div>
</template>

<script>
import centreLeft1Chart from "./echart/centerLeft2/centreLeft1Chart";
export default {
  props: {
    monthData: {},
    latest30DayData: {},
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '2.2rem'
    }
  },
  data() {
    return {
      openChartOne: false,
      openChartTwo: false,
      openChartThree: false,
      openChartFour: false,
      config: {
        lineWidth: 30,
        activeRadius: "80%",
        radius: "75%",
        activeTimeGap: 2000,
        data: [
          {
            name: "周口",
            value: 55
          },
          {
            name: "南阳",
            value: 120
          },
          {
            name: "西峡",
            value: 78
          },
          {
            name: "驻马店",
            value: 66
          },
          {
            name: "新乡",
            value: 80
          }
        ]
      },
      numberData: [
        {
          number: {
            number: [15],
            toFixed: 1,
            content: "{nt}"
          },
          text: "发电能力"
        },
        {
          number: {
            number: [1144],
            toFixed: 1,
            content: "{nt}"
          },
          text: "发电能力"
        },
        {
          number: {
            number: [361],
            toFixed: 1,
            content: "{nt}"
          },
          text: "发电能力"
        },
        {
          number: {
            number: [157],
            toFixed: 1,
            content: "{nt}"
          },
          text: "发电能力"
        }
      ]
    };
  },
  components: {
    centreLeft1Chart
  },
  mounted() {
    this.changeTiming();
    this.initOneChart();
    this.initTwoChart();
    this.initThreeChart();
    this.initFourChart();
  },
  methods: {
    open1(){
      this.$nextTick(() => {
        this.initOneChartDialog()
      })
    },
    open2(){
      this.$nextTick(() => {
        this.initTwoChartDialog()
      })
    },
    open3(){
      this.$nextTick(() => {
        this.initThreeChartDialog()
      })
    },
    open4(){
      this.$nextTick(() => {
        this.initFourChartDialog()
      })
    },
    openchart1(){
      this.openChartOne = true
    },
    openchart2(){
      this.openChartTwo = true
    },
    openchart3(){
      this.openChartThree = true
    },
    openchart4(){
      this.openChartFour = true
    },
    changeTiming() {
      setInterval(() => {
        this.changeNumber();
      }, 3000);
    },
    changeNumber() {
      this.numberData.forEach((item, index) => {
        item.number.number[0] += ++index;
        item.number = { ...item.number };
      });
    },
    initOneChart() {
      // 基于准备好的dom，初始化echarts实例
      this.chart = this.echarts.init(document.getElementById('oneGTGyChart'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].gtg3PowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        title: {
          text: '3#GTG',
          textAlign: 'center',
          x: 'center',
          y: '1px',
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
          }
        },
        xAxis: {
          type: 'category',
          data:dateDay,
          axisLabel: {
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            color: '#ffffff'
          }
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(255,128,0)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(253,222,2)'
                },
                {
                  offset: 1,
                  color: 'rgb(255,128,0)'
                }
              ])
            },
          }
        ]
      })
    },
    initOneChartDialog() {
      // 基于准备好的dom，初始化echarts实例
      this.chart1 = this.echarts.init(document.getElementById('oneGTGyChart1'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].gtg3PowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart1.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          // data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
          data:dateDay
        },
        yAxis: {
          type: 'value',
          name: 'Unit:(MW)'
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(255,128,0)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(253,222,2)'
                },
                {
                  offset: 1,
                  color: 'rgb(255,128,0)'
                }
              ])
            },
          }
        ]
      })
    },
    initTwoChart() {
      // 基于准备好的dom，初始化echarts实例
      this.chart = this.echarts.init(document.getElementById('twoGTGyChart'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].stgPowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        title: {
          text: 'STG',
          textAlign: 'center',
          x: 'center',
          y: '1px',
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
          }
        },
        xAxis: {
          type: 'category',
          // data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
          data:dateDay,
          axisLabel: {
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            color: '#ffffff'
          }
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(0,0,255)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(0,255,255)'
                },
                {
                  offset: 1,
                  color: 'rgb(0,0,255)'
                }
              ])
            },
          }
        ]
      })
    },
    initTwoChartDialog() {
      // 基于准备好的dom，初始化echarts实例
      this.chart2 = this.echarts.init(document.getElementById('twoGTGyChart1'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].stgPowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart2.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        title: {
          text: '1#发电机',
          textAlign: 'center',
          x: 'center',
          y: '1px',
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
          }
        },
        xAxis: {
          type: 'category',
          // data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
          data:dateDay
        },
        yAxis: {
          type: 'value',
          name: 'Unit:(MW)'
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(24,56,255)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(8,32,252)'
                },
                {
                  offset: 1,
                  color: 'rgb(21,171,231)'
                }
              ])
            },
          }
        ]
      })
    },
    initThreeChart() {
      // 基于准备好的dom，初始化echarts实例
      this.chart = this.echarts.init(document.getElementById('threeGTGyChart'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].gtg1PowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        title: {
          text: '1#GTG',
          textAlign: 'center',
          x: 'center',
          y: '1px',
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
          }
        },
        xAxis: {
          type: 'category',
          // data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
          data:dateDay,
          axisLabel: {
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            color: '#ffffff'
          }
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(0,128,0)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(128,255,0)'
                },
                {
                  offset: 1,
                  color: 'rgb(0,128,0)'
                }
              ])
            },
          }
        ]
      })
    },
    initThreeChartDialog() {
      // 基于准备好的dom，初始化echarts实例
      this.chart3 = this.echarts.init(document.getElementById('threeGTGyChart1'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].gtg1PowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart3.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        title: {
          text: '4#发电机',
          textAlign: 'center',
          x: 'center',
          y: '1px',
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
          }
        },
        xAxis: {
          type: 'category',
          // data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
          data:dateDay
        },
        yAxis: {
          type: 'value',
          name: 'Unit:(MW)'
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(0,128,0)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(128,255,0)'
                },
                {
                  offset: 1,
                  color: 'rgb(0,128,0)'
                }
              ])
            },
          }
        ]
      })
    },
    initFourChart() {
      // 基于准备好的dom，初始化echarts实例
      this.chart = this.echarts.init(document.getElementById('fourGTGyChart'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].gtg2PowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        title: {
          text: '2#GTG',
          textAlign: 'center',
          x: 'center',
          y: '1px',
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
          }
        },
        xAxis: {
          type: 'category',
          // data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
          data:dateDay,
          axisLabel: {
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            color: '#ffffff'
          }
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(128,0,109)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(189,225,250)'
                },
                {
                  offset: 1,
                  color: 'rgb(128,0,255)'
                }
              ])
            },
          }
        ]
      })
    },
    initFourChartDialog() {
      // 基于准备好的dom，初始化echarts实例
      this.chart4 = this.echarts.init(document.getElementById('fourGTGyChart1'))
      const dateDay = [];
      const dateNum = [];
      for (let i = 0; i < this.latest30DayData.length; i++) {
        dateDay[i] = this.latest30DayData[i].pullDate.toString().substr(5, 5);
        dateNum[i] = this.latest30DayData[i].gtg2PowerGenLevel;
      }
      dateDay.reverse();
      dateNum.reverse();
      this.chart4.setOption({
        /* 周围边距 */
        grid: {
          left: '3%',
          right: '3%',
          bottom: '1%',
          top: '13%',
          containLabel: true
        },
        title: {
          text: '2#GTG',
          textAlign: 'center',
          x: 'center',
          y: '1px',
          textStyle: {
            color: '#ffffff',
            fontSize: 12,
          }
        },
        xAxis: {
          type: 'category',
          // data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
          data:dateDay
        },
        yAxis: {
          type: 'value',
          name: 'Unit:(MW)'
        },
        series: [
          {
            // data: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135, 147, 260, 23, 147, 123],
            data:dateNum,
            type: 'line',
            itemStyle: {
              color: 'rgb(128,0,109)'
            },
            symbol: "none",
            areaStyle: {
              color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: 'rgb(189,225,250)'
                },
                {
                  offset: 1,
                  color: 'rgb(128,0,255)'
                }
              ])
            },
          }
        ]
      })
    },
  }
};
</script>

<style lang="scss">
/*body背景色*/
  .my-info-dialog {
    .el-dialog {
      .el-dialog__body{
        background: #ffffff;
      }
      .el-dialog__header{
      }
    }
  }

#centreLeft1 {
  padding: 0.2rem;
  height: 5.125rem;
  min-width: 3.75rem;
  border-radius: 0.0625rem;
  .bg-color-black {
    height: 4.8125rem;
    border-radius: 0.125rem;
    width: 100%;
    .chartStyle {
      // float: right;
      display:inline-block;
      position: relative;
      width: 50%;
    }
  }
  .text {
    color: #ffffff;
  }
  .chart-box {
    margin-top: 0.2rem;
    width: 2.125rem;
    height: 2.125rem;
    .active-ring-name {
      padding-top: 0.125rem;
    }
  }
  .bottom-data {
    .item-box {
      float: right;
      position: relative;
      width: 50%;
      color: #d3d6dd;
      // 金币
      .coin {
        position: absolute;
        left: 0.1rem;
        top: 0.2125rem;
        font-size: 0.25rem;
        color: #ffc107;
      }
      .colorYellow {
        color: yellowgreen;
      }
    }
  }
}
</style>
