I played around with gruff today. The final result is really impressive. Especially it can visualize data from your database in the way you want.
Before you install this gem. You need to install few extra things. They are imagemagick, ghostscript. On Mac OSX you need to do
brew install imagemagick ghostscript
After installing both packages, you can run bundle install
Usage
To generate a graph you need to
12345678910111213141516171819202122232425262728
require"gruff"require"date"# Create the graph objectg=Gruff::Line.new# Set the titleg.title="My First Graph"# Let say we have a data hash# The element is like {Date => Integer}today=Date.todayyesterday=Date.today.prev_daydata={yesterday=>100,today=>200}# We need to set the x-axis labels# It need to be a Hash { 0 => "name 1", 1 => "name 2", … }# We need to do a little bit of data transform here.g.labels=Hash[(0...data.keys.size).zipdata.keys.map{|day|day.strftime("%d %b")}]# => {0=>"07 Oct", 1=>"08 Oct"}# Then we need to set the y-axis, we need to give it a nameg.data:Price,data.values# Write the generated graph to a fileg.write"gruff.png"