带时间轴的折线图echart

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>带时间轴的折线图</title>
		<script src="//cdn.bootcss.com/echarts/3.4.0/echarts.min.js"></script>
	</head>
	<body>
		<div id="chart" style="width: 100%;height: 500px;"></div>
		<script type="text/javascript">
			// 基于准备好的dom,初始化echarts实例
			var myChart = echarts.init(document.getElementById('chart'));
			// 指定图表的配置项和数据
			option = {
			    title : {
			        text: '带时间轴的折线图',
			        subtext: '带时间轴的折线图',
			        x: 'center',
			        align: 'right'
			    },
			    grid: {
			        bottom: 80
			    },
			    toolbox: {
			        feature: {
			            saveAsImage: {}
			        }
			    },
			    tooltip : {
			        trigger: 'axis',
			        axisPointer: {
			            animation: false
			        }
			    },
			    dataZoom: [
			        {
			            show: true,
			            realtime: true,
			            start: 65,
			            end: 85
			        },
			        {
			            type: 'inside',
			            realtime: true,
			            start: 65,
			            end: 85
			        }
			    ],
			    //x轴时间轴
			    xAxis : [
			        {
			            type : 'category',
			            data : [
			                '2009/6/12 2:00', '2009/6/12 3:00', '2009/6/12 4:00', '2009/6/12 5:00', '2009/6/12 6:00', '2009/6/12 7:00', '2009/6/12 8:00', '2009/6/12 9:00', '2009/6/12 10:00', '2009/6/12 11:00'
			            ].map(function (str) {
			                return str.replace(' ', '\n')
			            })
			        }
			    ],
			    yAxis: [
			        {
			            name: '流量(m^3/s)',
			            type: 'value'
			        }
			    ],
			    //y轴
			    series: [
			        {
			            name:'流量',
			            type:'line',
			            animation: false,
			            areaStyle: {
			                normal: {}
			            },
			            lineStyle: {
			                normal: {
			                    width: 1
			                }
			            },
			            data:[
			                100.97,20.96,300.96,40.95,300.95,20.94,50.94,360.94,80.94,100.94
			            ]
			        }
			    ]
			};
			// 使用刚指定的配置项和数据显示图表。
			myChart.setOption(option);
			//自适应
			window.onresize = myChart.resize;
		</script>
	</body>
</html>

效果图:


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值