Pull datasets from DB and manipulate into separate arrays
- by dresdin
My DB has four fields, date:date, morning:integer, afternoon:integer, evening:integer.
Google charts needs the data split into one array per dataset (example below).  What's the best way to do this?
  ['Day',     'Morning', 'Afternoon', 'Evening'],
  ['06/27/13',  1000,       400           234],
  ['06/28/13',  1170,       460           275],
  ['06/29/13',  660,        1120          377],
  ['06/30/13',  1030,       540           934]
I've tried this without much luck:
var data = google.visualization.arrayToDataTable([
  <% @todo.each do |t| %>
  ['Day',                                   'Morning',        'Afternoon',        'Evening'],
  [<%= t.date.strftime("%m/%d/%y") %>,  <%= t.morning %>, <%= t.afternoon %>, <%= t.evening %>]
  <% end %>
]);