Echarts柱状折线图

<html>
<head>
<style>
	#EcharBox {
		margin: 0 auto;
		width: 95%;
		height: 400px;
	}
</style>
</head>
<body>
     <div id="EcharBox"></div>
</body>
<script>
//分别传入三个数组
var planArr=[10,3,30,16];
var hadArr=[5,10,50,40];
var hadRate=[0.5,0.3,0.6,0.4];
function showEchartYear(planArr, hadArr,hadRate) {		   echarts.dispose(document.getElementById('EcharBox'));
		var option = {
			color: ['#00ad53', '#feb63e'],
			title: {
				x: 'center',
				text: "2017年度",
				textStyle: {
					color: '#444',
					fontStyle: 'normal',
					fontWeight: 'bold',
					fontFamily: 'sans-serif',
					fontSize: 18
				}
			},
		    tooltip: {
		        trigger: "axis",
		        axisPointer: {
		            type: "shadow",
		            textStyle: {
		                color: "#fff"
		            },
		        },
		        formatter: function (params, ticket, callback) {
					var str=""+params[0].name+"<br/>";
		        	for(var i=0;i<params.length;i++){
		        		str+='<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:'+params[i].color+'"></span>';
						str+=params[i].seriesName+":";
						if(typeof(params[i].value)=="undefined"){
							str+="-";
						}else{
							if(i==2){
								str+=params[i].value+"%";
							}else{
								str+=params[i].value;
							}
						}
						str+="<br/>"
					}
		        	return str;
		        } 
		    },
			grid: {
				left: 10,
				right: 70,
				bottom: 10,
				containLabel: true
			},
			xAxis: [
				{
					type: 'category',
					data: ['一季度', '二季度', '三季度', '四季度'],
					axisLabel: {
						interval: 0,   //横轴信息全部显示
						//rotate: -30,//-30度角倾斜显示
						textStyle: {
							color: '#666'
						}
					},
					axisLine: {
						lineStyle: {
							color: '#eaedf0'
						}
					}
				}
			],
			yAxis: [
				{
					name: '金额:(亿元)',
					type: 'value',
					nameTextStyle: {
						color: '#666',
					},
					axisLine: {
						lineStyle: {
							color: '#eaedf0'
						}
					},
					axisLabel: {
						textStyle: {
							color: '#666'
						}
					}
				},
				{
					type : 'value',
					name:'完成率%',
					nameTextStyle:{
						color:'#666',
					},
					splitLine: {
						show: false
					},
					axisLabel:{
						formatter:'{value}%',
						textStyle:{
							color:'#666'
						}
					},
					axisTick:{
						show:false
					},
					axisLine:{
						lineStyle:{
							color:'#eaedf0'
						}
					}
				}
			],
			legend: {
				x: 'right',
				y: 'center',
				orient: 'vertical',
				data: ['计划', '完成','完成率']
			},
			series: [
				{
					name: '计划',
					type: 'bar',
					data: planArr,
					itemStyle: {
						normal: {
							label: {
								show: true,
								position: 'top',
								textStyle: {
									fontSize: '14',
									fontFamily: '微软雅黑',
								},
							}
						}
					},
				},
				{
					name: '完成',
					type: 'bar',
					data: hadArr,
					itemStyle: {
						normal: {
							label: {
								show: true,
								position: 'top',
								textStyle: {
									fontSize: '14',
									fontFamily: '微软雅黑',
								}
							}
						}
					},
				},
				{
					name:'完成率',
					type:'line',
					yAxisIndex:1,
					data:hadRate,
					label:{
						normal:{
							show:true,
							position:'right',
							formatter: '{c}%',
							textStyle:{
								color:'#666'
							}
						}
					}
				}
			]
		};
		myChart = echarts.init(document.getElementById('EcharBox'));
		myChart.setOption(option);
	}
	</script>

宿雨眠云原创

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值