<template>
  <div class="main"></div>
</template>

<script>
export default {
  data() {
    return {
    };
  },

  components: {},

  computed: {},

  beforeDestroy() {
    this.myChart = null;
    this.$echarts.dispose(this.myChart);
    window.removeEventListener("resize", this.chartResize);
  },
  mounted() {
    this.chart()
    this.init()
  },
  methods: {
    init() {
      window.addEventListener("resize", this.chartResize);
    },
    chartResize() {
      this.myChart.resize();
    },
    chart() {
      // 基于准备好的dom，初始化echarts实例
      this.myChart = this.$echarts.init(
        document.querySelector(".main")
      );
      var op = {
        grid: {
          top: "15%",
          left: "5%",
          right: "10%",
          bottom: "10%",
          containLabel: true,
        },
        visualMap: {
          show: false,
          min: 200,
          max: 2500,
          left: "left",
          top: "bottom",
          text: ["高", "低"],
          calculable: true,
          // colorLightness: [0.2, 100],
          color: [
            "rgba(3, 190, 251, 1)",
            "rgba(17, 221, 228, 1)",
            "rgba(253, 185, 23, 1)",
          ],
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            axisLine: {
              lineStyle: {
                color: "rgba(36, 53, 80, 1)",
              },
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: "rgba(36, 53, 80, 1)",
              },
            },
            axisTick: {
              show: false,
            },
            splitArea: {
              show: false,
            },
            axisLabel: {
              interval: 0,
              color: "#FFF",
              fontSize: 14,
            },
            data: [1, 2, 3, 4, 5, 6],
          },
        ],
        yAxis: [
          {
            // name: '次数',
            nameTextStyle: {
              color: "#03D8EF",
              fontSize: 14,
            },
            type: "value",
            // splitNumber: 3,
            axisLine: {
              show: true,
              lineStyle: {
                color: "rgba(36, 53, 80, 1)",
              },
            },
            axisTick: {
              show: false,
            },
            axisLabel: {
              show: false,
            },
            splitArea: {
              show: false,
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: "rgba(36, 53, 80, 1)",
              },
            },
            axisLabel: {
              interval: 0,
              color: "rgba(48, 171, 231, 1)",
              fontSize: 14,
            },
          },
          {
            axisLine: {
              show: false,
            },
            axisTick: {
              show: false,
            },
          },
        ],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            lineStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(0, 255, 233,0)",
                  },
                  {
                    offset: 0.5,
                    color: "rgba(255, 255, 255,1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(0, 255, 233,0)",
                  },
                ],
                global: false,
              },
            },
          },
        },
        series: [
          {
            name: "次数",
            type: "line",
            smooth: true, // 是否平滑曲线显示
            showAllSymbol: false,
            symbol: "emptyCircle",
            symbolSize: 10,
            symbol: "none",
            label: {
              show: false,
              position: "top",
              textStyle: {
                color: "#fff",
              },
            },
            lineStyle: {
              width: 4,
            },
            data: [1, 2, 3, 4, 5, 6],
          },
        ],
      };
      this.myChart.setOption(op);
    },
  }
}

</script>
<style scoped>
.main {
  width:100%;
  height: 100%;
}
</style>