<template>
  <div class="bigscreen-echarts-radar">
    <div :id="eId" :style="styles"></div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  name: "echartsRadarWrap",
  props: {
    eId: {
      type: String
    },
    styles: {
      type: String
    },
    colorList: {
      type: [Array, String],
      default: ""
    },
    option: {
      stype: Object,
      default: {}
    }
  },
  data() {
    return {
      chart: null
    };
  },
  created() {
    this.chart = null;
  },
  mounted() {
    this.drawLine();
  },
  methods: {
    drawLine() {
      if (!this.chart) {
        this.chart = echarts.init(document.getElementById(this.eId));
      }
      const option = {
        title: {
          text: ""
        },
        color: this.colorList,
        tooltip: {},
        legend: {
          data: []
        },
        radar: {
          nameGap: 5,
          name: {
            textStyle: {
              color: "#fff",
              backgroundColor: "#99999900",
              borderRadius: 2,
              padding: [1, 1]
            }
          },
          splitArea: {
            show: true,
            areaStyle: {
              color: ["#515a6e00"] // 图表背景网格的颜色
            }
          },
          axisLabel: {
            // 坐标轴文本标签，详见axis.axisLabel
            show: false,
            textStyle: {
              color: "#247bd7" // 坐标轴刻度文字的样式
            }
          },
          splitLine: {
            show: true,
            lineStyle: {
              width: 1,
              color: "#0865da" // 图表背景网格线的颜色
            }
          },
          indicator: this.option.indicator
        },
        series: [
          {
            name: "预算 vs 开销（Budget vs spending）",
            type: "radar",
            symbol: "none",
            itemStyle: {
              normal: {
                color: "rgba(46, 255, 233, 1)", // 图表中各个图区域的边框线拐点颜色
                lineStyle: {
                  color: "rgba(30, 238, 255, 1)" // 图表中各个图区域的边框线颜色
                },
                areaStyle: {
                  type: "default"
                }
              }
            },
            data: [
              {
                value: this.option.seriesList,
                name: ""
              }
            ]
          }
        ]
      };
      // console.log('radar',this.option, this.chart)
      this.chart.setOption(option);
    }
  },
  watch: {
    option: {
      handler: function (val, oldVal) {
        this.chart = null;
        this.drawLine();
      },
      deep: true
    }
  }
};
</script>
<style lang="scss">
.bigscreen-echarts-radar {
  position: relative;
  height: 100%;
  top: 0px;
}
</style>
