app.title = '世界人口总量 - 条形图';
option = {
title: {
text: '世界人口总量',
subtext: '数据来自网络'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: params => {
if (params) {
return `12<span style="color: #f00">34</span>56`;
} else {
return '22';
}
},
},
legend: {
data: ['2011年', '2012年']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01],
},
yAxis: {
type: 'category',
data: ['巴西','印尼','美国','印度','中国','世界人口(万)'],
axisLabel:{
formatter: params => {
if (params) {
return `12<span style="color: #f00">34</span>56`;
} else {
return '22';
}
},
}
},
series: [
{
name: '2011年',
type: 'bar',
data: [18203, 23489, 29034, 104970, 131744, 630230],
itemStyle: {
normal: {
label: {
show: true,
position:'right',
formatter: params => {
if (params) {
return `12<span style="color: #f00">34</span>56`;
} else {
return '78';
}
},
}
}
}
},
{
name: '2012年',
type: 'bar',
data: [19325, 23438, 31000, 121594, 134141, 681807]
}
]
};
echarts 富文本标签
于 2018-08-17 10:30:54 首次发布