2012-11-03 41 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轴的日期。