在 Rails 中使用 Google Visualizer 时,我得到第一列和第二列必须是实体和时间,为什么?
我正在使用 Ruby 包装器,它似乎适合使用 Google Visualizer:
https://github.com/jeremyolliver/gvis
但是,我不断收到此特定错误:
First and second columns must be entity and time
但是,据我所知,我传递的数据是实体和时间:
<% chart_data = [
["Apples", Date.new(1998,1,1), 1000,300,'East'],
["Oranges", Date.new(1998,1,1), 950,200,'West'],
["Bananas", Date.new(1998,1,1), 300,250,'West'],
["Apples", Date.new(1998,2,1), 1200,400,'East'],
["Oranges", Date.new(1998,2,1), 950,150,'West'],
["Bananas", Date.new(1998,2,1), 788,617,'West']
] %>
<% visualization "my_chart", "MotionChart", :width => 600, :height => 400, :html => {:class => "graph_chart"} do |chart| %>
<%# Add the columns that the graph will have
<% chart.string "Fruit" %>
<% chart.date "Date" %>
<% chart.number "Sales" %>
<% chart.number "Expenses" %>
<% chart.string "Location" %>
<% chart.add_rows(chart_data) %>
<% end %>
我不知道如何调试,因为我没有获得足够的信息来处理错误......
I am using a Ruby wrapper which appears to be correct for using Google Visualizer:
https://github.com/jeremyolliver/gvis
However, I keep getting this particular error:
First and second columns must be entity and time
However, the data I am passing are entity and time as far as I understand:
<% chart_data = [
["Apples", Date.new(1998,1,1), 1000,300,'East'],
["Oranges", Date.new(1998,1,1), 950,200,'West'],
["Bananas", Date.new(1998,1,1), 300,250,'West'],
["Apples", Date.new(1998,2,1), 1200,400,'East'],
["Oranges", Date.new(1998,2,1), 950,150,'West'],
["Bananas", Date.new(1998,2,1), 788,617,'West']
] %>
<% visualization "my_chart", "MotionChart", :width => 600, :height => 400, :html => {:class => "graph_chart"} do |chart| %>
<%# Add the columns that the graph will have
<% chart.string "Fruit" %>
<% chart.date "Date" %>
<% chart.number "Sales" %>
<% chart.number "Expenses" %>
<% chart.string "Location" %>
<% chart.add_rows(chart_data) %>
<% end %>
I'm not sure how to debug because I'm not getting enough information to work with in the errors....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该使用 highcharts :)
源代码的方式有点不同。
add_rows
似乎是您在chart_object
上调用的方法,然后将数组数组作为方法传递,以便此插件创建一个
chart
对象使用add_rows
方法传递数组。Should have gone with highcharts :)
The way the source code has it is a little different.
add_rows
seems to be the method you call on thechart_object
and then you pass your array of arrays as a methodso this plugin creates a
chart
object with theadd_rows
method for you to pass in your arrays.