[英]Rails and Chartkick
我正在嘗試將此樣式表實現到我的rails項目中。
<%= line_chart @goals.map{|goal|
{:name => goal.name, :data => goal.feats.group_by_week(:created_at).count }
} %>
我目前正在使用Chartkick這樣做。 http://ankane.github.io/chartkick/這是我的表格的設置方式。
我想在Timesheets表上的3列中跟蹤current_user Timesheets。
def change
create_table :timesheets do |t|
t.decimal :teacher
t.decimal :study
t.decimal :conversation
t.date :day
t.references :user
t.timestamps
end
add_index :timesheets, :user_id
end
這是我的時間表表格的樣子。 我怎樣才能跟蹤:老師,:學習,通過圖表通過圖表對話? 我已經閱讀了文檔,並不能完全掌握它。 謝謝!
如果我理解正確,你想做:
<%= line_chart [
{name: "Teacher", data: current_user.timesheets.map{|t| [t.day, t.teacher] }},
{name: "Study", data: current_user.timesheets.map{|t| [t.day, t.study] }},
{name: "Conversation", data: current_user.timesheets.map{|t| [t.day, t.conversation] }}
] %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.