1
我遵循Railscast #223的介紹Morris.JS。在Coffeescript/Morris.JS中使用Ruby Hash代替Rails ActiveRecord
我產生我的控制器在我看來,我有以下的嘗試和渲染圖形叫@orders_yearly
數據集:
<%= content_tag :div, "", id: "orders_chart", data: {orders: @orders_yearly} %>
調用@orders_yearly.inspect
顯示它只是一個簡單的哈希:
{2009=>1000, 2010=>2000, 2011=>4000, 2012=>100000}
我需要修改咖啡腳本中的xkey
和ykeys
的值才能工作,但我不確定如何使其與我的數據集一起工作:
jQuery ->
Morris.Line
element: 'orders_chart'
data: $('#orders_chart').data('orders')
xkey: 'purchased_at' # <------------------ replace with what?
ykeys: ['price'] # <---------------------- replace with what?
labels: ['Price']
任何人有任何想法?
謝謝!