在jqplot中显示每月数据

时间:2011-02-24 17:22:21

标签: javascript jquery jqplot

我每月使用OHLC渲染器获得一系列数据,每个数据点都有一个数据点。我试图用jqplot显示它。它看起来很好,除了数据点太瘦了,因为jqplot显示它们好像它们只适用于那一天。当我取出日期,并指定月份和年份时,jqplot会崩溃。

我的数据如下:

    [
        [
            "01/01/2008", 
            8152.9054008104704, 
            2612.7075024153296, 
            5382.8064516128998
        ], 
        // ...
        [
            "03/01/2008", 
            7554.0494491662403, 
            2086.69248631764, 
            4820.3709677419401
       ], 
    ]

这种配置是否可行,或者我应该自己破解代码? documentation并未明确说明如何执行此操作。

我应该修改哪些代码? DateAxisRendererOHLCRenderer

2 个答案:

答案 0 :(得分:5)

您可以使用tickInterval选项和jqplot.DateAxisRenderer插件来创建月份刻度。

xaxis: {
        renderer: jQuery.jqplot.DateAxisRenderer,
        tickOptions: {
              formatString:'%#d %I:%M %p'
        },
        rendererOptions: {
              daTickInterval: [1, 'month']
        }
  }

答案 1 :(得分:0)

Jagadish的rendererOptions对我不起作用。但是,这样做了:

axes:{
    xaxis:{
      renderer:$.jqplot.DateAxisRenderer,
      tickOptions:{formatString:'%b/%e/%Y'},
      tickInterval:'1 month'
    }
  },