HighCharts を使用して、xAxis に沿って日付 (日ごと) を表示しようとしています。そのために、レイジー ハイ チャートジェム w/ Rails を使用しています。HighCharts の「データ」引数については、[[日付、収益]、[日付、収益]、[日付、収益]...etc] でネストされた配列を渡します。
収益の y 軸は正しく機能していますが、x 軸の対応する日付は機能していません。
コントローラーのコードは次のとおりです。
def graph_orders
sales_and_date_array = []
Order.revenue_to_array(sales_and_date_array)
puts sales_and_date_array.inspect
# http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/series/data-array-of-arrays-datetime/
@chart = LazyHighCharts::HighChart.new('graph') do |f|
f.title(:text => "Lono Sales")
f.xAxis(
type: 'datetime'
)
f.series(:name => "Lono Sales Revenue", :yAxis => 0, :data => sales_and_date_array)
f.yAxis [
{:title => {:text => "Revenue", :margin => 70} },
{:title => {:text => "Revenue"}, :opposite => true},
]
f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)
f.chart({:defaultSeriesType=>"line"})
end
end
「sales_and_date_array」の検査は次のようになります。
[["2014-06-12", 208.28], ["2014-06-11", 416.56], ["2014-06-11", 624.84], ["2014-06-11", 833.12], ["2014-06-10", 1041.4], ["2014-06-09", 1249.68], ["2014-06-08", 1457.96], ["2014-06-08", 1666.24], ["2014-06-07", 1874.52], ["2014-06-07", 2082.8], ["2014-06-07", 2291.08],....etc
現在のグラフ出力は次のようになります。
何かご意見は?