Skip to content

Instantly share code, notes, and snippets.

@mattapayne
Created April 19, 2009 20:28
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 mattapayne/98207 to your computer and use it in GitHub Desktop.
Save mattapayne/98207 to your computer and use it in GitHub Desktop.
def create_bar_chart(opts, data)
g = Gruff::Bar.new(opts[:size])
g.title = opts[:title]
g.minimum_value = opts[:minimum]
g.maximum_value = opts[:maximum]
g.labels = data.map { |e| e.category }
g.data(opts[:legend], data.map { |e| e.count } )
g.x_axis_label = opts[:x_axis_label]
g.y_axis_label = opts[:y_axis_label]
return g.to_blob
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment