Prev | Current Page 62 | Next

David Berube

"Practical Reporting with Ruby and Rails"

Currently, Gruff has much more documentation available online and is
more mature than Scruffy.
With Scruffy, you can mix graph types in the same graph, so you could, for example,
have a chart with both line and bar elements. Suppose you were charting the output of a
factory that builds widgets and sprockets. You could use the code in Listing 3-2 to create a
bar and line chart with the data.
nNote To run this example, you??™ll need to install Scruffy with the command gem install scruffy. You??™ll
also need RMagick installed, so install that with gem install rmagick, if you haven??™t already done so.
CHAPTER 3 n CREATING GRAPHS WITH RUBY 34
Figure 3-1. A chart of guitar values created using Gruff
Listing 3-2. Creating a Simple Chart with Scruffy (widget_chart_scruffy.rb)
require 'scruffy'
sprocket_output = [["Jan",500],
["Feb",750],
["Apr",380]]
widget_output = [["Jan",350],
["Feb",650],
["Apr",560]]
graph = Scruffy::Graph.new(
:title => "Widget and Sprocket Output",
:theme => Scruffy::Themes::Keynote.


Pages:
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
Margo Liroy bukmacherzy sprzedam wózek Meat Loaf