Prev | Current Page 60 | Next

David Berube

"Practical Reporting with Ruby and Rails"

Chapter 7 shows you how to use Markaby, a templating language for Ruby, to
create your own HTML bar charts. Chapter 11 demonstrates how to use CSS helpers
to create charts in Rails. Here, we??™ll look at the Gruff and Scruffy graphing libraries, and
then use Gruff in a couple of examples.
Gruff (http://gruff.rubyforge.org/) provides a simple, Ruby-based interface to enter
data and display details. After writing the code, you call a simple command to render the
graph to a file. For example, if you had a collection of vintage guitars and wanted to display
a simple bar chart with their values, you could do so as shown in Listing 3-1.
nNote You??™ll need Gruff, ImageMagick, and RMagick installed to run this example. ImageMagick, an
image-manipulation toolkit used by Gruff, is available from http://imagemagick.org. RMagick is the
Ruby interface to ImageMagick that Gruff uses. Install them by running the commands gem install -y
gruff and gem install rmagick.
33
C H A P T E R 3
Listing 3-1. Creating a Simple Chart with Gruff (guitar_chart.


Pages:
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
Odżywki kamień elewacyjnywacyjny Lotto kuchnia na wymiar łazienka