我们在前面几个章节已经介绍了AQI雷达图和自定义雷达图,本章节我们重点介绍多雷达图的实现。
echarts 多雷达图实例
1,新建静态页面demo.html,并引入echarts的js库,在这里我们引入的是网络地址
<!-- V型知识库 www.vxzsk.com 原创--> <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script>
2,雷达图容器html代码,只需一行html代码
<div id="container" style="height: 500px"></div>
雷达图容器高度为500px,宽度默认,并且div的id号为container。
3,javascript实现代码
<script type="text/javascript"> var dom = document.getElementById("container"); var myChart = echarts.init(dom); var app = {}; app.title = 'v型知识库原创-www.vxzsk.com'; var option = null; option = { title: { text: '多雷达图' }, tooltip: { trigger: 'axis' }, legend: { x: 'center', data:['某软件','某主食手机','某水果手机','降水量','蒸发量'] }, radar: [ { indicator: [ {text: '品牌', max: 100}, {text: '内容', max: 100}, {text: '可用性', max: 100}, {text: '功能', max: 100} ], center: ['25%','40%'], radius: 80 }, { indicator: [ {text: '外观', max: 100}, {text: '拍照', max: 100}, {text: '系统', max: 100}, {text: '性能', max: 100}, {text: '屏幕', max: 100} ], radius: 80, center: ['50%','60%'], }, { indicator: (function (){ var res = []; for (var i = 1; i <= 12; i++) { res.push({text:i+'月',max:100}); } return res; })(), center: ['75%','40%'], radius: 80 } ], series: [ { type: 'radar', tooltip: { trigger: 'item' }, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data: [ { value: [60,73,85,40], name: '某软件' } ] }, { type: 'radar', radarIndex: 1, data: [ { value: [85, 90, 90, 95, 95], name: '某主食手机' }, { value: [95, 80, 95, 90, 93], name: '某水果手机' } ] }, { type: 'radar', radarIndex: 2, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data: [ { name: '降水量', value: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 75.6, 82.2, 48.7, 18.8, 6.0, 2.3], }, { name:'蒸发量', value:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 35.6, 62.2, 32.6, 20.0, 6.4, 3.3] } ] } ] };
4,用浏览器打开demo.html,效果如下
如上图所示,多个雷达图已经显示出来了。
5,多雷达图demo.html完整代码
<!DOCTYPE html> <head> <meta charset="utf-8"> </head> <body > <div id="container" style="height: 500px"></div> <!-- V型知识库 www.vxzsk.com --> <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script> <script type="text/javascript"> var dom = document.getElementById("container"); var myChart = echarts.init(dom); var app = {}; app.title = 'v型知识库原创-www.vxzsk.com'; var option = null; option = { title: { text: '多雷达图' }, tooltip: { trigger: 'axis' }, legend: { x: 'center', data:['某软件','某主食手机','某水果手机','降水量','蒸发量'] }, radar: [ { indicator: [ {text: '品牌', max: 100}, {text: '内容', max: 100}, {text: '可用性', max: 100}, {text: '功能', max: 100} ], center: ['25%','40%'], radius: 80 }, { indicator: [ {text: '外观', max: 100}, {text: '拍照', max: 100}, {text: '系统', max: 100}, {text: '性能', max: 100}, {text: '屏幕', max: 100} ], radius: 80, center: ['50%','60%'], }, { indicator: (function (){ var res = []; for (var i = 1; i <= 12; i++) { res.push({text:i+'月',max:100}); } return res; })(), center: ['75%','40%'], radius: 80 } ], series: [ { type: 'radar', tooltip: { trigger: 'item' }, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data: [ { value: [60,73,85,40], name: '某软件' } ] }, { type: 'radar', radarIndex: 1, data: [ { value: [85, 90, 90, 95, 95], name: '某主食手机' }, { value: [95, 80, 95, 90, 93], name: '某水果手机' } ] }, { type: 'radar', radarIndex: 2, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data: [ { name: '降水量', value: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 75.6, 82.2, 48.7, 18.8, 6.0, 2.3], }, { name:'蒸发量', value:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 35.6, 62.2, 32.6, 20.0, 6.4, 3.3] } ] } ] }; if (option && typeof option === "object") { myChart.setOption(option, true); } </script> </body> </html>
把上述代码复制到一个静态HTML页面中即可实现多雷达图效果。
此文章本站原创,地址 https://www.vxzsk.com/1153.html
转载请注明出处!谢谢!
感觉本站内容不错,读后有收获?小额赞助,鼓励网站分享出更好的教程
上一篇:echarts 自定义雷达图
下一篇:shiro 拦截器机制
^