3 require File.dirname(__FILE__) + "/gruff_test_case"
5 class TestGruffPie < GruffTestCase
21 g.title = "Visual Pie Graph Test"
22 @datasets.each do |data|
23 g.data(data[0], data[1])
27 g.write("test/output/pie_keynote.png")
30 def test_pie_graph_small
31 g = Gruff::Pie.new(400)
32 g.title = "Visual Pie Graph Test Small"
33 @datasets.each do |data|
34 g.data(data[0], data[1])
38 g.write("test/output/pie_keynote_small.png")
41 def test_pie_graph_nearly_equal
43 g.title = "Pie Graph Nearly Equal"
47 # g.data(:Grouch, [40])
48 # g.data(:Snuffleupagus, [43])
50 g.write("test/output/pie_nearly_equal.png")
53 def test_pie_graph_equal
55 g.title = "Pie Graph Equal"
60 g.write("test/output/pie_equal.png")
63 def test_pie_graph_zero
65 g.title = "Pie Graph One Zero"
70 g.write("test/output/pie_zero.png")
74 def test_pie_graph_one_val
76 g.title = "Pie Graph One Val"
81 g.write("test/output/pie_one_val.png")
86 g = setup_basic_graph('800x400')
88 g.write("test/output/pie_wide.png")
92 g = setup_basic_graph()
93 g.title = "Pie With Small Legend"
94 g.legend_font_size = 10
95 g.write("test/output/pie_legend.png")
97 g = setup_basic_graph(400)
98 g.title = "Small Pie With Small Legend"
99 g.legend_font_size = 10
100 g.write("test/output/pie_legend_small.png")
104 def test_tiny_simple_pie
105 @datasets = (1..5).map {|n| ['Auto', [rand(100)]]}
107 g = setup_basic_graph 200
110 g.hide_line_numbers = true
112 g.marker_font_size = 40.0
113 g.minimum_value = 0.0
115 write_test_file g, "pie_simple.png"
120 def setup_basic_graph(size=800)
121 g = Gruff::Pie.new(size)
122 g.title = "My Graph Title"
123 @datasets.each do |data|
124 g.data(data[0], data[1])