var arr = [44.6,38.4,8.1,6.3,1.5,0.8] option = { title: { text: "阶梯瀑布图", }, tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, formatter: function (params) { var tar; if (params[1].value != "-") { tar = params[1]; } else { tar = params[0]; } return tar.name + "<br/>" + tar.seriesName + " : " + tar.value; }, }, legend: { data: ["支出", "收入"], }, grid: { left: "3%", right: "4%", bottom: "3%", containLabel: true, }, xAxis: { type: "category", splitLine: { show: false }, data: (function () { var list = []; for (var i = 1; i <= 9; i++) { list.push("11月" + i + "日"); } return list; })(), }, yAxis: { type: "value", }, series: [ { name: "辅助", type: "bar", stack: "总量", itemStyle: { normal: { barBorderColor: "rgba(0,0,0,0)", color: "rgba(0,0,0,0)", }, emphasis: { barBorderColor: "rgba(0,0,0,0)", color: "rgba(0,0,0,0)", }, }, data: [0, 2688.3, 2070.2, 1938.8, 1837, 1811.3, 1798.3, 1798.3, 0], }, { name: "收入", type: "bar", stack: "总量", label: { normal: { show: true, position: "top", }, }, data: [3406.3, "-", "-", "-", "-", "-", "-", 0, 1798], }, { name: "支出", type: "bar", stack: "总量", label: { normal: { show: true, position: "bottom", formatter: function (value) { console.log(value) return '-'+value.value; }, }, }, data: ["-", 718, 618.1, 131.4, 101.8, 25.7, 13, "-", "-"], }, { name: "", type: "bar", stack: "总量", label: { normal: { show: true, position: "top", formatter: function (value) { console.log(value) return arr[value.dataIndex-1]+'%'; }, }, }, data: ["-", 0,0,0,0,0,0, "-", "-"], }, ], };