Reputation: 3383
I have a chart like so:
<%= line_chart Click.where(:deal_id => @deal.id).group_by_day(:created_at).count %>
I know we can pass min and max values, but I don't know how to pass time values correctly. I tried doing something like this:
<%= line_chart Click.where(:deal_id => @deal.id).group_by_day(:created_at).count, min: Time.now - 5.days, max: Time.now %>
This didn't change the axis. I want to have a rolling 5 day chart essentially. How can I accomplish this? Thanks in advance!
Upvotes: 1
Views: 2101
Reputation: 3236
You can do:
line_chart Click.where(:deal_id => @deal.id).group_by_day(:created_at, last: 5).count
For more details, see the time range section of the Groupdate documentation: https://github.com/ankane/groupdate#time-range
Upvotes: 3