我正在使用Chartkick宝石。此代码剪切实际上应显示特定用户的收入:
<%= area_chart Order.where(:user_name => current_user.name).group_by_day(:created_at).maximum(:totalprice), library: {isStacked: false, vAxis: {title: "Revenue"}, hAxis: {title: 'Date'}} %>
但它只显示totalprice
的最后一个条目。因此,例如,如果在特定日期出售2件商品(例如300 + 600美元价值),则仅显示600美元商标。如何转换上面的代码,以便总结所有Order.totalprice
条目?
提前致谢!
答案 0 :(得分:3)
最高可获得最高总价,如果您想将它们加在一起,您需要总和。
<%= area_chart Order.where(:user_name => current_user.name).group_by_day(:created_at).sum(:totalprice), library: {isStacked: false, vAxis: {title: "Revenue"}, hAxis: {title: 'Date'}} %>