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

barChart issue after upgrading to Rails 3 #20

Closed nitinsinghit closed 12 years ago

nitinsinghit commented 12 years ago

<%= visualization "chart_id", "barChart", :hAxis => "{title: 'Year1', titleColor:'red'}",:width => 830, :height => 600, :axisColor => 'Orange' ,:colors => ['#FBC302','#9ABE94','red'], :borderColor => '#495F44' , :backgroundColor => '#f5f5f5', :legendBackgroundColor => '#f5f5f5',:legendFontSize => 16, :legend => 'top', :tooltipWidth => 250, :tooltipFontSize => 14, :titleY => 'Game', :titleX => '# of Days to Complete', :titleFontSize => 10, :isStacked => true, :min => 0, :html => {:class => "graph_class"} do |chart| %>

    <% chart.string "ABC" %>
    <% chart.number "Days for user to complete" %>
    <% chart.number "Days for user to accept" %>
    <% chart.add_rows(@chart_data) %>

<% end %>

Above code use to work before I install gvis gem and upgrade to rails 3. Using firebug i see that there syntax error on :hAxis => "{title: 'Year1', titleColor:'red'}" . I remove hAxis but no chart rendered.

Please tell me what I am missing in the above code.

jeremyolliver commented 12 years ago

Sorry I didn't respond earlier - the issue here is that the :hAxis option should be specified as a ruby hash, not a string containing the javascript hash/object. Like this:

:hAxis => {"title" => 'Year1', "titleColor" => 'red'}