Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nikosd/16060 to your computer and use it in GitHub Desktop.
Save nikosd/16060 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'gruff'
# With more options now
g = Gruff::Bar.new('800x500') # Define a custom size
g.sort = false # Do NOT sort data based on values
g.maximum_value = 50 # Declare a max value for the Y axis
g.minimum_value = 0 # Declare a min value for the Y axis
g.theme_37signals # Declare a theme from the presets available
g.title = 'A more advanced bar chart'
g.data('Foo', [5, 10, 24])
g.data('Bar', [15, 3, 10])
g.data('Else', [38, 15, 32])
g.labels = {0 => 'Last year', 1 => 'This year', 2 => 'Next year'} # Define labels for each of the "columns" in data
g.write('a_more_advanced_graph.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment