How to incorporate Rails into jqPlot?
===

I've got some data in a SQLite3 database which I'm using through Rails. I'm trying to graphically display this data. using bar charts, pie charts, etc. It's been decided that I'm to use the jQuery framework to help me complete this task, so I've decided upon using jqPlot for the actual charts.

How do I get dynamic data from my tables? I can get the charts to pop up using manual data, but this obviously isn't helpful in the long run. I'm putting the majority of my code in my View (I'll move the logic into the model afterwards, for you Rails Purists), which is an .html.erb file (embedded Ruby). I can't access my tables without using <% and %>, but the html itself doesn't understand the Ruby. My current code is as follows:

    <% foo = [] %>

    <% Book.all.each do |book| %>
      <% foo.push([book.isbn]) %>
    <% end %>
    
    $.jqplot('chartdiv',  [foo],
    {
      title: {
        text: 'Test Message',
      },
    });

But the jqplot function doesn't know what `foo` is. How do I get a chart to use data stored in a database?

Ruby 1.9.3, Rails 3.2.6, SQLite3 3.6.20, jquery-rails 2.0.2 (RubyGem), JQuery 1.7.2, jqplot 1.0.0_r1012.

Thanks!