Sha256: 4ef585d232e26f51bdeea149f1278a5b1342c8d9c363ba96375a1a70a4b35734

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

#!/usr/bin/ruby

$:.unshift(File.dirname(__FILE__) + "/../lib/")
#$:.unshift File.dirname(__FILE__) + "/fixtures/helpers"

require 'test/unit'
require 'gruff'

class TestGruffSideSideStackedBar < Test::Unit::TestCase

  # TODO Delete old output files once when starting tests

  def setup
    @datasets = [
      [:Jimmy, [25, 36, 86, 39]],
      [:Charles, [80, 54, 67, 54]],
      [:Julie, [22, 29, 35, 38]],
      #[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
      #[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
      #["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
      ]
    @sample_labels = {
        0 => '5/6', 
        1 => '5/15', 
        2 => '5/24'
      }      

  end

  def test_bar_graph
    g = Gruff::SideStackedBar.new
    g.title = "Visual Stacked Bar Graph Test"
    g.labels = {
      0 => '5/6', 
      1 => '5/15', 
      2 => '5/24', 
      3 => '5/30', 
    }
    @datasets.each do |data|
      g.data(data[0], data[1])
    end
    g.write "test/output/side_stacked_bar_keynote.png"
  end


  def test_bar_graph_small
    g = Gruff::SideStackedBar.new(400)
    g.title = "Visual Stacked Bar Graph Test"
    g.labels = {
      0 => '5/6', 
      1 => '5/15', 
      2 => '5/24', 
      3 => '5/30', 
    }
    @datasets.each do |data|
      g.data(data[0], data[1])
    end
    g.write "test/output/side_stacked_bar_keynote_small.png"
  end

  def test_wide
    g = setup_basic_graph('800x400')
    g.title = "Wide SSBar"
    g.write "test/output/side_stacked_bar_wide.png"
  end

protected

  def setup_basic_graph(size=800)
    g = Gruff::SideStackedBar.new(size)
    g.title = "My Graph Title"
    g.labels = @sample_labels
    @datasets.each do |data|
      g.data(data[0], data[1])
    end
    return g
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gruff-0.1.1 test/sidestacked_bar_test.rb