直接贴代码,拿走不谢,别忘记点赞加关注
在这里插入代码片 option = { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, // color: '#FFD461' // color:'#FF2929' }, ] }, tooltip: { trigger: "item", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow" // 默认为直线,可选为:'line' | 'shadow' } }, grid: { top: '30px', left: "3%", right: "4%", bottom: "3%", containLabel: true }, backgroundColor: '#ffffff', xAxis: [{ type: "category", data: [ "总计", "同监督", "已完成", "进行中", "未启动" ], axisTick: { alignWithLabel: true }, splitArea: { show: false }, axisLine: { lineStyle: { color: "#fff" } }, axisLabel: { show: true, interval: 0, left:'10', formatter: function(params) { let newParamsName = ""; let paramsNameNumber = params.length; let provideNumber = 6; //一行显示几个字 let rowNumber = Math.ceil(paramsNameNumber / provideNumber); if (paramsNameNumber > provideNumber) { for (let p = 0; p < rowNumber; p++) { let tempStr = ""; let start = p * provideNumber; let end = start + provideNumber; if (p == rowNumber - 1) { tempStr = params.substring(start, paramsNameNumber); } else { tempStr = params.substring(start, end) + "\n"; } newParamsName += tempStr; } } else { newParamsName = params; } return newParamsName + ' 协同项'; }, textStyle: { color: "#000000", //文字颜色 fontSize:'16', } } }], yAxis: [{ min: 0, // max: 500, type: "value", axisLine: { show: false, onZero: false }, splitArea: { show: false }, axisTick: { show: false }, axisLabel: { show: false }, splitLine: { show: false, lineStyle: { type: "dashed", color: '#fff' } } }], series: [{ type: "bar", barWidth: "20", silent: true, data: [1,2,3,4,4], showBackground: true, roundCap:true, itemStyle: { normal: { barBorderRadius:[50, 50, 50, 50], color: function(params) { var colorList = ['#2264FF','#2264FF','#33C4B7','#579DFF','#FF6A59']; return colorList[params.dataIndex] } } }, label:{ show:true, position:'insideTop', color: '#ffffff' }, backgroundStyle: { color: '#ebf1ff', barBorderRadius:[50, 50, 50, 50], } },{ type: "bar", name:'协同项', barWidth: "20", barGap:'3', silent: true, data: [2,1,2,3,2], showBackground: true, roundCap:true, itemStyle: { normal: { barBorderRadius:[50, 50, 50, 50], color: function(params) { var colorList = ['#2264FF','#2264FF','#33C4B7','#579DFF','#FF6A59']; return colorList[params.dataIndex] } } }, label:{ show:true, position:'insideTop', color: '#ffffff', }, backgroundStyle: { color: '#ebf1ff', barBorderRadius:[50, 50, 50, 50], } }] };