多个echarts图叠加

多个echarts图叠加

多个图叠加在一起

在这里插入图片描述
代码如下:

option = {
	tooltip: {
		trigger: 'axis',
		axisPointer: {
			type: 'cross',
			crossStyle: {
				color: '#999'
			}
		}
	},
	toolbox: {
		feature: {
			dataView: {show: true, readOnly: false},
			magicType: {show: true, type: ['line', 'bar']},
			restore: {show: true},
			saveAsImage: {show: true}
		}
	},
	color: ['#D38267', '#333333', 'red', 'blue','#8435DE','green','#3B99FB','#999999'],
	//有几个图,就有几个grid,从上往下排
	grid: [
		{x: '7%', y: '7%', height: '20%', left: '10%'},
		{x: '7%', y2: '7%', height: '20%', left: '10%', bottom: '53%'},
		{x: '7%', y2: '7%', height: '20%', left: '10%', bottom: '33%'},
		{x: '7%', y2: '7%', height: '20%', left: '10%', bottom: '13%'}
	],
	legend: {
		data:['PM₂.₅','PM₁₀','SO₂','NO₂','CO','O₃','AQI','AQI1']
	},
	xAxis: [
		{
			type: 'category',//PM2.5和PM10 X轴
			gridIndex: 0,//对应grid的索引位置(第1个)
			axisTick: {
				alignWithLabel: true,
				show:false
			},
			axisLabel: {
				show:false
			},
			data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		},
		{
			type: 'category',//SO2 和NO2 X轴
			gridIndex: 1,//对应grid的索引位置(第2个)
			axisTick: {
				alignWithLabel: true,
				show:false
			},
			axisLabel: {
				show:false
			},
			data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],

		},
		{
			type: 'category',//CO和O3 X轴
			gridIndex: 2,//对应grid的索引位置(第3个)
			axisTick: {
				alignWithLabel: true,
				show:false
			},
			axisLabel: {
				show:false
			},
			data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		},
		{
			type: 'category',//AQI X轴
			gridIndex: 3,//对应grid的索引位置(第4个)
			axisTick: {
				alignWithLabel: true
			},
			axisLabel: {
				//interval:showNum,
			},
			data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],

		}
	],
	//y轴
   
	yAxis: [
		{
			type: 'value',
			gridIndex: 0,//对应grid的索引位置(第1个)
			name: 'PM₂.₅(μg/m³)',
			nameTextStyle: {
				padding: 25
			},
			position: 'left',
			nameLocation: 'middle',
			splitLine: {show: false},
			axisLine: {
				lineStyle: {
					//color: '#f8f106'
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false,
				textStyle: {
					fontSize: 12//y轴坐标轴上的字体大小
				}
			},
		}, {
			type: 'value',
			gridIndex: 0,//对应grid的索引位置(第1个)
			name: 'PM₁₀(μg/m³)',
			nameTextStyle: {
				padding: 25
			},
			nameLocation: 'middle',
			position: 'right',
			splitLine: {show: false},
			axisLine: {
				lineStyle: {
					
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false,
				textStyle: {
					fontSize: 12//y轴坐标轴上的字体大小
				}
			}
		 },
		  
		  
		  
		{
			type: 'value',
			gridIndex: 1,//对应grid的索引位置(第2个)
			nameLocation: 'middle',
			name: 'SO₂(μg/m³)',
			nameTextStyle: {
				padding: 25
			},
			splitLine: {show: false},
			position: 'left',
			axisLine: {
				lineStyle: {
					
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false,
			}
		},{
			type: 'value',
			gridIndex: 1,//对应grid的索引位置(第2个)
			name: 'NO₂(μg/m³)',
			//nameLocation:'end',
			splitLine: {show: false},
			nameLocation: 'middle',
			nameTextStyle: {
				padding: 25
			},
			position: 'right',
			axisLine: {
				lineStyle: {
					
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false
			}
		},
		  
		  
		{
			type: 'value',
			gridIndex: 2,//对应grid的索引位置(第3个)
			name: 'CO(μg/m³)',
			nameTextStyle: {
				padding: 25
			},
			position: 'left',
			nameLocation: 'middle',
			splitLine: {show: false},
			axisLine: {
				lineStyle: {
					//color: '#f8f106'
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false,
				textStyle: {
					fontSize: 12//y轴坐标轴上的字体大小
				}
			},
		 }, {
			type: 'value',
			gridIndex: 2,//对应grid的索引位置(第3个)
			name: 'O₃(μg/m³)',
			nameTextStyle: {
				padding: 25
			},
			nameLocation: 'middle',
			position: 'right',
			splitLine: {show: false},
			axisLine: {
				lineStyle: {
					//color: colors[1]
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false,
				textStyle: {
					fontSize: 12//y轴坐标轴上的字体大小
				}
			}
		},
		  
		  
		{
			type: 'value',
			gridIndex: 3,//对应grid的索引位置(第4个)
			name: 'AQI(μg/m³)',
			nameTextStyle: {
				padding: 25
			},
			nameLocation: 'middle',
			position: 'left',
			splitLine: {show: false},
			axisLine: {
				lineStyle: {
					//color: colors[1]
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false,
				textStyle: {
					fontSize: 12//y轴坐标轴上的字体大小
				}
			}
		},
		{
			type: 'value',
			gridIndex: 3,//对应grid的索引位置(第4个)
			name: 'AQI(μg/m³)',
			nameTextStyle: {
				padding: 25
			},
			nameLocation: 'middle',
			position: 'right',
			splitLine: {show: false},
			axisLine: {
				lineStyle: {
					//color: colors[1]
				}
			},
			axisLabel: {
				formatter: '{value}',
				showMaxLabel: false,
				textStyle: {
					fontSize: 12//y轴坐标轴上的字体大小
				}
			}
		}
	],
	series: [
		{
			name:'PM₂.₅',
			type:'line',
			smooth:true,
			xAxisIndex: 0,//对应grid的索引位置(第1个)
			yAxisIndex: 0,//对应yAxis的索引位置(第1个)
			data:[200.0, 40.9, 70.0, 103.2, 55.6, 76.7, 100.6, 120.2, 150.6, 200.0, 60.4, 30.3]
		},
		{
			name:'PM₁₀',
			type: "line",
			smooth:true,
			xAxisIndex: 0,//对应grid的索引位置(第1个)
			yAxisIndex: 1,//对应yAxis的索引位置(第2个)
			data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
		},
		
		
		{
			name:'SO₂',
			type:'line',
			smooth:true,
			xAxisIndex: 1,//对应grid的索引位置(第2个)
			yAxisIndex: 2,//对应yAxis的索引位置(第3个)
			data:[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
		},
		{
			name:'NO₂',
			type:'line',
			smooth:true,
			xAxisIndex: 1,//对应grid的索引位置(第2个)
			yAxisIndex: 3,//对应yAxis的索引位置(第4个)
			data:[220.0, 20.2, 30.3, 14.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
		},
		
		 
		{
			name:'CO',
			type:'line',
			smooth:true,
			xAxisIndex: 2,//对应grid的索引位置(第3个)
			yAxisIndex: 4,//对应yAxis的索引位置(第5个)
			data:[20.0, 40.9, 70.0, 103.2, 55.6, 76.7, 100.6, 120.2, 150.6, 200.0, 60.4, 30.3]
		},
		{
			name:'O₃',
			type: "line",
			smooth:true,
			xAxisIndex: 2,//对应grid的索引位置(第3个)
			yAxisIndex: 5,//对应yAxis的索引位置(第6个)
			data:[201.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
		},
		
		
		{
			name:'AQI',
			type: "line",
			smooth:true,
			xAxisIndex: 3,//对应grid的索引位置(第4个)
			yAxisIndex: 6,//对应yAxis的索引位置(第7个)
			data:[21.6, 5.9, 90.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
		},
		{
			name:'AQI',
			type: "line",
			smooth:true,
			xAxisIndex: 3,//对应grid的索引位置(第4个)
			yAxisIndex: 7,//对应yAxis的索引位置(第8个)
			tooltip: {
				show : false//设置提示框不显示
			},
			data:[21.6, 5.9, 90.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
		}
	]
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值