Chartkicks轨道中的堆积列

时间:2016-03-07 14:44:51

标签: ruby-on-rails ruby charts chartkick

我正在尝试堆叠此列图:

<%= column_chart  [
              {name: "Paper", data: current_user.papers.map{|t| [t.paper_type, t.paper_weight] }, 'interpolateNulls':true, 'stacked':true},
              {name: "EnvPaper", data: current_user.papers.map{|t| [t.paper_type, t.env_paper_weight ] }, 'interpolateNulls':true, 'stacked':true} ] %>

我在chartkicks文档中读到这段代码可以使它堆叠

<%= column_chart data, stacked: true %>

所以我尝试了几次修改,但似乎没有任何效果。现在我的图形代码看起来像这样。

<%= column_chart data, stacked: true, current_user.papers.map{|t|
              {name: t.paper_type, data: t.paper_weight.count, t.env_paper_weight.count }} %>

它给了我这个错误:

syntax error, unexpected '}', expecting =>
...unt, t.env_paper_weight.count }} );@output_buffer.safe_appen...
...                               ^
/Users/dadi/Documents/Vefir/SprettaEMS1.5/app/views/users/show.html.erb:115: syntax error, unexpected keyword_ensure, expecting '}'
/Users/dadi/Documents/Vefir/SprettaEMS1.5/app/views/users/show.html.erb:117: syntax error, unexpected keyword_end, expecting '}'

我真的被困在这里,是否有人可以帮助我?

提前谢谢 大地

1 个答案:

答案 0 :(得分:1)

您已将代码添加到错误的位置,请尝试如下:

<%= column_chart stacked: true, data: current_user.papers.map{|t|
          {name: t.paper_type, data: t.paper_weight.count, t.env_paper_weight.count }} %>