散点根据X轴的年月日+Y轴时分秒进行二维定位在坐标轴上,例如series的data:[[2017-11-01,08:45:01],[2017-11-01,08:45:01]]的数据;其中,X轴显示的数值是固定的11月份的30天,Y轴是每天的00:00:00到23:59:59。通过两个坐标轴对散点进行定位放置。求教大神
配置项如下
option = {
xAxis: {type : 'value',
scale:true,
axisLabel : {
formatter: function(ff){
var date = new Date(ff);//如果date为10位不需要乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var m = (date.getMinutes() <10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var s = (date.getSeconds() <10 ? '0' + date.getSeconds() : date.getSeconds());
return Y+M+D;
}
}
},
yAxis: {type : 'value',
scale:true,
axisLabel : {
formatter: function(ff){
var date = new Date(ff);//如果date为10位不需要乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var m = (date.getMinutes() <10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var s = (date.getSeconds() <10 ? '0' + date.getSeconds() : date.getSeconds());
return h+m+s;
}
}
},
series: [{
symbolSize: 20,
data: [
[2017-11-01,2017-11-01],
[2017-11-02,2017-11-02]
],
type: 'scatter'
}]
};