// 今日各时段预警情况
<template>
  <div class="main" style="width: 930px">
    <div class="top">
      <div class="top-tit">
        <img src="../../../assets/arrow.png" alt="" />
        <span>今日各时段预警情况</span>
      </div>
      <div class="top-line">
        <img src="../../../assets/top-line.png" alt="" />
      </div>
    </div>
    <div class="container">
      <div class="container-title">今日预警数：46</div>
      <div
        ref="barEcharts"
        :id="id"
        :style="{ width: '100%', height: '100%' }"
      ></div>
    </div>
  </div>
</template>

<script>
// import resize from "./mixins/resize";
export default {
  // mixins: [resize],
  props: {
    type: {
      type: String,
      default: "",
    },
    legend: {
      type: Array,
      default() {
        return [];
      },
    },
    // title: {
    //   type: String,
    //   default: ''
    // },
    xAxisData: {
      type: Array,
      default() {
        return [];
      },
    },
    yAxisData: {
      type: Array,
      default() {
        return [];
      },
    },
    colorList: {
      type: Array,
      default() {
        return ["#88aefe", "#4983fb"];
      },
    },
  },
  data() {
    return {
      id: "LineEchartsJrgsdyjqk",
      chart: null,
    };
  },
  methods: {
    drawBar() {
      this.chart = this.$echarts.init(document.getElementById(this.id));
      this.chart.setOption({
        grid: {
          top: 10,
          bottom: 30,
          left: 40,
          right: 30,
        },
        xAxis: [
          {
            type: "category",
            data: [
              "00:00-03:00",
              "03:00-06:00",
              "06:00-09:00",
              "09:00-12:00",
              "12:00-15:00",
              "15:00-18:00",
              "18:00-21:00",
              "21:00-24:00",
            ],
            axisLabel: {
              fontSize: 13,
              color: "#EBEFFFCC",
            },
            // x轴最下面的线
            axisLine: {
              show: true, // X轴 网格线 颜色类型的修改
              lineStyle: {
                type: "dashed",
                color: "#596687",
              },
            },
          },
        ],
        yAxis: {
          type: "value",
          //y轴名字
          axisLabel: {
            show: true,
            textStyle: {
              color: "#EBEFFFCC",
              fontSize: 13,
            },
          },
          // x轴线
          splitLine: {
            show: true,
            lineStyle: {
              type: "dashed",
              color: "#596687",
            },
          },
          interval: 2, // 设置刻度间隔为 50
        },
        series: [
          {
            // name: this.legend[0],
            // data: this.yAxisData,
            data: [3, 9, 8, 12, 10],
            showSymbol: false, //去掉折线上的小圆点
            //  symbol: 'none', // 没有圆点
            type: "line",
            //设置折线颜色和粗细
            lineStyle: {
              width: 2,
              color: "#4BC7C7",
            },
            areaStyle: {
              // 面积阴影
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(52, 60, 88, 0)", // 起始颜色
                  },
                  {
                    offset: 0.937,
                    color: "rgba(105, 147, 254, 0.36)", // 结束颜色
                  },
                ],
              },
            },
            // itemStyle: {
            //   color: "#FFA741",
            // },
            // symbolSize: 10, // 设置折线上的小圆点大小为 10px
          },
        ],
      });
    },
  },
  watch: {
    yAxisData() {
      // console.log(this.findingsData);
      // console.log(this.type);
      this.drawBar();
    },
  },
  mounted() {
    this.drawBar();
  },
};
</script>

<style lang="scss" scoped>
.main {
  width: 455px;
  height: 308px;
  border-radius: 8px;
  background: rgba(26, 52, 125, 0.95);
  padding: 10px;
  margin: 20px;
}
.top {
  height: 45px;
  .top-tit {
    font-size: 18px;
    font-weight: 600;
    line-height: 23.4px;
    text-align: left;
    color: #ffffff;
    img {
      margin-right: 10px;
    }
  }
  .top-line {
    margin-top: -7px;
  }
}
.container {
  width: 100%;
  height: 86%;
  position: relative;
  .container-title {
    position: absolute;
    right: 7px;
    top: -48px;
    font-size: 20px;
    font-weight: 500;
    line-height: 30px;
    color: #53cbff;
  }
}
</style>
