Echarts 堆叠柱形图如何添加总计
1.通过stack产生并行的柱形图
2.利用 bargap 调整两条柱形图的重叠
3.使用 label 的 noraml 中 position 将总计展示在 right (top / left 亦可)
4.总计的数据
横向竖向堆叠柱形图都可使用
series: [{name: 'Direct',type: 'bar',stack: 'total',emphasis: {focus: 'series'},data: [320, 302, 301, 334, 390, 330, 320]},{name: 'Mail Ad',type: 'bar',stack: 'total',emphasis: {focus: 'series'},data: [120, 132, 101, 134, 90, 230, 210]},{name: 'Affiliate Ad',type: 'bar',stack: 'total',emphasis: {focus: 'series'},data: [220, 182, 191, 234, 290, 330, 310]},{name: 'Video Ad',type: 'bar',stack: 'total',emphasis: {focus: 'series'},data: [150, 212, 201, 154, 190, 330, 410]},{name: 'Search Engine',type: 'bar',stack: 'total',emphasis: {focus: 'series'},data: [820, 832, 901, 934, 1290, 1330, 1320]},//重点在这,另起一个stack类型的数据,他们会产生一个并行的柱图{name: '总计',type: 'bar',stack: '',label: {show: true,normal: {show: true,position: 'right',color: '#000'},},//将层级设置为负数,确保总计的柱形图不影响原堆叠图z:-3,//不同系列的柱间距离,为百分比,如果想要两个系列的柱子重叠,可以设置 barGap 为 '-100%'。barGap: '-100%',emphasis: {focus: 'series'},//数据的综合data: [11111, 832, 901, 934, 1290, 1330, 1320]}]