Skip to content

Instantly share code, notes, and snippets.

@b2l

b2l/gchartdb.rb Secret

Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b2l/ff06129a0dad77250e4e to your computer and use it in GitHub Desktop.
Save b2l/ff06129a0dad77250e4e to your computer and use it in GitHub Desktop.
Rails GoogleCharts
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)
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
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