let tableData = [{ value: 6170.400, name: "省内" }, { value: 1608.800, name: "省外" }] let option = { toolbox: { show: true, right: '0', feature: { mark: { show: true }, restore: { show: false }, saveAsImage: { show: true, pixelRatio: 1, title: '保存为图片', type: 'png', lang: ['点击保存'] } } }, grid: { }, title: { text: '总里程', right: "center", top: '10%', textStyle: { fontWeight: 500, fontSize: 16 } }, legend: { show: true, top: '60%', // bottom: '10%', left: 'center', textStyle: { fontSize: 12, }, formatter: (params) => { return params == '省内里程统计' ? params + ': ' + tableData[0].value + ' ' + '公里' : params + ': ' + tableData[1].value + ' ' + '公里' } }, color: ['#fc874b', '#fad336'], xAxis: { show: false, type: 'value', boundaryGap: [0, 0] }, yAxis: [ { type: 'category', data: [''], axisLine: { show: false }, axisTick: [{ show: false }] } ], series: [ { type: 'bar', name: tableData[0].name, stack: '总量', barWidth: 20, label: { show: true, position: 'inside', color: "#fff", formatter: '{c}%' }, showBackground: true, backgroundStyle: { color: '#fad336', borderRadius: 10, }, itemStyle: { barBorderRadius: [10, 10, 10, 10] }, data: [79.32] }, { type: 'bar', name: tableData[1].name, stack: '总量', barWidth: 20, label: { show: true, color: "#fff", position: 'inside', formatter: '{c}%' }, showBackground: true, backgroundStyle: { color: 'transparent', barBorderRadius: [10, 10, 10, 10], }, itemStyle: { color: '#fad336', barBorderRadius: [0, 10, 10, 0], }, silent: true, data: [20.68] } ] } console.log(option)