//今日人员行为数据占比情况
<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 style="height: 86%; width: 50%">
          <div class="title">人员性别占比情况：</div>
          <PieEchartsJrryxwsjzbqkVue></PieEchartsJrryxwsjzbqkVue>
        </div>
        <div style="height: 86%; width: 50%">
          <div class="title">人员年龄占比情况：</div>
          <div
            ref="barEcharts"
            :id="id"
            :style="{ width: '100%', height: '100%' }"
          ></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import PieEchartsJrryxwsjzbqkVue from "./PieEchartsJrryxwsjzbqk.vue";
// import resize from "./mixins/resize";

export default {
  components: { PieEchartsJrryxwsjzbqkVue },
  // 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: "PieRadarEchartsJrryxwsjzbqk",
      chart: null,
    };
  },
  methods: {
    drawBar() {
      this.chart = this.$echarts.init(document.getElementById(this.id));
      const dataValue = [9, 6, 14, 10, 17];
      const sum = dataValue.reduce((sum, item) => {
        return sum + item;
      }, 0);
      let ii = -1;
      this.chart.setOption({
        radar: {
          radius: "63%", //大小
          center: ["50%", "55%"], // 图的位置
          indicator: [
            { name: "20岁以下", max: 20 },
            { name: "20~35岁", max: 20 },
            { name: "35~50岁", max: 20 },
            { name: "50~65岁", max: 20 },
            { name: "65岁以上", max: 20 },
          ],
          axisName: {
            rich: {
              a: {
                fontSize: 13,
                color: "#FFFFFFD9",
                // align: "center",
                lineHeight: 19.5,
              },
              b: {
                fontSize: 13,
                color: "#FFFFFFD9",
                // align: "center",
                // fontWeight: 700,
                lineHeight: 19.5,
              },
            },
            formatter: (a, b) => {
              ii++;
              return `{a|${a}:}  {b|${
                ((dataValue[ii] / sum) * 100).toFixed(2) + "%"
              }}`;
            },
          },
          axisLine: {
            lineStyle: {
              color: "#FAFAFA0D",
            },
          },
          // shape: "circle",
          splitArea: {
            areaStyle: {
              color: "#FAFAFA0D", //背景
              // fontSize: 14,
            },
          },
          // 分割的个数
          splitNumber: 4,
          // 分割的线条的样式
          splitLine: {
            lineStyle: {
              // type: "dashed", // 虚线
              color: "#FAFAFA0D", // 颜色
              width: 2,
            },
          },
        },
        series: [
          {
            type: "radar",
            data: [
              {
                value: dataValue,
                symbol: "none", // 没有圆点
                lineStyle: {
                  width: 2,
                  type: "solid", // 连接线实线
                  color: "#1972FF", // 连接线颜色
                },
                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;
}
.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;
  width: 100%;
  height: 86%;
  // padding-left: 10px;
  .title {
    font-size: 16px;
    font-weight: 700;
    line-height: 20px;
    text-align: left;
    color: #ebefff;
  }
}
</style>
