<template>
  <div class="crop-area">
    <Model title="农业总产值">
      <div ref="areas" class="area"></div>
    </Model>
  </div>
</template>

<script>
import Model from "../model.vue";

export default {
  name: "nyzcc",
  components: { Model },
  mounted() {
    this.initRT();
  },
  methods: {
    initRT() {
      let Chart = this.$refs.areas;
      let myChart = this.$echarts.init(Chart);
      let that = this;
      const option = {
        // backgroundColor: '#0D2038',
        color: ["#1890FF"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
          formatter: (params) => {
            return `${params[0].name} :  ${params[0].value}亿元`;
          },
        },
        grid: {
          left: "0%",
          right: "0%",
          bottom: "3%",
          top: "0%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            data: ["2019", "2020", "2021", "2022"],
            boundaryGap: false,
            axisTick: {
              show: false, // 不显示坐标轴刻度线
            },
            splitLine: {
              // show: true,
              lineStyle: {
                // type: 'dashed',
                color: "#ffffff",
              },
            },
            axisLine: {
              lineStyle: {
                color: "#ffffff",
              },
            },
            //x底部文字
            axisLabel: {
              textStyle: {
                padding: [10, 0, 0, 0], //表示 [上, 右, 下, 左] 的边距。
                color: "#ffffff",
                fontSize: 16,
              },
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            //y右侧文字
            axisLabel: {
              textStyle: {
                color: "#ffffff",
                fontSize: 16,
              },
              // formatter: '{value} 亿元'
            },
            axisLine: {
              lineStyle: {
                color: "#ffffff",
              },
            },
            lineStyle: {
              type: "dashed",
              color: "#ffffff",
            },
            // y轴的分割线
            splitLine: {
              // show: true,
              lineStyle: {
                type: "dashed",
                color: "#ffffff",
              },
            },
          },
        ],
        series: [
          {
            name: "总产值",
            type: "line",
            smooth: true,
            symbol: "circle", //拐点设置为实心
            symbolSize: 10, //拐点大小
            itemStyle: {
              normal: {
                borderColor: "rgba(42,157,255,.2)", //拐点边框颜色
                borderWidth: 10, //拐点边框大小，
                color: "#1890FF",
              },
            },
            tooltip: {
              trigger: "axis",
              axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: "line", // 默认为直线，可选为：'line' | 'shadow'
              },
            },
            lineStyle: {
              normal: {
                width: 3,
                shadowColor: "#1890FF",
                shadowBlur: 20,
              },
            },
            areaStyle: {
              opacity: 1,
              //右下左上
              color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(24, 144, 255, .5)",
                },
                {
                  offset: 0.3,
                  color: "rgba(24, 144, 255, 0.2)",
                },
                {
                  offset: 1,
                  color: "rgba(24, 144, 255, 0)",
                },
              ]),
            },
            data: [
              { value: 122.34 },
              { value: 136.37 },
              { value: 149.64 },
              { value: 152.93 },
              // { value: 625 },
              {
                value: 155,
                // symbolSize: 15,
                itemStyle: {
                  color: "#1EE7E7",
                  borderColor: "rgba(30,231,231,.5)",
                  borderWidth: 15, //拐点边框大小，
                },
              },
            ],
          },
        ],
      };
      myChart.setOption(option);
    },
  },
};
</script>

<style lang="less" scoped>
.crop-area {
  margin-top: 10px;

  .area {
    width: 100%;
    height: 225px;
  }
}
</style>
