在echarts中series里有个参数stack:
用于数据堆叠同个类目轴上,系列配置相同的stack,后一个系列的值会加在前一个系列之后,如图:
stack的使用
series部分代码:

series: [{
					type: 'bar',
					stack: 'Total1',
					itemStyle: {
						borderColor: 'transparent',
						color: 'transparent'
					},
					emphasis: {
						itemStyle: {
							borderColor: 'transparent',
							color: 'transparent'
						}
					},
					data: [43, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
				},
				{
					type: 'bar',
					stack: 'Tota1',
					label: {
						show: true,
						position: 'inside'
					},
					data: [580, 580, 100, 300, 500, 600, 200, 200, 300, 600, 600]
				},

				{
					type: 'bar',
					stack: 'Total2',
					itemStyle: {
						borderColor: 'transparent',
						color: 'transparent'
					},
					emphasis: {
						itemStyle: {
							borderColor: 'transparent',
							color: 'transparent'
						}
					},
					data: [40, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10]
				},
				{
					type: 'bar',
					stack: 'Total2',
					label: {
						show: true,
						position: 'inside'
					},
					data: [480, 560, 100, 300, 500, 650, 200, 200, 300, 400, 400]
				},

				{
					type: 'bar',
					stack: 'Total3',
					itemStyle: {
						borderColor: 'transparent',
						color: 'transparent'
					},
					emphasis: {
						itemStyle: {
							borderColor: 'transparent',
							color: 'transparent'
						}
					},
					data: [40, 20, 20, 50, 20, 20, 40, 10, 10, 10, 10]
				},
				{
					type: 'bar',
					stack: 'Total3',
					label: {
						show: true,
						position: 'inside'
					},
					data: [480, 560, 300, 300, 500, 650, 400, 200, 300, 400, 400]
				},

				{
					type: 'bar',
					stack: 'Total4',
					itemStyle: {
						borderColor: 'transparent',
						color: 'transparent'
					},
					emphasis: {
						itemStyle: {
							borderColor: 'transparent',
							color: 'transparent'
						}
					},
					data: [20, 10, 10, 20, 40, 20, 30, 10, 10, 10, 10]
				},
				{
					type: 'bar',
					stack: 'Total4',
					label: {
						show: true,
						position: 'inside'
					},
					data: [180, 660, 100, 200, 500, 550, 200, 200, 300, 400, 200]
				},

			]
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐