echarts绘制雷达图


<template>
  <div>
    <div>【云端报警风险】</div>
    <div ref="target" class="w-full h-full" style='width:200px;height:300px'></div>
  </div>
</template>

<script setup>
import { ref, onMounted,watch } from 'vue';
import * as echarts from "echarts";
// 1.初始化
let myChart = null;
const target = ref(null);
onMounted(() => {
  myChart = echarts.init(target.value);
  renderChart();
});
let resData=[
  {
    "id": 1,
    "name": "华北",
    "value": 64
  },
  {
    "id": 2,
    "name": "东北",
    "value": 68
  },
  {
    "id": 3,
    "name": "华东",
    "value": 45
  },
  {
    "id": 4,
    "name": "中南",
    "value": 74
  },
  {
    "id": 5,
    "name": "西南",
    "value": 69
  },
  {
    "id": 6,
    "name": "西北",
    "value": 37
  }
]
// 2.构建 option 配置对象
const renderChart = () => {
  const options = {
    // 雷达图坐标系配置
    radar: {
      name: {
        textStyle: {
          color: "#05D5FF",
          fontSize: 14
        }
      },
      shape: 'polygon',
      center: ['50%', '50%'],
      radius: '80%',
      startAngle: 120,
      // 轴线
      axisLine: {
        lineStyle: {
          color: 'rgba(2,213,255,.8)'
        }
      },
      // 网格线
      splitLine: {
        show: true,
        lineStyle: {
          with: 1,
          color: 'rgba(5,213,255,.8)'
        }
      },
      // 指示器名称
      indicator:resData.map(item => ({
        name: item.name,
        max: 100
      })),
      splitArea: {
        show:false
      }
    },
    // 位置、极点
    polar: {
      center: ['50%', '50%'],
      radius:'0%'
    },
    // 坐标角度
    angleAxis: {
      min: 0,
      interval: 5,
      clockwise:false,//刻度逆时针
    },
    // 径向轴
    radiusAxis: {
      min: 0,
      interval: 20,
      splitLine: {
        show:true
      }
    },
    // 图表核心配置
    series: {
      type: 'radar',
      symbol: 'circle',
      symbolSize: 10,
      itemStyle: {
        normal: {
          color:'#05D5FF'
        }
      },
      areaStyle: {
        normal: {
          color: '#05D5FF',
          opacity:0.5
        }
      },
      lineStyle: {
        with: 2,
        color:'#05D5FF'
      },
      label: {
        normal: {
          show:true,
          color: '#05D5FF',
        }
      },
      data: [
        {
          value:resData.map(item=>item.value)
        }
      ]
    }
  }
  // 3.通过实例.setOptions(option)
  myChart.setOption(options);
};
watch(() => resData,renderChart)

</script>

<style lang="scss" scoped>

</style>

在这里插入图片描述

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值