Created
October 10, 2008 14:42
-
-
Save nikosd/16064 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'gruff' | |
# Let's hack almost everything | |
g = Gruff::Bar.new('800x700') # Define a custom size | |
g.sort = false # Do NOT sort data based on values | |
g.maximum_value = 40 # Declare a max value for the Y axis | |
g.minimum_value = 0 # Declare a min value for the Y axis | |
g.y_axis_increment = 1 # Points shown on the Y axis | |
g.legend_font_size = 14 # Legend font size | |
g.title_font_size = 22 # Title font size | |
g.font = '/Library/Fonts/NuevaStd-BoldCond.otf' # Path to a custom font | |
g.top_margin = 10 # Empty space on the upper part of the chart | |
g.bottom_margin = 30 # Empty space on the lower part of the chart | |
g.theme = { # Declare a custom theme | |
:colors => %w(orange purple green white red #cccccc), # colors can be described on hex values (#0f0f0f) | |
:marker_color => 'black', # The horizontal lines color | |
:background_colors => %w(white grey) # you can use instead: :background_image => ‘some_image.png’ | |
} | |
g.title = 'A more advanced bar chart' | |
g.x_axis_label = "X axis label" | |
g.y_axis_label = "Y axis label" | |
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('advanced_graph.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you