gruff 0.5.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.editorconfig +14 -0
- data/.github/ISSUE_TEMPLATE.md +18 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +109 -0
- data/.rubocop_todo.yml +130 -0
- data/.travis.yml +24 -12
- data/.yardopts +1 -0
- data/{History.txt → CHANGELOG.md} +61 -25
- data/Gemfile +3 -7
- data/README.md +57 -25
- data/Rakefile +6 -201
- data/assets/plastik/blue.png +0 -0
- data/assets/plastik/green.png +0 -0
- data/assets/plastik/red.png +0 -0
- data/docker/Dockerfile +14 -0
- data/docker/build.sh +4 -0
- data/docker/launch.sh +4 -0
- data/gruff.gemspec +19 -14
- data/init.rb +2 -0
- data/lib/gruff.rb +26 -2
- data/lib/gruff/accumulator_bar.rb +18 -8
- data/lib/gruff/area.rb +33 -19
- data/lib/gruff/bar.rb +76 -45
- data/lib/gruff/base.rb +337 -613
- data/lib/gruff/bezier.rb +34 -19
- data/lib/gruff/bullet.rb +51 -62
- data/lib/gruff/dot.rb +38 -62
- data/lib/gruff/helper/bar_conversion.rb +47 -0
- data/lib/gruff/helper/bar_value_label_mixin.rb +30 -0
- data/lib/gruff/helper/stacked_mixin.rb +23 -0
- data/lib/gruff/histogram.rb +59 -0
- data/lib/gruff/line.rb +130 -150
- data/lib/gruff/mini/bar.rb +17 -10
- data/lib/gruff/mini/legend.rb +24 -36
- data/lib/gruff/mini/pie.rb +18 -12
- data/lib/gruff/mini/side_bar.rb +26 -12
- data/lib/gruff/net.rb +60 -84
- data/lib/gruff/patch/rmagick.rb +33 -0
- data/lib/gruff/patch/string.rb +10 -0
- data/lib/gruff/photo_bar.rb +27 -30
- data/lib/gruff/pie.rb +190 -93
- data/lib/gruff/renderer/bezier.rb +21 -0
- data/lib/gruff/renderer/circle.rb +21 -0
- data/lib/gruff/renderer/dash_line.rb +22 -0
- data/lib/gruff/renderer/dot.rb +39 -0
- data/lib/gruff/renderer/ellipse.rb +21 -0
- data/lib/gruff/renderer/line.rb +34 -0
- data/lib/gruff/renderer/polygon.rb +23 -0
- data/lib/gruff/renderer/polyline.rb +21 -0
- data/lib/gruff/renderer/rectangle.rb +19 -0
- data/lib/gruff/renderer/renderer.rb +127 -0
- data/lib/gruff/renderer/text.rb +42 -0
- data/lib/gruff/scatter.rb +156 -180
- data/lib/gruff/scene.rb +31 -41
- data/lib/gruff/side_bar.rb +77 -63
- data/lib/gruff/side_stacked_bar.rb +77 -60
- data/lib/gruff/spider.rb +37 -50
- data/lib/gruff/stacked_area.rb +32 -30
- data/lib/gruff/stacked_bar.rb +87 -49
- data/lib/gruff/store/base_data.rb +34 -0
- data/lib/gruff/store/custom_data.rb +34 -0
- data/lib/gruff/store/store.rb +80 -0
- data/lib/gruff/store/xy_data.rb +55 -0
- data/lib/gruff/themes.rb +32 -33
- data/lib/gruff/version.rb +3 -1
- metadata +99 -92
- data/Manifest.txt +0 -81
- data/RELEASE.md +0 -30
- data/assets/bubble.png +0 -0
- data/assets/city_scene/background/0000.png +0 -0
- data/assets/city_scene/background/0600.png +0 -0
- data/assets/city_scene/background/2000.png +0 -0
- data/assets/city_scene/clouds/cloudy.png +0 -0
- data/assets/city_scene/clouds/partly_cloudy.png +0 -0
- data/assets/city_scene/clouds/stormy.png +0 -0
- data/assets/city_scene/grass/default.png +0 -0
- data/assets/city_scene/haze/true.png +0 -0
- data/assets/city_scene/number_sample/1.png +0 -0
- data/assets/city_scene/number_sample/2.png +0 -0
- data/assets/city_scene/number_sample/default.png +0 -0
- data/assets/city_scene/sky/0000.png +0 -0
- data/assets/city_scene/sky/0200.png +0 -0
- data/assets/city_scene/sky/0400.png +0 -0
- data/assets/city_scene/sky/0600.png +0 -0
- data/assets/city_scene/sky/0800.png +0 -0
- data/assets/city_scene/sky/1000.png +0 -0
- data/assets/city_scene/sky/1200.png +0 -0
- data/assets/city_scene/sky/1400.png +0 -0
- data/assets/city_scene/sky/1500.png +0 -0
- data/assets/city_scene/sky/1700.png +0 -0
- data/assets/city_scene/sky/2000.png +0 -0
- data/assets/pc306715.jpg +0 -0
- data/lib/gruff/bar_conversion.rb +0 -46
- data/lib/gruff/deprecated.rb +0 -39
- data/lib/gruff/stacked_mixin.rb +0 -23
- data/test/gruff_test_case.rb +0 -154
- data/test/image_compare.rb +0 -58
- data/test/test_accumulator_bar.rb +0 -51
- data/test/test_area.rb +0 -134
- data/test/test_bar.rb +0 -505
- data/test/test_base.rb +0 -8
- data/test/test_bezier.rb +0 -33
- data/test/test_bullet.rb +0 -26
- data/test/test_dot.rb +0 -263
- data/test/test_legend.rb +0 -68
- data/test/test_line.rb +0 -657
- data/test/test_mini_bar.rb +0 -33
- data/test/test_mini_pie.rb +0 -25
- data/test/test_mini_side_bar.rb +0 -36
- data/test/test_net.rb +0 -231
- data/test/test_photo.rb +0 -41
- data/test/test_pie.rb +0 -154
- data/test/test_scatter.rb +0 -233
- data/test/test_scene.rb +0 -100
- data/test/test_side_bar.rb +0 -56
- data/test/test_sidestacked_bar.rb +0 -105
- data/test/test_spider.rb +0 -226
- data/test/test_stacked_area.rb +0 -52
- data/test/test_stacked_bar.rb +0 -52
data/test/test_mini_bar.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.expand_path('../gruff_test_case', __FILE__)
|
3
|
-
|
4
|
-
class TestMiniBar < GruffTestCase
|
5
|
-
|
6
|
-
def test_simple_bar
|
7
|
-
setup_single_dataset
|
8
|
-
g = setup_basic_graph(Gruff::Mini::Bar, 200)
|
9
|
-
g.hide_mini_legend = true
|
10
|
-
write_test_file g, 'mini_bar.png'
|
11
|
-
end
|
12
|
-
|
13
|
-
# def test_simple_bar_wide_dataset
|
14
|
-
# setup_wide_dataset
|
15
|
-
# g = setup_basic_graph(Gruff::Mini::Bar, 200)
|
16
|
-
# write_test_file g, 'mini_bar_wide_data.png'
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# def test_code_sample
|
20
|
-
# g = Gruff::Mini::Bar.new(200)
|
21
|
-
# g.data "Jim", [200, 500, 400]
|
22
|
-
# g.labels = { 0 => 'This Month', 1 => 'Average', 2 => 'Overall'}
|
23
|
-
# g.write "mini_bar_one_color.png"
|
24
|
-
#
|
25
|
-
# g = Gruff::Mini::Bar.new(200)
|
26
|
-
# g.data "Car", 200
|
27
|
-
# g.data "Food", 500
|
28
|
-
# g.data "Art", 1000
|
29
|
-
# g.data "Music", 16
|
30
|
-
# g.write "mini_bar_many_colors.png"
|
31
|
-
# end
|
32
|
-
|
33
|
-
end
|
data/test/test_mini_pie.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.expand_path('../gruff_test_case', __FILE__)
|
2
|
-
|
3
|
-
class TestMiniPie < GruffTestCase
|
4
|
-
|
5
|
-
def test_simple_pie
|
6
|
-
g = setup_basic_graph(Gruff::Mini::Pie, 200)
|
7
|
-
write_test_file g, 'mini_pie.png'
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_pie_with_legend_right
|
11
|
-
g = setup_basic_graph(Gruff::Mini::Pie, 200)
|
12
|
-
g.legend_position = :right
|
13
|
-
write_test_file g, 'mini_pie_right_legend.png'
|
14
|
-
end
|
15
|
-
|
16
|
-
# def test_code_sample
|
17
|
-
# g = Gruff::Mini::Pie.new(200)
|
18
|
-
# g.data "Car", 200
|
19
|
-
# g.data "Food", 500
|
20
|
-
# g.data "Art", 1000
|
21
|
-
# g.data "Music", 16
|
22
|
-
# g.write "mini_pie.png"
|
23
|
-
# end
|
24
|
-
|
25
|
-
end
|
data/test/test_mini_side_bar.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path('../gruff_test_case', __FILE__)
|
2
|
-
|
3
|
-
class TestMiniSideBar < GruffTestCase
|
4
|
-
|
5
|
-
def test_one_color
|
6
|
-
# Use a single data set
|
7
|
-
@datasets = [
|
8
|
-
[:Jimmy, [25, 36, 86, 39]]
|
9
|
-
]
|
10
|
-
@labels = {
|
11
|
-
0 => 'Auto',
|
12
|
-
1 => 'Entertainment',
|
13
|
-
2 => 'Food',
|
14
|
-
3 => 'Bus'
|
15
|
-
}
|
16
|
-
|
17
|
-
g = setup_basic_graph(Gruff::Mini::SideBar, 200)
|
18
|
-
write_test_file g, 'mini_side_bar.png'
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_multi_color
|
22
|
-
# @datasets = [
|
23
|
-
# [:Jimmy, [25, 36, 86, 39]]
|
24
|
-
# ]
|
25
|
-
# @labels = {
|
26
|
-
# 0 => 'Auto',
|
27
|
-
# 1 => 'Entertainment',
|
28
|
-
# 2 => 'Food',
|
29
|
-
# 3 => 'Bus'
|
30
|
-
# }
|
31
|
-
|
32
|
-
g = setup_basic_graph(Gruff::Mini::SideBar, 200)
|
33
|
-
write_test_file g, 'mini_side_bar_multi_color.png'
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
data/test/test_net.rb
DELETED
@@ -1,231 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + "/gruff_test_case"
|
4
|
-
|
5
|
-
class TestGruffNet < GruffTestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
super
|
9
|
-
@datasets = [
|
10
|
-
[:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
|
11
|
-
[:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
|
12
|
-
[:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
|
13
|
-
[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
|
14
|
-
[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
|
15
|
-
["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
|
16
|
-
]
|
17
|
-
|
18
|
-
@sample_labels = {
|
19
|
-
0 => '5/6',
|
20
|
-
1 => '5/15',
|
21
|
-
2 => '5/24',
|
22
|
-
3 => '5/30',
|
23
|
-
4 => '6/4',
|
24
|
-
5 => '6/12',
|
25
|
-
6 => '6/21',
|
26
|
-
7 => '6/28',
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_net_small_values
|
31
|
-
@datasets = [
|
32
|
-
[:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
|
33
|
-
[:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
|
34
|
-
]
|
35
|
-
|
36
|
-
g = Gruff::Net.new
|
37
|
-
g.title = "Small Values Net Graph Test"
|
38
|
-
@datasets.each do |data|
|
39
|
-
g.data(data[0], data[1])
|
40
|
-
end
|
41
|
-
g.write("test/output/net_small.png")
|
42
|
-
|
43
|
-
g = Gruff::Net.new(400)
|
44
|
-
g.title = "Small Values Net Graph Test 400px"
|
45
|
-
@datasets.each do |data|
|
46
|
-
g.data(data[0], data[1])
|
47
|
-
end
|
48
|
-
g.write("test/output/net_small_small.png")
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_net_starts_with_zero
|
52
|
-
@datasets = [
|
53
|
-
[:first0, [0, 5, 10, 8, 18]],
|
54
|
-
[:normal, [1, 2, 3, 4, 5]]
|
55
|
-
]
|
56
|
-
|
57
|
-
g = Gruff::Net.new
|
58
|
-
g.title = "Small Values Net Graph Test"
|
59
|
-
@datasets.each do |data|
|
60
|
-
g.data(data[0], data[1])
|
61
|
-
end
|
62
|
-
g.write("test/output/net_small_zero.png")
|
63
|
-
|
64
|
-
g = Gruff::Net.new(400)
|
65
|
-
g.title = "Small Values Net Graph Test 400px"
|
66
|
-
@datasets.each do |data|
|
67
|
-
g.data(data[0], data[1])
|
68
|
-
end
|
69
|
-
g.write("test/output/net_small_small_zero.png")
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
def test_net_large_values
|
74
|
-
@datasets = [
|
75
|
-
[:large, [100_005, 35_000, 28_000, 27_000]],
|
76
|
-
[:large2, [35_000, 28_000, 27_000, 100_005]],
|
77
|
-
[:large3, [28_000, 27_000, 100_005, 35_000]],
|
78
|
-
[:large4, [1_238, 39_092, 27_938, 48_876]]
|
79
|
-
]
|
80
|
-
|
81
|
-
g = Gruff::Net.new
|
82
|
-
g.title = "Very Large Values Net Graph Test"
|
83
|
-
@datasets.each do |data|
|
84
|
-
g.data(data[0], data[1])
|
85
|
-
end
|
86
|
-
|
87
|
-
g.write("test/output/net_large.png")
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_many_datapoints
|
91
|
-
g = Gruff::Net.new
|
92
|
-
g.title = "Many Multi-Net Graph Test"
|
93
|
-
g.labels = {
|
94
|
-
0 => 'June',
|
95
|
-
10 => 'July',
|
96
|
-
30 => 'August',
|
97
|
-
50 => 'September',
|
98
|
-
}
|
99
|
-
g.data('many points', (0..50).collect {|i| rand(100) })
|
100
|
-
|
101
|
-
# Default theme
|
102
|
-
g.write("test/output/net_many.png")
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
def test_similar_high_end_values
|
107
|
-
g = Gruff::Net.new
|
108
|
-
g.title = "Similar High End Values Test"
|
109
|
-
g.data('similar points', %w(29.43 29.459 29.498 29.53 29.548 29.589 29.619 29.66 29.689 29.849 29.878 29.74 29.769 29.79 29.808 29.828).collect {|i| i.to_f} )
|
110
|
-
|
111
|
-
# Default theme
|
112
|
-
g.write("test/output/net_similar_high_end_values.png")
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_many_nets_graph_small
|
116
|
-
g = Gruff::Net.new(400)
|
117
|
-
g.title = "Many Values Net Test 400px"
|
118
|
-
g.labels = {
|
119
|
-
0 => '5/6',
|
120
|
-
10 => '5/15',
|
121
|
-
20 => '5/24',
|
122
|
-
30 => '5/30',
|
123
|
-
40 => '6/4',
|
124
|
-
50 => '6/16'
|
125
|
-
}
|
126
|
-
%w{jimmy jane philip arthur julie bert}.each do |student_name|
|
127
|
-
g.data(student_name, (0..50).collect { |i| rand 100 })
|
128
|
-
end
|
129
|
-
|
130
|
-
# Default theme
|
131
|
-
g.write("test/output/net_many_nets_small.png")
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_dots_graph_tiny
|
135
|
-
g = Gruff::Net.new(300)
|
136
|
-
g.title = "Dots Test 300px"
|
137
|
-
g.labels = {
|
138
|
-
0 => '5/6',
|
139
|
-
10 => '5/15',
|
140
|
-
20 => '5/24',
|
141
|
-
30 => '5/30',
|
142
|
-
40 => '6/4',
|
143
|
-
50 => '6/16'
|
144
|
-
}
|
145
|
-
%w{jimmy jane philip arthur julie bert}.each do |student_name|
|
146
|
-
g.data(student_name, (0..50).collect { |i| rand 100 })
|
147
|
-
end
|
148
|
-
|
149
|
-
# Default theme
|
150
|
-
g.write("test/output/net_dots_tiny.png")
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_no_data
|
154
|
-
g = Gruff::Net.new(400)
|
155
|
-
g.title = "No Data"
|
156
|
-
# Default theme
|
157
|
-
g.write("test/output/net_no_data.png")
|
158
|
-
|
159
|
-
g = Gruff::Net.new(400)
|
160
|
-
g.title = "No Data Title"
|
161
|
-
g.no_data_message = 'There is no data'
|
162
|
-
g.write("test/output/net_no_data_msg.png")
|
163
|
-
end
|
164
|
-
|
165
|
-
|
166
|
-
def test_all_zeros
|
167
|
-
g = Gruff::Net.new(400)
|
168
|
-
g.title = "All Zeros"
|
169
|
-
|
170
|
-
g.data(:gus, [0,0,0,0])
|
171
|
-
|
172
|
-
# Default theme
|
173
|
-
g.write("test/output/net_no_data_other.png")
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_no_title
|
177
|
-
g = Gruff::Net.new(400)
|
178
|
-
g.labels = @sample_labels
|
179
|
-
@datasets.each do |data|
|
180
|
-
g.data(data[0], data[1])
|
181
|
-
end
|
182
|
-
|
183
|
-
g.write("test/output/net_no_title.png")
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_no_net_markers
|
187
|
-
g = setup_basic_graph(400)
|
188
|
-
g.title = "No Net Markers"
|
189
|
-
g.hide_line_markers = true
|
190
|
-
g.write("test/output/net_no_net_markers.png")
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_no_legend
|
194
|
-
g = setup_basic_graph(400)
|
195
|
-
g.title = "No Legend"
|
196
|
-
g.hide_legend = true
|
197
|
-
g.write("test/output/net_no_legend.png")
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_nothing_but_the_graph
|
201
|
-
g = setup_basic_graph(400)
|
202
|
-
g.title = "THIS TITLE SHOULD NOT DISPLAY!!!"
|
203
|
-
g.hide_line_markers = true
|
204
|
-
g.hide_legend = true
|
205
|
-
g.hide_title = true
|
206
|
-
g.write("test/output/net_nothing_but_the_graph.png")
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_wide_graph
|
210
|
-
g = setup_basic_graph('800x400')
|
211
|
-
g.title = "Wide Graph"
|
212
|
-
g.write("test/output/net_wide_graph.png")
|
213
|
-
|
214
|
-
g = setup_basic_graph('400x200')
|
215
|
-
g.title = "Wide Graph Small"
|
216
|
-
g.write("test/output/net_wide_graph_small.png")
|
217
|
-
end
|
218
|
-
|
219
|
-
protected
|
220
|
-
|
221
|
-
def setup_basic_graph(size=800)
|
222
|
-
g = Gruff::Net.new(size)
|
223
|
-
g.title = "My Graph Title"
|
224
|
-
g.labels = @sample_labels
|
225
|
-
@datasets.each do |data|
|
226
|
-
g.data(data[0], data[1])
|
227
|
-
end
|
228
|
-
return g
|
229
|
-
end
|
230
|
-
|
231
|
-
end
|
data/test/test_photo.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + "/gruff_test_case"
|
4
|
-
|
5
|
-
class TestGruffPhotoBar < GruffTestCase
|
6
|
-
|
7
|
-
# def setup
|
8
|
-
# @datasets = [
|
9
|
-
# [:Jimmy, [25, 36, 86, 39]],
|
10
|
-
# [:Charles, [80, 54, 67, 54]],
|
11
|
-
# # [:Charity, [0, nil, 100, 90]],
|
12
|
-
# ]
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# def test_bar_graph
|
16
|
-
# bar_graph_sized
|
17
|
-
# bar_graph_sized(400)
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# protected
|
22
|
-
#
|
23
|
-
# def bar_graph_sized(size=800)
|
24
|
-
# g = Gruff::PhotoBar.new(size)
|
25
|
-
# g.title = "Photo Bar Graph Test #{size}px"
|
26
|
-
# g.labels = {
|
27
|
-
# 0 => '5/6',
|
28
|
-
# 1 => '5/15',
|
29
|
-
# 2 => '5/24',
|
30
|
-
# 3 => '5/30',
|
31
|
-
# }
|
32
|
-
# @datasets.each do |data|
|
33
|
-
# g.data(*data)
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
# g.theme = 'plastik'
|
37
|
-
#
|
38
|
-
# g.write("test/output/photo_plastik_#{size}.png")
|
39
|
-
# end
|
40
|
-
|
41
|
-
end
|
data/test/test_pie.rb
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + "/gruff_test_case"
|
4
|
-
|
5
|
-
class TestGruffPie < GruffTestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@datasets = [
|
9
|
-
[:Darren, [25]],
|
10
|
-
[:Chris, [80]],
|
11
|
-
[:Egbert, [22]],
|
12
|
-
[:Adam, [95]],
|
13
|
-
[:Bill, [90]],
|
14
|
-
["Frank", [5]],
|
15
|
-
["Zero", [0]],
|
16
|
-
]
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_pie_graph
|
20
|
-
g = Gruff::Pie.new
|
21
|
-
g.title = "Visual Pie Graph Test"
|
22
|
-
@datasets.each do |data|
|
23
|
-
g.data(data[0], data[1])
|
24
|
-
end
|
25
|
-
|
26
|
-
# Default theme
|
27
|
-
g.write("test/output/pie_keynote.png")
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_pie_graph_greyscale
|
31
|
-
g = Gruff::Pie.new
|
32
|
-
g.title = "Greyscale Pie Graph Test"
|
33
|
-
g.theme = Gruff::Themes::GREYSCALE
|
34
|
-
@datasets.each do |data|
|
35
|
-
g.data(data[0], data[1])
|
36
|
-
end
|
37
|
-
|
38
|
-
# Default theme
|
39
|
-
g.write("test/output/pie_grey.png")
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_pie_graph_pastel
|
43
|
-
g = Gruff::Pie.new
|
44
|
-
g.theme = Gruff::Themes::PASTEL
|
45
|
-
g.title = "Pastel Pie Graph Test"
|
46
|
-
@datasets.each do |data|
|
47
|
-
g.data(data[0], data[1])
|
48
|
-
end
|
49
|
-
|
50
|
-
# Default theme
|
51
|
-
g.write("test/output/pie_pastel.png")
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def test_pie_graph_small
|
56
|
-
g = Gruff::Pie.new(400)
|
57
|
-
g.title = "Visual Pie Graph Test Small"
|
58
|
-
@datasets.each do |data|
|
59
|
-
g.data(data[0], data[1])
|
60
|
-
end
|
61
|
-
|
62
|
-
# Default theme
|
63
|
-
g.write("test/output/pie_keynote_small.png")
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_pie_graph_nearly_equal
|
67
|
-
g = Gruff::Pie.new
|
68
|
-
g.title = "Pie Graph Nearly Equal"
|
69
|
-
|
70
|
-
g.data(:Blake, [41])
|
71
|
-
g.data(:Aaron, [42])
|
72
|
-
# g.data(:Grouch, [40])
|
73
|
-
# g.data(:Snuffleupagus, [43])
|
74
|
-
|
75
|
-
g.write("test/output/pie_nearly_equal.png")
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_pie_graph_equal
|
79
|
-
g = Gruff::Pie.new
|
80
|
-
g.title = "Pie Graph Equal"
|
81
|
-
|
82
|
-
g.data(:Bert, [41])
|
83
|
-
g.data(:Adam, [41])
|
84
|
-
|
85
|
-
g.write("test/output/pie_equal.png")
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_pie_graph_zero
|
89
|
-
g = Gruff::Pie.new
|
90
|
-
g.title = "Pie Graph One Zero"
|
91
|
-
|
92
|
-
g.data(:Bert, [0])
|
93
|
-
g.data(:Adam, [1])
|
94
|
-
|
95
|
-
g.write("test/output/pie_zero.png")
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
def test_pie_graph_one_val
|
100
|
-
g = Gruff::Pie.new
|
101
|
-
g.title = "Pie Graph One Val"
|
102
|
-
|
103
|
-
g.data(:Bert, 53)
|
104
|
-
g.data(:Adam, 29)
|
105
|
-
|
106
|
-
g.write("test/output/pie_one_val.png")
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
def test_wide
|
111
|
-
g = setup_basic_graph('800x400')
|
112
|
-
g.title = "Wide Pie"
|
113
|
-
g.write("test/output/pie_wide.png")
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_label_size
|
117
|
-
g = setup_basic_graph()
|
118
|
-
g.title = "Pie With Small Legend"
|
119
|
-
g.legend_font_size = 10
|
120
|
-
g.write("test/output/pie_legend.png")
|
121
|
-
|
122
|
-
g = setup_basic_graph(400)
|
123
|
-
g.title = "Small Pie With Small Legend"
|
124
|
-
g.legend_font_size = 10
|
125
|
-
g.write("test/output/pie_legend_small.png")
|
126
|
-
end
|
127
|
-
|
128
|
-
|
129
|
-
def test_tiny_simple_pie
|
130
|
-
@datasets = (1..5).map {|n| ['Auto', [rand(100)]]}
|
131
|
-
|
132
|
-
g = setup_basic_graph 200
|
133
|
-
g.hide_legend = true
|
134
|
-
g.hide_title = true
|
135
|
-
g.hide_line_numbers = true
|
136
|
-
|
137
|
-
g.marker_font_size = 40.0
|
138
|
-
g.minimum_value = 0.0
|
139
|
-
|
140
|
-
write_test_file g, "pie_simple.png"
|
141
|
-
end
|
142
|
-
|
143
|
-
protected
|
144
|
-
|
145
|
-
def setup_basic_graph(size=800)
|
146
|
-
g = Gruff::Pie.new(size)
|
147
|
-
g.title = "My Graph Title"
|
148
|
-
@datasets.each do |data|
|
149
|
-
g.data(data[0], data[1])
|
150
|
-
end
|
151
|
-
return g
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|