fix security issue
[selectricity] / lib / gruff-0.2.8 / test / test_sidestacked_bar.rb
1 #!/usr/bin/ruby
2
3 require File.dirname(__FILE__) + "/gruff_test_case"
4
5 class TestGruffSideStackedBar < GruffTestCase
6
7   def setup
8     @datasets = [
9       [:Jimmy, [25, 36, 86, 39]],
10       [:Charles, [80, 54, 67, 54]],
11       [:Julie, [22, 29, 35, 38]],
12       #[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
13       #[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
14       #["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
15       ]
16     @sample_labels = {
17         0 => '5/6', 
18         1 => '5/15', 
19         2 => '5/24'
20       }      
21
22   end
23
24   def test_bar_graph
25     g = Gruff::SideStackedBar.new
26     g.title = "Visual Stacked Bar Graph Test"
27     g.labels = {
28       0 => '5/6', 
29       1 => '5/15', 
30       2 => '5/24', 
31       3 => '5/30', 
32     }
33     @datasets.each do |data|
34       g.data(data[0], data[1])
35     end
36     g.write "test/output/side_stacked_bar_keynote.png"
37   end
38
39
40   def test_bar_graph_small
41     g = Gruff::SideStackedBar.new(400)
42     g.title = "Visual Stacked Bar Graph Test"
43     g.labels = {
44       0 => '5/6', 
45       1 => '5/15', 
46       2 => '5/24', 
47       3 => '5/30', 
48     }
49     @datasets.each do |data|
50       g.data(data[0], data[1])
51     end
52     g.write "test/output/side_stacked_bar_keynote_small.png"
53   end
54
55   def test_wide
56     g = setup_basic_graph('800x400')
57     g.title = "Wide SSBar"
58     g.write "test/output/side_stacked_bar_wide.png"
59   end
60
61   def test_should_space_long_left_labels_appropriately
62     g = Gruff::SideStackedBar.new
63     g.title = "Stacked Bar Long Label"
64     g.labels = {
65       0 => 'September', 
66       1 => 'Oct', 
67       2 => 'Nov', 
68       3 => 'Dec', 
69     }
70     @datasets.each do |data|
71       g.data(data[0], data[1])
72     end
73     g.write "test/output/side_stacked_bar_long_label.png"
74   end
75
76 protected
77
78   def setup_basic_graph(size=800)
79     g = Gruff::SideStackedBar.new(size)
80     g.title = "My Graph Title"
81     g.labels = @sample_labels
82     @datasets.each do |data|
83       g.data(data[0], data[1])
84     end
85     return g
86   end
87
88 end
89

Benjamin Mako Hill || Want to submit a patch?