有一个日期范围,例如.2013-07-01到2013-07-18。我想显示两个日期之间的日期。我还设置了min = 2013-07-01,max = 2013 -07-18,tickInterval = 7天。但是X轴将是2013-07-01,2013-07-08,2013-07-15,2013-07-22。我只想显示数据直到2013- 07-18。我可以做一些事情让X轴成为2013-07-01,2013-07-08,2013-07-15,2013-07-18 ?????非常感谢..
答案 0 :(得分:0)
如果您的刻度永远不会改变,您可以告诉jqplot使用一个字符串数组作为刻度标签:
var xTicks = ['2013-07-01', '2013-07-08', '2013-07-15', '2013-07-18'];
$.jqplot('chart1', [myData], {
axes: {
xaxis: {
renderer:$.jqplot.DateAxisRenderer,
rendererOptions:{
tickRenderer:$.jqplot.CanvasAxisTickRenderer
},
ticks: xTicks,
tickOptions: {
angle: -90,
formatString: '%d/%m/%Y %H:%M'
},
}
}
});
请参阅工作jsFiddle here
修改强>
更新了jsFiddle,用于为包含2013-07-01至2013-07-18期间所有日期的数组xDates制作xTicks here
var dates = [
'2013-07-01','2013-07-02','2013-07-03','2013-07-04',
'2013-07-05','2013-07-06','2013-07-07','2013-07-08',
'2013-07-09','2013-07-10','2013-07-11','2013-07-12',
'2013-07-13','2013-07-14','2013-07-15','2013-07-16',
'2013-07-17','2013-07-18',
];
var nbWeeks = Math.floor(dates.length/7);
var xTicks = [];
xTicks.push(dates[0]);
for(var i = 1; i<=nbWeeks; i++)
xTicks.push(dates[i*7]);
xTicks.push(dates[dates.length-1]);