
功能介绍:百度echarts做一个pie饼状,想要在legend名称后面加上当前的值和百分比,并且每个文字标签宽带一致(如右图),下面web建站小编给大家简单介绍一下实现代码!
实现代码如下:
//myData图表数据
legend: {
bottom: '0',
left: 'center',
icon: "circle",
itemHeight: 6,
itemWidth: 6,
formatter: function(name) {
var total = 0
var value
for (var i = 0; i < myData.length; i++) {
total += myData[i].value
if (myData[i].name == name) {
// 获取对应值
value = myData[i].value
}
}
let percent = Math.round((tarValue / total) * 100) + '%' // 获取百分百(根据需要在下面添加)
var arr = ['{a|' + name + '}', '{b|' + value + '}']
return arr.join(' ')
},
textStyle: {
rich: {
a: { //设置名称宽度
width: 32
},
b: { //设置值的宽度
width: 65,
},
c:{
//.....一般值都可以设置
//fontSize: 15,
//color: '#c1c1c1'
}
}
},
}
百度echarts雷达图radar根据分数点显示每个不同颜色
百度echarts柱状图/折线图x轴显示全部文本(太长自动换行)
上面是“百度echarts饼状legend显示值和百分比”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2889.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

PHP语法检测HTTP_USER_AGENT请求头信息,判断当前设备类型
一款专注于提升美学以及出色的排版设计的AI图像生成模型——Reve Image
FoodiesFeed:一个专门提供各种好看的食物、食材、料理高清图片的图片网站
问小白o4:能同时启动8条思考路径,打字速度比DeepSeek R1提升70%