代码如下:(角度需要自己计算,如果是百分百的圆就不需要averagenum,直接写值就可以了)
function mychart3() {
var averagenum=50.22;
myChart3=echarts.init(document.getElementById('profitIncome')); option = { var pass_rate = 70,average = averagenum*0.7,total = 100; // 360*70%=252度数 252/360=0.7 let option = { series: [ { name:'通过率'+pass_rate+'%', type:'pie', radius: ['52%', '54%'], //禁止鼠标悬停放大 hoverAnimation: false, silent: true, //环的位置 label: { show: false, position: 'center', }, labelLine: { normal: { show: false } }, data:[ { value:pass_rate, //需要显示的数据 // name: '通过率'+pass_rate+'%', itemStyle: { normal: { color:'#008AD4', } } }, { value:total-pass_rate, //不需要显示的数据,颜色设置成和背景一样 itemStyle: { normal: { color: 'transparent' } } } ] }, { name:'平均值'+average+'%', type:'pie', // roundCap: true, radius: ['48%', '52%'], hoverAnimation: false, silent: true, label: { show: false, position: 'center', }, labelLine: { normal: { show: false } }, data:[ { // name:'平均值'+average+'%', value:average, itemStyle: { normal: { color: { // 完成的圆环的颜色 colorStops: [ { offset: 0, color: "#2449F3" // 0% 处的颜色 }, { offset: 1, color: "#7493F8" // 100% 处的颜色 } ] }, } } }, { value:total-average, itemStyle: { normal: { color: 'transparent' } } } ], }, ] }; } myChart3.setOption(option); }