<template>
  <el-row>
    <div id="index1" ref="echartD" style="width:100%;height:300px;"></div>
  </el-row>
</template>
<script>
import * as echarts from "echarts";
export default {
  props: ["resData"],
  props: {
    dataMap: { type: Number, default: () => 0 },
    dataNumber: { type: Number, default: () => 0 },
    color: { type: String, default: () => "#468EFD" },
    size: { type: Number, default: () => 20 },
    tick: { type: Boolean, default: () => true },
    with: { type: Number, default: () => 200 },
  },
  data() {
    return {};
  },
  watch: {
    dataMap(val) {
      console.log(val)
      this.getData(val);
    },
    dataNumber(val) {
      this.getData(val);
    },
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData(val) {
      console.log(val)
      echarts.init(this.$refs.echartD).setOption({
        grid: {
          // top: 0,
          // bottom: 0,
          // left: 0,
          // right: 0,
          // margi
        },
        series: [
          // 进度条
          {
            name: "仪表盘",
            type: "gauge",
            radius: "55%", // 半径
            startAngle: 270, //开始角度 左侧角度
            endAngle: -89.999, //结束角度 右侧
            splitNumber: 20,
            axisLine: {
              lineStyle: {
                color: [
                  [this.dataMap, this.color],
                  [1, "#FF5801"],
                ],
                width: this.with,
              },
            },
            axisLabel: {
              show: false,
            },
            axisTick: {
              show: false,
            },
            splitLine: {
              show: false,
            },
            itemStyle: {
              show: false,
            },
            detail: {
              formatter:  (value) => {
                let data = `电量:${this.dataNumber.checkCount}\n信号:${this.dataNumber.checkCount}`
                return data;
              },
              offsetCenter: [0, "0%"],
              textStyle: {
                //fontSize: this.size,
                fontSize: this.size,
                fontWeight: "700",
                color:this.color,
                // color: "#FFF",
                fontFamily: '"DS", "DS-B", "DS-BB", "DS-BS"',
              },
            },
            title: {
              offsetCenter: [0, "10%"],
            },
            pointer: {
              show: false,
            },
            data: [
                (this.dataNumber/10 || this.dataMap),
            ],
          },
        ],
      });
      // window.addEventListener("resize", function() {
      //   myChart.resize();
      // });

    },

  }
};
</script>

<style lang="scss" scoped></style>
