series数据下label里的显示文字标签show: true如果大于等于4位数怎么显示千位分隔符? tooltip下的鼠标悬停提示 echarts自带就有千位分割。
配置项如下
var option = {
tooltip: {},
xAxis: {
axisLabel: {
textStyle: { //坐标轴文字颜色
color: '#000'
}
},
axisLine: {
lineStyle: {
color: '#dee2e5' //坐标轴线颜色
}
},
splitLine: {
show: false
}, //是否显示分隔线
axisTick: {
show: false
}, //是否显示坐标轴刻度
data: ["本地", "本州", "全美"]
},
yAxis: {
type: 'value',
axisLine: {
lineStyle: { //坐标轴线颜色
color: '#dee2e5'
}
},
splitLine: {
show: false
}, //是否显示分隔线
axisTick: {
show: false
}, //是否显示坐标轴刻度
axisLabel: {
show: false
} //是否显示刻度标签
},
series: [{
name: '平均家庭收入',
type: 'bar',
barWidth: '40',
label: {
normal: {
show: true, //柱子上边显示文字标签
position: 'top',
formatter: function(param){
var char = param.value;
var chart = function (num) {
return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
};
return '$'+chart(char);
},
offset: [0, -5],
textStyle: {
fontSize: 16,
color: '#000',
fontWeight: 'bold'
}
}
},
data: [{
value: "120000",
itemStyle: { //柱子颜色
normal: {
color: '#00b8ee'
}
}
}, {
value: "50000",
itemStyle: {
normal: {
color: '#8fc320'
}
}
}, {
value: "30000",
itemStyle: {
normal: {
color: '#fe9e25'
}
}
}]
}]
}