配置项如下
let legend = ["吸尘", "洒水", "洗扫"];
let yData = [
{ name: "宿州大道", text: "1标段" },
{ name: "宿州大道", text: "1标段" },
{ name: "宿州大道", text: "1标段" },
{ name: "宿州大道", text: "1标段" }
]
var disk = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYCAYAAABxlTA0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0NjczMjI5MjI3MjcxMUU4OTIzNUNGREYwREM2MEQ2RCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo0NjczMjI5MzI3MjcxMUU4OTIzNUNGREYwREM2MEQ2RCI+IDx4bXBNTTpEZXJpdmVkRnJ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VyWnRDl7n23vb6RyatnaDe46QJZlljuSc4E1I9Tmn5AfcEoALoD+VRVs00zmSw+UV7pk1EvcuswZrz50oykNYKEJ6GFsgnwXgi5GwBBoMQhLJUpnpnOzJgRwZILldRYsKsvbDJZakzuAVDeknaZYF0L6AQ+Z1L4C1dJ8E/jIur4o93usNcOnJV+VnFuf2QyWrCOYobf2DfWuAl7u59a/SrjV4qdt/AgwAnL2HNfAqKWsAAAAASUVORK5CYII='
let xDataFormat = yData.map((v, i) => {
// let color = i > 2 ? '#333333' : labelColor[i];
let item = {
value: `${v.name}**${v.text}`,
textStyle: {
rich: {
a: {
color: "#fff",
width: 64,
height: 17,
align: 'center',
backgroundStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 1, 1, [{
offset: 0,
color: '#3D9FFF'
}, {
offset: 1,
color: '#41D7F3'
}], false),
symbol: disk
},
verticalAlign: 'middle',
lineHeight: 30
},
b: {
},
value: {
align: 'center',
fontSize: 16,
color: 'rgba(2,247,253,1)'
}
}
}
}
return item;
})
option = {
backgroundColor: "#0f375f",
tooltip: {
trigger: "axis"
},
legend: {
show: false
},
barWidth: 10,
xAxis: {
type: "value",
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: { // 改变x轴颜色
show:false
},
axisLabel: { // 改变x轴字体颜色和大小
show: false
}
},
yAxis: {
type: "category",
data: xDataFormat,
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: { // 改变y轴颜色
show: false
},
axisLabel: { // 改变y轴字体颜色和大小
formatter: function(value) {
// console.log(value);
let valueArr = value.split("**");
console.log(value)
return '{value|' + valueArr[0] + '}{b|\n}{a|' + valueArr[1] + '}'
},
textStyle: {
color: "rgba(2,247,253,1)",
fontSize: 16
}
}
},
series: [{
type: "bar",
name: legend[0],
barGap: 1,
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: "right", //在上方显示
formatter: function(param) {
return `${param.seriesName} ${param.value}%`;
},
textStyle: { //数值样式
color: "rgba(255,255,255,1)",
fontSize: 12
}
},
color: "rgba(0,144,236,1)",
borderWidth: 0
}
},
data: [19, 29, 39, 81]
},
{
type: "bar",
name: legend[1],
barGap: 1,
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: "right", //在上方显示
formatter: function(param) {
return `${param.seriesName} ${param.value}%`;
},
textStyle: { //数值样式
color: "rgba(255,255,255,1)",
fontSize: 12
}
},
color: "rgba(255,229,38,1)",
borderWidth: 0
}
},
data: [12, 23, 35, 100]
},
{
type: "bar",
name: legend[2],
barGap: 1,
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: "right", //在上方显示
formatter: function(param) {
return `${param.seriesName} ${param.value}%`;
},
textStyle: { //数值样式
color: "rgba(255,255,255,1)",
fontSize: 12
}
},
color: "rgba(45,230,255,1)",
borderWidth: 0
}
},
data: [12, 23, 35, 100]
}
]
};