const datas = [ { name: "增值税", value: "58", value1: "158111", value2: "82311" }, { name: "企业所得税", value: "76", value1: "16522", value2: "9873" }, { name: "个人所得税", value: "98", value1: "5823", value2: "5500" }, { name: "资源税", value: "77" , value1: "3244", value2: "2355" }, { name: "土地增值税", value: "85", value1: "15344", value2: "12009" }, { name: "契税", value: "96", value1: "16733", value2: "16570" }, { name: "消费税", value: "65", value1: "16555", value2: "9555" }, { name: "其他各税", value: "74", value1: "26655", value2: "19650" } ]; const xData = datas.map(item => item.value1); const yData = datas.map(item => item.name); const zData = datas.map(item => item.value2); const pData = datas.map(item => item.value); //const max = Math.ceil(Math.max(...yData) * 1.2); const max = 100; const maxData = [max, max, max, max, max, max, max, max, max, max];//控制左边名字显示的数量 option = { toolbox: { show: true, feature: { saveAsImage: { show: true, title: "保存图片", excludeComponents: ["toolbox"], pixelRatio: 1, backgroundColor: "#05233D", }, }, }, backgroundColor: "#0b1a2a", grid: { left: "10%", right: "25%", bottom: "10%", top: "10%", containLabel: false }, xAxis: [ { show: false }, { show: true, splitLine: { show: false } } ], yAxis: [ { show: true, data: yData, offset: 80, position: "right", axisLabel: { lineHeight: 0, verticalAlign: "bottom", fontSize: 14, color: "#e6a635", formatter: "{value}" }, axisLine: { show: false }, splitLine: { show: false }, axisTick: { show: false } }, { show: true, data: zData, offset: 5, position: "right", axisLabel: { lineHeight: 0, verticalAlign: "bottom", fontSize: 14, color: "#fff", formatter: "{value}" }, axisLine: { show: false }, splitLine: { show: false }, axisTick: { show: false } } ], series: [ { name: "进度", show: true, type: "bar", barGap: "-100%", xAxisIndex: 1, barWidth: 20, itemStyle: { borderRadius: 4, color: { type: 'linear', x: 0, y: 0, x2: 1, y2: 0, colorStops: [ { offset: 0, color: '#148BCE', // 0% 处的颜色 }, { offset: 1, color: '#73E3FF', // 0% 处的颜色 }, ], global: false, // 缺省为 false } }, label: { show: true, position: 'insideRight', formatter: '{c}%', offset: [-10, 2], color: '#fff' }, labelLine: { show: false }, z: 2, data: pData, animationDelay: 1000, animationDuration: 1000 }, // { // name: "外圆", // type: "scatter", // emphasis: { // scale: false // }, // xAxisIndex: 1, // symbolSize: 10, // itemStyle: { // color: "#f5d600", // shadowColor: "rgba(255, 255, 255, 0.5)", // shadowBlur: 5, // borderWidth: 1, // opacity: 1 // }, // z: 2, // data: pData, // animationDelay: 1500, // animationDuration: 1000 // }, { name: "百分比", z: 1, show: true, type: "bar", xAxisIndex: 1, barGap: "-100%", barWidth: 20, itemStyle: { borderRadius: 4, color: "rgba(13, 55, 78, 1)" }, label: { show: true, verticalAlign: "middle", position: "left", fontSize: 14, color: "#fff", formatter: function (data) { return xData[data.dataIndex]; } }, data: maxData } ] };