//今日各预警等级预警情况
<template>
  <div class="main">
    <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
        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: "radarEchartsJrgyjdjyjqk",
      chart: null,
    };
  },
  methods: {
    drawBar() {
      this.chart = this.$echarts.init(document.getElementById(this.id));
      const dataValue = [9, 6, 14, 10, 17];
      let ii = -1;
      this.chart.setOption({
        radar: {
          radius: "63%", //大小
          center: ["50%", "55%"], // 图的位置
          indicator: [
            { name: "Ⅰ级预警", max: 20 },
            { name: "Ⅱ级预警", max: 20 },
            { name: "Ⅲ级预警", max: 20 },
            { name: "Ⅳ级预警", max: 20 },
            { name: "Ⅴ级预警", max: 20 },
          ],
          shape: "circle",
          splitArea: {
            areaStyle: {
              color: "transparent", //背景
              // fontSize: 14,
            },
          },
          axisName: {
            rich: {
              a: {
                fontSize: 14,
                color: "#E3E8FF",
                align: "center",
                lineHeight: 21,
              },
              b: {
                fontSize: 17,
                color: "#FFAF65",
                align: "center",
                fontWeight: 700,
                lineHeight: 25.5,
              },
            },
            formatter: (a, b) => {
              ii++;
              return `{a|${a}}  \n  {b|${dataValue[ii]}}`;
            },
          },
          axisLine: {
            lineStyle: {
              color: "transparent",
            },
          },
          splitLine: {
            lineStyle: {
              type: "dashed", // 虚线
              color: "#8192BFCC", // 虚线颜色
            },
          },
        },
        series: [
          {
            type: "radar",
            data: [
              {
                value: dataValue,
                symbol: "circle", // 圆点为圆形
                symbolSize: 6, // 圆点大小
                lineStyle: {
                  width: 1,
                  type: "solid", // 连接线实线
                  color: "#FFAF65", // 连接线颜色
                },
                itemStyle: {
                  color: "#FFAF65", // 圆点颜色
                },
                areaStyle: {
                  color: "#4479FF80", // 围起来的面积颜色
                },
              },
            ],
          },
        ],
      });
    },
  },
  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%;
}
</style>
