我试图将这个样式图实现到我的rails项目中。
<%= line_chart @goals.map{|goal|
{:name => goal.name, :data => goal.feats.group_by_week(:created_at).count }
} %>我目前正在使用Chartkick这样做。http://ankane.github.io/chartkick/这里是如何设置我的表的。
我想从时间表表的3列中跟踪current_user时间表。
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这是当前我的时间表表的样子。我怎样才能追踪:老师,:学习,:通过图表通过图表交谈?我读过这些文档,但不太理解。谢谢!
发布于 2013-08-07 04:35:09
如果我理解正确,你想做:
<%= 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] }}
] %>https://stackoverflow.com/questions/18073327
复制相似问题