jqPlot每小时图

时间:2012-06-04 16:59:50

标签: jquery graph jqplot

我希望jqPlot与此类似,http://www.jqplot.com/deploy/dist/examples/date-axes.html

但是我想每小时做一次。我有2个星期的数据,我想每小时显示一次,并希望x轴显示有点像这样:

8am 9am 10am ... 11pm   12am 1am 2am 3am ...  
|----June 1, 2012----| |----June 2, 2012----|

有办法做到这一点吗?

对该示例进行天真修改的问题是,即使使用少量数据,x轴标签也变得不可读。

Axis Overwrite

天真的代码修改:

$(document).ready(function(){
  var line1=[... data snipped...];
  var plot2 = $.jqplot('chart2', [line1], {
      title:'Customized Date Axis', 
      axes:{
        xaxis:{
          renderer:$.jqplot.DateAxisRenderer, 
          tickOptions:{formatString:'%b %#d, %#I %p'},
          min:'June 1, 2012 8:00AM', 
          tickInterval:'1 hour'
        }
      },
      series:[{lineWidth:4, markerOptions:{style:'square'}}]
  });
});​

请参阅JSFiddle以了解该问题的实时编辑。 http://jsfiddle.net/AqFTV/

我知道我可以更改tickOptions formatstring,但我无法找到相关的文档。

1 个答案:

答案 0 :(得分:1)

我强烈建议您提高图表的可读性to rotate your ticks example here.

当你选择勾选格式时,你可以在docs under DateAxisRenderer plugin here.

中找到