Sha256: 768e1ab9bbb4cf95425368f6f7c360fb3367232d37f0e4722b7feec468df158e

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

#!/usr/bin/ruby

require File.dirname(__FILE__) + "/gruff_test_case"

class TestGruffStackedBar < GruffTestCase

  def setup
    @datasets = [
      [:Jimmy, [25, 36, 86, 39]],
      [:Charles, [80, 54, 67, 54]],
      [:Julie, [22, 29, 35, 38]],
      ]
    @sample_labels = {
        0 => '5/6', 
        1 => '5/15', 
        2 => '5/24'
      }      

  end

  def test_bar_graph
    g = Gruff::StackedBar.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/stacked_bar_keynote.png"
  end


  def test_bar_graph_small
    g = Gruff::StackedBar.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/stacked_bar_keynote_small.png"
  end


  def test_bar_with_1_ldata
    g = Gruff::StackedBar.new(800)
    g.title = "Stacked Bar Test with ldata"
    @datasets.each do |data|
      g.data(data[0], data[1])
    end
    g.ldata(:trend, [ 94, 70, 120, 80 ])
    g.write "test/output/stacked_bar_with_1_ldata.png"
  end


  def test_bar_with_2_ldata
    g = Gruff::StackedBar.new(800)
    g.title = "Stacked Bar Test with ldata"
    @datasets.each do |data|
      g.data(data[0], data[1])
    end
    g.ldata(:trend, [ 94, 70, 120, 80 ],
	    :style => [15,5], :line_width => 2, :color => 'grey')
    g.ldata(:target, [ 140, 150, 160, 170 ],
	    :style => 'dot', :line_width => 4, :color => 'red' )
    g.write "test/output/stacked_bar_with_2_ldata.png"
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jslade-gruff-0.3.5 test/test_stacked_bar.rb