highcharts 以时间为x轴的图表
先上一张效果图
直接上代码
function graph(data) {
$('#container').highcharts({
global:{
useUTC:false
},
chart: {
type: 'spline'
},
credits:{
enabled:false
},
title: {
text: ''
},
xAxis: {
type: 'datetime', //以时间为x轴
dateTimeLabelFormats: {
day: '%H:%M' //显示的时间格式,百度dateTimeLabelFormats可以找到更多格式
}
},
yAxis: {
title: {
text: ''
},
min:0,
labels : { formatter:function (){ return this.value + 'Gbps(y轴单位)' ; } }
},
tooltip: {
valueSuffix: 'Gbps(y轴单位)'
},
plotOptions: {
spline: {
lineWidth: 2,
states: {
hover: {
lineWidth: 3
}
},
marker: {
enabled: false
}
}
},
series: [
{
name:'Traffic_Flood(折现图名称1)',
pointInterval:'30000(30s,x轴时间间隔,以毫秒为单位)',
pointStart:Date.UTC('2018(年)','10(月)','26(日)','12(时)','30(分)','30(秒)'),(开始时间)
pointEnd:Date.UTC('2018(年)','10(月)','26(日)','12(时)','40(分)','30(秒)'),(结束时间)
data:[1,2,3,4,5,……,19,20] //y轴数据,例如1对应2018.10.26.12.30.30,20对应2018.10.26.12.40.30
},
{
name:'Traffic_Flood(折现图名称2)',
pointInterval:'30000(30s,x轴时间间隔,以毫秒为单位)',
pointStart:Date.UTC('2018(年)','10(月)','26(日)','12(时)','30(分)','30(秒)'),
pointEnd:Date.UTC('2018(年)','10(月)','26(日)','12(时)','40(分)','30(秒)'),
data:[1,2,3,4,5,……,19,20] //y轴数据,例如1对应2018.10.26.12.30.30,20对应2018.10.26.12.40.30
},……
]
});
}