Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GoogleVisualr::PieChart Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/piechart.html#Example
def pie_chart
@chart = GoogleVisualr::PieChart.new
@chart.add_column('string', 'Task')
@chart.add_column('number', 'Hours per Day')
@chart.add_rows(5)
@chart.set_value(0, 0, 'Work' )
@chart.set_value(0, 1, 11 )
@chart.set_value(1, 0, 'Eat' )
@chart.set_value(1, 1, 2 )
@chart.set_value(2, 0, 'Commute' )
@chart.set_value(2, 1, 2 )
@chart.set_value(3, 0, 'Watch TV' )
@chart.set_value(3, 1, 2 )
@chart.set_value(4, 0, 'Sleep' )
@chart.set_value(4, 1, 7 )
options = { :width => 400, :height => 240, :title => 'My Daily Activities', :is3D => true }
options.each_pair do | key, value |
@chart.send "#{key}=", value
end
end
<div id='chart'></div>
<%= @chart.render('chart') %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment