-
-
Save b2l/ff06129a0dad77250e4e to your computer and use it in GitHub Desktop.
Rails GoogleCharts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GoogleChart::BarChart.new("#{options[:width]}x#{options[:height]}", options[:name]) do |lc| // SIZE DEFINED AS STRING WITH BOTH WIDTH AND HEIGHT, NOT GOOD | |
lc.show_legend = false | |
lc.data 'Visningar', google_data, 'E04300' | |
lc.axis :x, :color => '333333', :font_size => 10, :alignment => :center, :labels => labels | |
lc.axis :y, :range => [0,max], :color => '333333', :font_size => 10, :alignment => :center | |
lc.width_spacing_options(:bar_width => options[:bar_width], :bar_spacing => options[:bar_spacing]) | |
end.to_url | |
image_tag(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GoogleChart.100x200_pie(10,20,40,30).to_url | |
### OR | |
sales_chart = GoogleChart.newsales_chart.type = :pie | |
sales_chart.height = 200 | |
sales_chart.width = 150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gchart.bar(:data => google_data, | |
:size => "#{options[:width]}x#{options[:height]}", // SIZE DEFINED AS STRING WITH BOTH WIDTH AND HEIGHT, NOT GOOD | |
:axis_with_labels => 'x,y', | |
:axis_labels => [labels, [0, (max/2).to_i, max.to_i]], | |
:format => 'image_tag', | |
:bar_colors => 'E04300', | |
:max_value => max, | |
:bar_width_and_spacing => "#{options[:bar_width]},#{options[:bar_spacing]}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment