mis*_*ist 2 ruby charts ruby-on-rails
我正在尝试将这个样式图表实现到我的 Rails 项目中。
<%= line_chart @goals.map{|goal|
{:name => goal.name, :data => goal.feats.group_by_week(:created_at).count }
} %>
Run Code Online (Sandbox Code Playgroud)
我目前正在使用 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
Run Code Online (Sandbox Code Playgroud)
这就是我的时间表目前的样子。我如何通过 Chartkick 的图表来跟踪 :teacher、:study、:conversation?我已经阅读了文档,但无法完全理解它。谢谢你!
如果我理解正确的话,你想做的是:
<%= 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] }}
] %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3577 次 |
| 最近记录: |