Scruffy 0.2.0
August 14, 2006 @ 03:56 PMWell, I warned you.
Scruffy 0.2.0 has been released, and with it comes some significant changes. However, I said the majority of the changes would affect only the rendering system, and for the most part I stuck to that.
What’s new (Layout/Rendering) & what isn’t…
The result of these large changes is a pretty nifty rendering/layout engine that allows you to make your graphs look pretty much however you want. In addition, all elements on the graph have been made into components. You can move anything anywhere on the graph with ease.
To demonstate the capabilities of the renderers, I created a couple different layouts that are included with Scruffy. You can use them, or create your own.
Still no piecharts, but yes, those are coming, as are a few more chart types that I personally need.
Using Scruffy
The documentation is out of date at the moment. I will fix that in the next day or two to reflect the changes. The API for using the graph hasn’t changed much and is fairly simple. Below is a collection of code of resulting images.
Installing
1 2 |
gem install scruffy
|
Using
1 2 3 4 5 |
require 'scruffy'
graph = Scruffy::Graph.new
(...)
|
Examples
Split Graph
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
graph = Scruffy::Graph.new
graph.title = "Long-term Comparisons"
graph.value_formatter = Scruffy::Formatters::Currency.new(:special_negatives => true,
:negative_color => '#ff7777')
graph.renderer = Scruffy::Renderers::Split.new(:split_label => 'Northeastern (Top) / Central (Bottom)')
graph.add :area, 'Jeff', [20, -5, 100, 70, 30, 106, 203, 100, 50, 203, 289, 20], :category => :top
graph.add :area, 'Jerry', [-10, 70, 20, 102, 201, 26, 30, 106, 203, 100, 50, 39], :category => :top
graph.add :bar, 'Jack', [30, 0, 49, 29, 100, 203, 70, 20, 102, 201, 26, 130], :category => :bottom
graph.add :line, 'Brasten', [42, 10, 75, 150, 130, 70, -10, -20, 50, 92, -21, 19], :categories => [:top, :bottom]
graph.add :line, 'Jim', [-10, -20, 50, 92, -21, 56, 92, 84, 82, 100, 39, 120], :categories => [:top, :bottom]
graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
… generates …
Stacking Graph Types
1 2 3 4 5 6 7 8 9 10 |
graph = Scruffy::Graph.new
graph.title = "Comparative Agent Performance"
graph.value_formatter = Scruffy::Formatters::Percentage.new(:precision => 0)
graph.add :stacked do |stacked|
stacked.add :bar, 'Jack', [30, 60, 49, 29, 100, 120]
stacked.add :bar, 'Jill', [120, 240, 0, 100, 140, 20]
stacked.add :bar, 'Hill', [10, 10, 90, 20, 40, 10]
end
graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
|
… generates …
Multi-viewport Multi-layered (This was Fun)
1 2 3 4 5 6 7 8 9 10 11 |
graph = Scruffy::Graph.new
graph.title = "Some Kind of Information"
graph.renderer = Scruffy::Renderers::Cubed.new
graph.add :area, 'Jeff', [20, -5, 100, 70, 30, 106], :categories => [:top_left, :bottom_right]
graph.add :area, 'Jerry', [-10, 70, 20, 102, 201, 26], :categories => [:bottom_left, :buttom_right]
graph.add :bar, 'Jack', [30, 0, 49, 29, 100, 203], :categories => [:bottom_left, :top_right]
graph.add :line, 'Brasten', [42, 10, 75, 150, 130, 70], :categories => [:top_right, :bottom_left]
graph.add :line, 'Jim', [-10, -20, 50, 92, -21, 56], :categories => [:top_left, :bottom_right]
graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
|
… generates …


