문제

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!

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top