jeremyolliver / gvis

Rails plugin for easy embedding charts with Google Visualization API
http://github.com/jeremyolliver/gvis
MIT License
49 stars 22 forks source link

can I pass a 'string' to a Date or make a conversion? #11

Closed angelacode closed 12 years ago

angelacode commented 14 years ago

I am using the statistics gem which creates a hash, which I then turn to an array using sort:

#<OrderedHash {"2010-11-05"=>3, "2010-11-06"=>2}>

After sort, it becomes:

@email_series = [["2010-11-05", 3], ["2010-11-06", 2]]

I want to graph this and did the following:

 <% visualization "next_chart", "MotionChart", :width => 300, :height => 200, :html => {:class => "graph_chart"} do |chart| %>
  <%# Add the columns that the graph will have %>
  <% chart.date "Date" %>
  <% chart.number "Count" %>

  <% chart.add_rows(@email_series) %>

But my graph doesn't work -- what are the specific or constraints of passing data to the graph?

jeremyolliver commented 13 years ago

Hi Angela,

Currently all Date columns are expected to be input as a ruby date object such as:

@email_series = [[Date.new(2010,11,5), 3], [Date.new(2010,11,6), 2]]

I'm about to spend a little more time, brushing up this library, so I'll give a go at a patch that allows a string formatted date as well.

Cheers, Jeremy

jeremyolliver commented 12 years ago

Closing this ticket, string values can be used, as long as the column is declared as a date type