我从下面这样的代码中得到哈希
{"Jan 2016"=>4649, "Feb 2016"=>3945, "Mar 2016"=>4870, "Apr 2016"=>4872,
"May 2016"=>6494, "Jun 2016"=>4981, "Jul 2016"=>9949, "Aug 2016"=>4842,
"Sep 2016"=>5820, "Oct 2016"=>4934, "Nov 2016"=>4136, "Dec 2016"=>8856,
"Jan 2017"=>3762, "Feb 2017"=>3261, "Mar 2017"=>2185, "Apr 2017"=>702}
这个从代码生成的哈希
@bookings.group_by_month(:check_in_date, format: "%b %Y").sum(:total_night)
我正在使用此代码使用 chartkick 生成图表,我想按季度对其进行分组以生成数据系列,这样我就可以为每个系列赋予不同的颜色,
预期输出为
[
{name: "Q1",data: {"Jan 2016"=>4649, "Feb 2016"=>3945, "Mar 2016"=>4870}},
{name: "Q2",data: {"Apr 2016"=>4872, "May 2016"=>6494, "Jun 2016"=>4981}}
…
]