配置项如下
// res = {
// "name": ["选项A", "选项B", "选项C", "选项D"],
// "data": [40, 5, 5, 4],
// "ratio": [2, 5, 5, 4]}
res = [
{name: '选项A', value: 40,ratio: 2},
{name: '选项b', value: 5,ratio: 20},
{name: '选项c', value: 5,ratio: 2},
];
option = {
title: {
text: '{a|富文本确实定义了,说好的变宽呢}',
textStyle: {
align: 'center',
width: '1000000',
height: '10000',
rich: {
a: {color: 'red'}
}
},
// backgroundColor: 'yellow'
},
xAxis: {
},
yAxis: {
type: 'category'
},
dataset: {
source: res
},
series: [{
type: 'bar',
label: {
// align: 'left',
position: 'right',
show: true,
formatter:function(params) {
const {value} = params
return value.value + '占比' + value.ratio+ '%'
}
},
}]
};