Incorporating Ruby into jqPlot
===


I'm trying to create a pie chart using jqPlot, gathering data from a Rails database.

    <script>
    <% things = [] %>
      <% @topEvents.each do |event| %>
    <% things << [event.name, event.total] %>
    <% end %>

    $.jqplot('topEvents', [ <%= things %> ],
    {
      seriesDefaults: {
        renderer: jQuery.jqplot.PieRenderer,
        rendererOptions: {
          showDataLabels: true
        }
      }
    });
    </script>

My problem occurs because jqplot doesn't understand the strings generated from event.name. If I manually insert a couple of strings, without going through Rails, it works fine. I believe it has something to do with escaping characters it shouldn't be. The error I get from Firebug shows events = [[&quot;Title&quot;, 1234566]]. Thus jqplot tries to create this chart with &quot;Title&quot; as a key. It doesn't like that.

I've tried using html_safe, to no avail.

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!
