<template>
  <div class="box">
    <tit :title="'光伏发电折合碳排放趋势'">
      <div class="tit-r">单位：t</div>
    </tit>
    <div id="mainTendency"></div>
  </div>
</template>

<script>
import tit from "./tit.vue";
export default {
  data() {
    return {
    };
  },
  components: {
    tit
  },
  created() {
    this.$nextTick(() => {
      this.echartsInit()
    })

  },
  mounted() {

  },
  methods: {
    echartsInit() {
      const chartDom = document.getElementById('mainTendency');
      const myChart = this.$echarts.init(chartDom);
      const option = {
        // title: {
        //   show: true,
        //   text: "温度（单位：℃）",
        //   textStyle: {
        //     fontWeight: 400,
        //     fontSize: 14,
        //     color: "#009fff",
        //   },
        //   top: 10,
        // },

        grid: {
          top: "10%",
          left: "0",
          right: "10",
          bottom: "0",
          containLabel: true,
        },
        // tooltip: {
        //   trigger: "axis",
        //   formatter: (e) => {
        //     return (
        //       e[0].axisValueLabel +
        //       "<br />" +
        //       '<div style="border: 1px solid #12244A;margin:5px 0"></div>' +
        //       '<span style="color:#fff">' +
        //       "温度变化趋势" +
        //       "：" +
        //       "</span>" +
        //       e[0].value +
        //       " ℃" +
        //       "<br />"
        //     );
        //   },
        //   extraCssText:
        //     "font-size: 16px;border-radius: 2px;height:60px;border: 1px solid #0477DF;background: rgba(0, 0, 0, 0.8);text-align:left;color:#00E5FC",
        // },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: [
              // "0",
              "1月",
              "2月",
              "3月",
              "4月",
              "5月",
              "6月",
              // "7月",
              // "8月",
              // "9月",
              // "10月",
              // "11月",
              // "12月",
            ],
            axisLabel: {
              //y轴文字的配置
              textStyle: {
                color: "#9fa9b5",
                margin: 14,
              },
            },
            axisTick: {
              show: true,
              inside: true,
              lineStyle: {
                color: "#9fabc1",
              },
            },
            axisLine: {
              lineStyle: {
                color: "#9fabc1",
              },
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            show: true, //是否显示y轴
            axisLabel: {
              //y轴文字的配置
              textStyle: {
                color: "#9fa9b5",
              },
            },
            axisTick: {
              show: true,
              inside: true,
              lineStyle: {
                color: "#9fabc1",
              },
            },
            // 刻度线
            axisLine: {
              show: true,
              lineStyle: {
                color: "#9fabc1",
              },
            },
            // 线
            splitLine: {
              show: true,
              lineStyle: {
                color: "#616d87",
              },
            },
          },
        ],
        series: [
          {
            type: "line",
            smooth: true,
            lineStyle: {
              width: 2,
              color: "#2CBCCE",
            },
            label: {
              show: true,
              color: "#fff",
              backgroundColor: "#2CBCCE",
              padding: [2, 4, 2, 4]
            },
            areaStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 1,
                x2: 0,
                y2: 0,
                colorStops: [
                  {
                    offset: 0,
                    color: "#031a45",
                  },
                  {
                    offset: 1,
                    color: "#2CBCCE",
                  },
                ],
                global: false, //  缺省为  false
              },
            },
            data: [{
              value: 18, label: {
                offset: [12, 0]
              }
            }, 20, 15, 3022, 2225, 10, 15, 16, 18, 30, 20, 25, 30],
            // markPoint: {
            //   symbolSize: 40,
            //   itemStyle: {
            //     color: '#14a876'
            //   },
            //   data: [
            //     { type: "max", name: "Max" },
            //     { type: "min", name: "Min" },
            //   ],
            // },
          },
        ],
      };
      myChart.setOption(option);
    }
  }
};
</script>
<style lang="scss" scoped>
.box {
  width: 4.6rem;
  height: 3.2rem;
  border-radius: 4px;
  box-sizing: border-box;
  background: url("../../../../public/img/energySourcesProvince/tendency.png");
  background-size: 100% 100%;
  padding: 0.54rem 0.22rem 0 0.22rem;
  position: absolute;
  top: 4.69rem;
  right: 0.24rem;

  .tit-r {
    font-size: 0.14rem;
    color: rgba($color: #fff, $alpha: 0.4);
    margin-top: 0.04rem;
  }

  #mainTendency {
    height: 2.4rem;
  }
}
</style>
