[Awesome Ruby Gem] Use gruff gem to make beautiful graphs in Ruby

gruff

Gruff Graphs is a library for making beautiful graphs.

gruff gem is the Gruff graphing library for Ruby

Installation

You can install it as a gem:

1
$ gem install gruff

or add it into a Gemfile (Bundler):

1
2
3
4
5
6
7
8
# Gemfile

# Put gems used only for development or testing in the appropriate group in the Gemfile
group :development do
# topfunky/gruff: Gruff graphing library for Ruby
# https://github.com/topfunky/gruff
gem 'gruff', '0.13.0'
end

Then, run bundle install.

1
$ bundle install

Font

Gruff uses Roboto font as default font which is licensed under the Apache License, Version 2.0.

Usage

1
2
3
4
5
6
7
8
9
10
11
12
require 'gruff'
g = Gruff::Line.new
g.title = 'Wow! Look at this!'
g.labels = { 0 => '5/6', 1 => '5/15', 2 => '5/24', 3 => '5/30', 4 => '6/4',
5 => '6/12', 6 => '6/21', 7 => '6/28' }
g.data :Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]
g.data :Charles, [80, 54, 67, 54, 68, 70, 90, 95]
g.data :Julie, [22, 29, 35, 38, 36, 40, 46, 57]
g.data :Jane, [95, 95, 95, 90, 85, 80, 88, 100]
g.data :Philip, [90, 34, 23, 12, 78, 89, 98, 88]
g.data :Arthur, [5, 10, 13, 11, 6, 16, 22, 32]
g.write('exciting.png')

Examples

You can find many examples in the test - https://github.com/topfunky/gruff/tree/master/test directory along with their resulting charts in the expected - https://github.com/topfunky/gruff/tree/master/test/expected directory.

References

[1] topfunky/gruff: Gruff graphing library for Ruby - https://github.com/topfunky/gruff

[2] gruff | RubyGems.org | your community gem host - https://rubygems.org/gems/gruff/