<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js"></script>
<meta name="viewport" content="user-scalable=no,width=device-width,height=device-height">
</head>
<body>
<style>
html, body, #main {
width: 100%;
height: 100%;
margin: 0;
}
</style>
<div id="main"></div>
<script>
//用的是15min的x坐标
var time15 = ['00:00:00', '00:15:00', '00:30:00', '00:45:00', '01:00:00', '01:15:00', '01:30:00', '01:45:00', '02:00:00', '02:15:00', '02:30:00', '02:45:00', '03:00:00', '03:15:00', '03:30:00', '03:45:00', '04:00:00', '04:15:00', '04:30:00', '04:45:00', '05:00:00', '05:15:00', '05:30:00', '05:45:00', '06:00:00', '06:15:00', '06:30:00', '06:45:00', '07:00:00', '07:15:00', '07:30:00', '07:45:00', '08:00:00', '08:15:00', '08:30:00', '08:45:00', '09:00:00', '09:15:00', '09:30:00', '09:45:00', '10:00:00', '10:15:00', '10:30:00', '10:45:00', '11:00:00', '11:15:00', '11:30:00', '11:45:00', '12:00:00', '12:15:00', '12:30:00', '12:45:00', '13:00:00', '13:15:00', '13:30:00', '13:45:00', '14:00:00', '14:15:00', '14:30:00', '14:45:00', '15:00:00', '15:15:00', '15:30:00', '15:45:00', '16:00:00', '16:15:00', '16:30:00', '16:45:00', '17:00:00', '17:15:00', '17:30:00', '17:45:00', '18:00:00', '18:15:00', '18:30:00', '18:45:00', '19:00:00', '19:15:00', '19:30:00', '19:45:00', '20:00:00', '20:15:00', '20:30:00', '20:45:00', '21:00:00', '21:15:00', '21:30:00', '21:45:00', '22:00:00', '22:15:00', '22:30:00', '22:45:00', '23:00:00', '23:15:00', '23:30:00', '23:45:00'];
var time30 = ['00:00:00', '00:30:00', '01:00:00', '01:30:00', '02:00:00', '02:30:00', '03:00:00', '03:30:00', '04:00:00', '04:30:00', '05:00:00', '05:30:00', '06:00:00', '06:30:00', '07:00:00', '07:30:00', '08:00:00', '08:30:00', '09:00:00', '09:30:00', '10:00:00', '10:30:00', '11:00:00', '11:30:00', '12:00:00', '12:30:00', '13:00:00', '13:30:00', '14:00:00', '14:30:00', '15:00:00', '15:30:00', '16:00:00', '16:30:00', '17:00:00', '17:30:00', '18:00:00', '18:30:00', '19:00:00', '19:30:00', '20:00:00', '20:30:00', '21:00:00', '21:30:00', '22:00:00', '22:30:00', '23:00:00', '23:30:00'];
var time60 = ['00:00:00', '01:00:00', '02:00:00', '03:00:00', '04:00:00', '05:00:00', '06:00:00', '07:00:00', '08:00:00', '09:00:00', '10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00', '15:00:00', '16:00:00', '17:00:00', '18:00:00', '19:00:00', '20:00:00', '21:00:00', '22:00:00', '23:00:00'];
var ttime = ['00:00', '00:15', '00:30', '00:45', '01:00', '01:15', '01:30', '01:45', '02:00', '02:15', '02:30', '02:45', '03:00', '03:15', '03:30', '03:45', '04:00', '04:15', '04:30', '04:45', '05:00', '05:15', '05:30', '05:45', '06:00', '06:15', '06:30', '06:45', '07:00', '07:15', '07:30', '07:45', '08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30', '10:45', '11:00', '11:15', '11:30', '11:45', '12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30', '13:45', '14:00', '14:15', '14:30', '14:45', '15:00', '15:15', '15:30', '15:45', '16:00', '16:15', '16:30', '16:45', '17:00', '17:15', '17:30', '17:45', '18:00', '18:15', '18:30', '18:45', '19:00', '19:15', '19:30', '19:45', '20:00', '20:15', '20:30', '20:45', '21:00', '21:15', '21:30', '21:45', '22:00', '22:15', '22:30', '22:45', '23:00', '23:15', '23:30', '23:45'];
var bigtitle = '站点A的车流量(统计间隔:15min)';
var yname = '车流量(辆/15min)';
var thetime = time15;//x坐标的时间
var maxvalue = 1500;//y的最大值
// 分段数据datas
var datas = [[276, 238, 212, 230, 162, 149, 131, 140, 126, 88, 96, 82, 79, 70, 75, 72, 61, 76, 88, 83, 99, 131, 160, 231, 353, 468, 707, 948, 987, 1064, 961, 967, 969, 1108, 1092, 1074, 944, 893, 924, 923, 996, 979, 900, 912, 875, 909, 832, 829, 774, 743, 735, 776, 868, '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'] , ['-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 868, 989, 942, 922, 769, 819, 802, 797, 1170, 1060, 1004, 995, 1039, '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'] , ['-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 1039, 998, 1036, 1060, 1077, 1128, 1124, 1078, 1093, 1072, 1024, 842, 815, 768, 684, 735, 733, 661, 737, 653, 634, 629, 663, 490, 555, 485, 425, 365, 327, 320, 292, 246]];
// 分段时间点
var div = ['16:00:00','13:00:00','23:45:00'];
var lw = 3 //线条的粗细
var chart = echarts.init(document.getElementById('main'));
var sampling = 'none';
chart.setOption({
title : {
padding:40,
text: bigtitle,
// subtext: '2019年4月1日',
x: 'center',
textStyle:{
fontSize:40
}
},
tooltip : {
trigger: 'axis',
formatter: function(params) {
return params[0].name + '<br/>'
+ (
params[0]
? params[0].seriesName + ' : ' + params[0].value + ' (辆/15min)<br/>'
: ''
);
},
axisPointer: {
animation: false
}
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: true},
saveAsImage : {show: true}
}
},
textStyle:{fontSize:20},
grid:{left:'10%',top:'15%'},
xAxis : [
{
type : 'category',
boundaryGap : false,
axisLine: {onZero: false},
axisLabel:{fontSize:15},
data : thetime
}
],
yAxis : [
{
name : yname,
type : 'value',
axisLabel:{fontSize:20},
max : maxvalue
}
],
series : [
{
name:'流量',
type:'line',
notShowSymbol: true,
// sampling: sampling,
smooth:true,
hoverAnimation: false,
lineStyle:{type:'solid',width:lw},
markArea: {
silent: true,
data: [[{
// name: 'a',
xAxis: '00:00'
// xAxis: 1
}, {
// name: 'b',
xAxis: div[1]
// xAxis: 5
}]],
itemStyle:{color:'rgba(0,255,0,0.2)'}
},
data:datas[0]
},
{
name:'流量',
type:'line',
notShowSymbol: true,
// sampling: sampling,
smooth:true,
hoverAnimation: false,
lineStyle:{type:'dashed',width:lw},
markArea: {
silent: true,
data: [[{
// name: 'a',
xAxis: div[1]
// xAxis: 1
}, {
// name: 'b',
xAxis: div[0]
// xAxis: 5
}]],
itemStyle:{color:'rgba( 135,206,250,0.2)'}
},
data:datas[1]
},
{
name:'流量',
type:'line',
notShowSymbol: true,
// sampling: sampling,
smooth:true,
hoverAnimation: false,
lineStyle:{type:'dotted',width:lw},
markArea: {
silent: true,
data: [[{
// name: 'a',
xAxis: div[0]
// xAxis: 1
}, {
// name: 'b',
xAxis: div[2]
// xAxis: 5
}]],
itemStyle:{color:'rgba( 0,0,255,0.2)'}
},
data:datas[2]
},
]
});
</script>
</body>
</html>