1
我想绘制一个图形,其中x轴是日期,y轴是时间(以小时为单位)。如何使用JQPlot在图上绘制水平线其中Y轴在时间范围内
这是
var line3 = [['02/01/2012 00:00:00', '02/01/2012 01:00:00'], ['02/02/2012 00:00:00', '02/01/2012 06:00:00'], ['02/03/2012 00:00:00', '02/01/2012 06:00:00'], ['02/04/2012 00:00:00', '02/01/2012 06:00:00']];
var plot2 = $.jqplot('chart1', [line3], {
title:'Mouse Cursor Tracking',
axes:{
xaxis:{
min:'2012-02-01',
max:'2012-02-10',
Label: 'Day',
renderer:$.jqplot.DateAxisRenderer,
tickOptions:{
formatString:'%b %#d'
},
tickInterval:'1 day'
},
yaxis:{
min:'2012-02-01 00:00:00',
max:'2012-02-01 24:00:00',
Label: 'Time',
renderer:$.jqplot.DateAxisRenderer,
tickOptions:{
formatString:'%H'
},
tickInterval:'2 hour'
}
},
highlighter: {
show: false
},
cursor: {
show: true,
tooltipLocation:'sw'
},
canvasOverlay: {
show: true,
objects: [
{horizontalLine: {
name: 'pebbles',
y: '2012-02-01 05:00:00',
lineWidth: 3,
color: 'rgb(100, 55, 124)',
shadow: true,
lineCap: 'butt',
xOffset: 0
}}
]
}
});
我想画一条线,其中y = 05:00小时的代码。这不起作用。
你以前遇到过这个问题吗?任何形式的输入都会很棒。
Kryptic,谢谢你的帮助。它确实画了一条线。我想知道有没有办法将日期转换为一个值,这将帮助我做到这一点。我想通过我的代码动态地做到这一点。 – pramodh 2012-02-10 17:35:33
@pramodh当然,我编辑了这个答案,包括这一点。它应该完成你想要的。 – Kryptic 2012-02-10 20:39:35
非常感谢。是的,它像一个魅力! – pramodh 2012-02-10 21:55:04