2012-11-03 46 views
1

我想用https://github.com/michelson/lazy_high_charts來渲染一個簡單的區域圖,其中x軸的日期和y軸的得分。我使用了lazy_high_charts中的以下片段。圖形呈現,但x軸不是日期。帶有lazy_chart紅寶石寶石的Highcharts區域圖

@h = LazyHighCharts::HighChart.new('graph', style: '') do |f| 
    f.options[:chart][:defaultSeriesType] = "area" 
    f.options[:plotOptions] = {areaspline: {pointInterval: 1.day, pointStart: 10.days.ago}} 
    f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9]) 
    f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9]) 
    f.xAxis(type: :datetime) 
end 

我想要有一個時間間隔的時間系列,像這樣的http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-pointstart-datetime/

以上代碼生成下面的HTML(http://jsfiddle.net/nUxvA/

我想比較這兩個和劇情的選擇是不同的。我怎樣才能在X軸上有日間間隔刻度?

回答

0

上述代碼有3個問題。

  1. pointInterval必須是在毫秒所以1.day應該1.day * 1000
  2. pointStart必須是在UTC毫秒所以10.days.ago應該10.days.ago.getutc.to_i * 1000
  3. areaspline應該是一系列

繪製X軸的日期。