echarts实现环形图
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | //来自一个大佬的恩赐var pass_rate = 70,average = 60,total = 100; option = { tooltip: { show:false, trigger: 'item', formatter: "{a} : {c} ({d}%)" }, // color: ['#85b6b2', '#6d4f8d'], color: ['rgb(255,159,127)', 'rgb(50,197,233)'], legend: { orient: 'vertical', x: '35%', top:'27%', itemHeight: 10,//图例的高度 itemGap:8,//图例之间的间距 data:['通过率'+pass_rate+'%','平均值'+average+'%'] //图例的名字需要和饼图的name一致,才会显示图例 }, series: [ { name:'通过率'+pass_rate+'%', type:'pie', radius: ['40%', '45%'], //环的位置 label: { show: false, position: 'center', // normal: { // 显示的位置 // position: 'inner' // } }, labelLine: { normal: { show: false } }, emphasis: { label: { show: true, fontSize: '20', fontWeight: 'bold' } }, data:[ { value:pass_rate, //需要显示的数据 name: '通过率'+pass_rate+'%', itemStyle: { normal: { color: 'rgb(255,159,127)' } } }, { value:total-pass_rate, //不需要显示的数据,颜色设置成和背景一样 itemStyle: { normal: { color: 'transparent' } } } ] }, { name:'平均值'+average+'%', type:'pie', radius: ['30%', '35%'], label: { show: false, position: 'center', // normal: { // position: 'inner' // } }, labelLine: { normal: { show: false } }, emphasis: { label: { show: true, fontSize: '20', fontWeight: 'bold' } }, data:[ { name:'平均值'+average+'%', value:average, itemStyle: { normal: { color: 'rgb(50,197,233)' } } }, { value:total-average, itemStyle: { normal: { color: 'transparent' } } } ] } ] }; |
样式图例:
努力到无能为力,拼搏到感动自己。
欢迎大家在下方多多评论。
分类:
框架之vue,react
, echarts
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了