柱状图-无轴横向柱状图-自定义显示内容
效果图:
代码:
const data = [{ value: 498, name: '1号生产线' }, { value: 460, name: '2号生产线' }, { value: 421, name: '3号生产线' }, { value: 400, name: '4号生产线' }, { value: 396, name: '5号生产线' }, { value: 346, name: '6号生产线' }] const colorList = ['rgba(30,231,231,0.35)', '#D0E71E'] const update = () => { // 图表设置tooltip chart.setOption({ backgroundColor: "transparent", legend: { show: false }, xAxis: { show: false, }, grid: { left: '5%', top: '8%', width: '90%', height: '94%', }, yAxis: [ { triggerEvent: true, show: true, inverse: true, data: ['1号生产线', '3号生产线', '3号生产线', '4号生产线', '5号生产线', '6号生产线'], axisLine: { show: false, }, splitLine: { show: false, }, axisTick: { show: false, }, axisLabel: { interval: 0, inside: true, color: 'rgba(255, 255, 255, 0.85)', margin: 0, padding: [0, 0, 14, 0], align: 'left', verticalAlign: 'bottom', formatter: function (value, index) { return '{title|' + value + '}'; }, rich: { title: { width: 50, fontSize: 12, color: "rgba(255, 255, 255, 0.85)" }, }, }, }, { triggerEvent: true, show: true, inverse: true, data: ['1号生产线', '3号生产线', '3号生产线', '4号生产线', '5号生产线', '6号生产线'], axisLine: { show: false, }, splitLine: { show: false, }, axisTick: { show: false, }, axisLabel: { interval: 0, inside: true, color: 'rgba(255, 255, 255, 0.85)', margin: 0, padding: [0, 0, 14, 0], align: 'right', verticalAlign: 'bottom', formatter: function (value, index) { return '{title|' + data[index].value + '}{unit|/500}'; }, rich: { title: { fontSize: 16, color: "rgba(255, 255, 255, 1)" }, unit: { fontSize: 12, color: "rgba(255, 255, 255, 0.85)" }, }, }, }, ], series: [ { type: 'bar', showBackground: true, barMinWidth: '10', backgroundStyle: { color: 'rgba(255, 255, 255, 0.1)', }, yAxisIndex: 0, data: data, barWidth: 10, // align: left, itemStyle: { normal: { //颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上 color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ { offset: 0, color: colorList[0], }, { offset: 1, color: colorList[1], }, ]), }, }, label: { show: true, fontSize: 12, color: "#FFFFFF", position: "insideLeft", offset: [165, -14], formatter: function (params) { return '{unit|已完成:}{title|' + (((params.value) / 500) * 100).toFixed(1) + '}{unit|/%}'; }, rich: { title: { fontSize: 16, color: "rgba(255, 255, 255, 1)" }, unit: { fontSize: 12, color: "rgba(255, 255, 255, 0.85)" }, }, }, }, ], }) } setTimeout(update, 0)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了