echarts绘制雷达图

慈云数据 8个月前 (03-12) 技术支持 114 0

  
云端报警风险】
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)

在这里插入图片描述

微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon