// 年度单模块预警情况
<template>
  <div class="main" style="width: 930px">
    <div class="mian-contain">
      <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="item-left">
          <div class="item-main">
            <div class="img-byyqk">
              <img src="../../../assets/byyjqk.png" alt="" />
            </div>
            <div class="item-main-text">
              <div class="item-main-text-1">年度预警数</div>
              <div class="item-main-text-num">326</div>
            </div>
            <div class="item-main-text1">
              <i class="el-icon-caret-bottom"></i>
              年同比-1.7%
            </div>
          </div>
        </div>
        <div class="imet-right">
          <div
            ref="barEcharts"
            :id="id"
            :style="{ width: '100%', height: '100%' }"
          ></div>
        </div>
      </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: "barEchartsNddmkyjqk",
      chart: null,
    };
  },
  methods: {
    drawBar() {
      this.chart = this.$echarts.init(document.getElementById(this.id));
      this.chart.setOption({
        grid: {
          top: 30,
          bottom: 20,
          left: 30,
          right: 30,
        },
        xAxis: [
          {
            type: "category",
            data: [
              "1月",
              "2月",
              "3月",
              "4月",
              "5月",
              "6月",
              "7月",
              "8月",
              "9月",
              "10月",
              "11月",
              "12月",
            ],
            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: 100, // 设置刻度间隔为 100
        },
        series: [
          {
            // name: this.legend[0],
            // data: this.yAxisData,
            data: [30, 190, 80, 360, 150],
            showSymbol: false, //去掉折线上的小圆点
            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)", // 结束颜色
                  },
                ],
              },
            },
          },
        ],
      });
    },
  },
  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;
}
.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;
  }
}
.mian-contain {
  border-radius: 8px;
  padding: 10px;
  background: rgba(29, 65, 171);
  // overflow: hidden;
  height: 100%;
}
.container {
  display: flex;
  .item-left {
    margin-right: 10px;
    .item-main {
      padding: 30px;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      .img-byyqk {
        width: 180px;
        height: 72px;
        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
        }
      }
      .item-main-text {
        text-align: center;
        margin-top: -20px;
        .item-main-text-1 {
          font-size: 18px;
          font-weight: 700;
          line-height: 27px;
          color: #e3e8ffcc;
        }
        .item-main-text-num {
          font-size: 28px;
          font-weight: 900;
          line-height: 42px;
          color: #ebefff;
        }
      }
      .item-main-text1 {
        margin-top: 20px;
        font-size: 16px;
        font-weight: 500;
        line-height: 24px;
        color: #5bffeb;
      }
    }
  }
  .imet-right {
    flex: 1;
  }
}
</style>
