gruff 0.7.0-java → 0.8.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +5 -5
  2. data/.editorconfig +14 -0
  3. data/.rubocop.yml +16 -0
  4. data/.rubocop_todo.yml +923 -0
  5. data/.travis.yml +21 -14
  6. data/{History.txt → CHANGELOG.md} +32 -25
  7. data/README.md +3 -2
  8. data/Rakefile +27 -18
  9. data/assets/bubble.png +0 -0
  10. data/assets/city_scene/background/0000.png +0 -0
  11. data/assets/city_scene/background/0600.png +0 -0
  12. data/assets/city_scene/background/2000.png +0 -0
  13. data/assets/city_scene/clouds/cloudy.png +0 -0
  14. data/assets/city_scene/clouds/partly_cloudy.png +0 -0
  15. data/assets/city_scene/clouds/stormy.png +0 -0
  16. data/assets/city_scene/grass/default.png +0 -0
  17. data/assets/city_scene/haze/true.png +0 -0
  18. data/assets/city_scene/number_sample/1.png +0 -0
  19. data/assets/city_scene/number_sample/2.png +0 -0
  20. data/assets/city_scene/number_sample/default.png +0 -0
  21. data/assets/city_scene/sky/0000.png +0 -0
  22. data/assets/city_scene/sky/0200.png +0 -0
  23. data/assets/city_scene/sky/0400.png +0 -0
  24. data/assets/city_scene/sky/0600.png +0 -0
  25. data/assets/city_scene/sky/0800.png +0 -0
  26. data/assets/city_scene/sky/1000.png +0 -0
  27. data/assets/city_scene/sky/1200.png +0 -0
  28. data/assets/city_scene/sky/1400.png +0 -0
  29. data/assets/city_scene/sky/1500.png +0 -0
  30. data/assets/city_scene/sky/1700.png +0 -0
  31. data/assets/city_scene/sky/2000.png +0 -0
  32. data/assets/pc306715.jpg +0 -0
  33. data/assets/plastik/blue.png +0 -0
  34. data/assets/plastik/green.png +0 -0
  35. data/assets/plastik/red.png +0 -0
  36. data/gruff.gemspec +12 -10
  37. data/lib/gruff.rb +2 -2
  38. data/lib/gruff/accumulator_bar.rb +2 -2
  39. data/lib/gruff/area.rb +1 -4
  40. data/lib/gruff/bar.rb +12 -13
  41. data/lib/gruff/bar_conversion.rb +11 -11
  42. data/lib/gruff/base.rb +36 -36
  43. data/lib/gruff/bezier.rb +1 -2
  44. data/lib/gruff/bullet.rb +7 -10
  45. data/lib/gruff/deprecated.rb +10 -11
  46. data/lib/gruff/dot.rb +3 -4
  47. data/lib/gruff/line.rb +13 -14
  48. data/lib/gruff/mini/bar.rb +3 -3
  49. data/lib/gruff/mini/legend.rb +7 -8
  50. data/lib/gruff/mini/pie.rb +6 -6
  51. data/lib/gruff/mini/side_bar.rb +7 -7
  52. data/lib/gruff/net.rb +2 -8
  53. data/lib/gruff/photo_bar.rb +9 -12
  54. data/lib/gruff/pie.rb +6 -6
  55. data/lib/gruff/scatter.rb +47 -51
  56. data/lib/gruff/scene.rb +17 -19
  57. data/lib/gruff/side_bar.rb +5 -8
  58. data/lib/gruff/side_stacked_bar.rb +24 -26
  59. data/lib/gruff/spider.rb +14 -15
  60. data/lib/gruff/stacked_area.rb +12 -16
  61. data/lib/gruff/stacked_bar.rb +50 -52
  62. data/lib/gruff/stacked_mixin.rb +2 -3
  63. data/lib/gruff/themes.rb +32 -33
  64. data/lib/gruff/version.rb +1 -1
  65. metadata +15 -72
  66. data/RELEASE.md +0 -30
  67. data/test/gruff_test_case.rb +0 -152
  68. data/test/image_compare.rb +0 -58
  69. data/test/test_accumulator_bar.rb +0 -51
  70. data/test/test_area.rb +0 -134
  71. data/test/test_bar.rb +0 -505
  72. data/test/test_base.rb +0 -33
  73. data/test/test_bezier.rb +0 -33
  74. data/test/test_bullet.rb +0 -26
  75. data/test/test_dot.rb +0 -263
  76. data/test/test_labels_for_null_data.rb +0 -27
  77. data/test/test_legend.rb +0 -68
  78. data/test/test_line.rb +0 -674
  79. data/test/test_mini_bar.rb +0 -33
  80. data/test/test_mini_pie.rb +0 -25
  81. data/test/test_mini_side_bar.rb +0 -36
  82. data/test/test_net.rb +0 -231
  83. data/test/test_photo.rb +0 -41
  84. data/test/test_pie.rb +0 -194
  85. data/test/test_scatter.rb +0 -270
  86. data/test/test_scene.rb +0 -100
  87. data/test/test_side_bar.rb +0 -56
  88. data/test/test_sidestacked_bar.rb +0 -105
  89. data/test/test_spider.rb +0 -226
  90. data/test/test_stacked_area.rb +0 -52
  91. data/test/test_stacked_bar.rb +0 -68
@@ -1,33 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- require File.dirname(__FILE__) + "/gruff_test_case"
4
-
5
- class TestGruffBase < GruffTestCase
6
-
7
- def setup
8
- @sample_numeric_labels = {
9
- 0 => 6,
10
- 1 => 15,
11
- 2 => 24,
12
- 3 => 30,
13
- 4 => 4,
14
- 5 => 12,
15
- 6 => 21,
16
- 7 => 28,
17
- }
18
- end
19
-
20
- def test_labels_can_be_any_object
21
- g = Gruff::Bar.new
22
- g.title = 'Bar Graph With Manual Colors'
23
- g.legend_margin = 50
24
- g.labels = @sample_numeric_labels
25
- g.data(:Art, [0, 5, 8, 15], '#990000')
26
- g.data(:Philosophy, [10, 3, 2, 8], '#009900')
27
- g.data(:Science, [2, 15, 8, 11], '#990099')
28
-
29
- g.minimum_value = 0
30
-
31
- g.write('test/output/bar_object_labels.png')
32
- end
33
- end
@@ -1,33 +0,0 @@
1
- require File.dirname(__FILE__) + "/gruff_test_case"
2
-
3
- class TestBezier < GruffTestCase
4
-
5
- def setup
6
- @data_args = [75, 100, {
7
- :target => 80,
8
- :low => 50,
9
- :high => 90
10
- }]
11
- end
12
-
13
- def test_bezier
14
- g = Gruff::Bezier.new
15
- g.title = "Bezier?"
16
- g.data 'Series 1', [0, 100]
17
- g.write("test/output/bezier.png")
18
- end
19
-
20
- def test_bezier_2
21
- g = Gruff::Bezier.new
22
- g.data 'Series 2', [0, 127, 150]
23
- g.write("test/output/bezier_2.png")
24
- end
25
-
26
- def test_bezier_3
27
- g = Gruff::Bezier.new
28
- g.data 'Series 3', [100,300,200,250]
29
- g.minimum_value = 0
30
- g.write("test/output/bezier_3.png")
31
- end
32
-
33
- end
@@ -1,26 +0,0 @@
1
- require File.dirname(__FILE__) + "/gruff_test_case"
2
-
3
- class TestGruffBullet < GruffTestCase
4
-
5
- def setup
6
- @data_args = [75, 100, {
7
- :target => 80,
8
- :low => 50,
9
- :high => 90
10
- }]
11
- end
12
-
13
- def test_bullet_graph
14
- g = Gruff::Bullet.new
15
- g.title = "Monthly Revenue"
16
- g.data(*@data_args)
17
- g.write("test/output/bullet_greyscale.png")
18
- end
19
-
20
- def test_no_options
21
- g = Gruff::Bullet.new
22
- g.data(*@data_args)
23
- g.write("test/output/bullet_no_options.png")
24
- end
25
-
26
- end
@@ -1,263 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- require File.dirname(__FILE__) + '/gruff_test_case'
4
-
5
- class TestGruffDot < GruffTestCase
6
-
7
- # TODO Delete old output files once when starting tests
8
-
9
- def setup
10
- @datasets = [
11
- [:Jimmy, [25, 36, 86, 39]],
12
- [:Charles, [80, 54, 67, 54]],
13
- [:Julie, [22, 29, 35, 38]],
14
- #[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
15
- #[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
16
- #["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
17
- ]
18
- end
19
-
20
- def test_dot_graph
21
- g = setup_basic_graph
22
- g.title = 'Dot Graph Test'
23
- g.write('test/output/dot.png')
24
- end
25
-
26
- def test_dot_graph_set_colors
27
- g = Gruff::Dot.new
28
- g.title = 'Dot Graph With Manual Colors'
29
- g.labels = {
30
- 0 => '5/6',
31
- 1 => '5/15',
32
- 2 => '5/24',
33
- 3 => '5/30',
34
- }
35
- g.data(:Art, [0, 5, 8, 15], '#990000')
36
- g.data(:Philosophy, [10, 3, 2, 8], '#009900')
37
- g.data(:Science, [2, 15, 8, 11], '#990099')
38
-
39
- g.minimum_value = 0
40
-
41
- g.write('test/output/dot_manual_colors.png')
42
- end
43
-
44
- def test_dot_graph_small
45
- g = setup_basic_graph(400)
46
- g.title = 'Visual Multi-Line Dot Graph Test'
47
- g.write('test/output/dot_small.png')
48
- end
49
-
50
- # Somewhat worthless test. Should an error be thrown?
51
- # def test_nil_font
52
- # g = setup_basic_graph 400
53
- # g.title = "Nil Font"
54
- # g.font = nil
55
- # g.write "test/output/dot_nil_font.png"
56
- # end
57
-
58
-
59
- def test_no_line_markers
60
- g = setup_basic_graph(400)
61
- g.title = 'No Line Markers'
62
- g.hide_line_markers = true
63
- g.write('test/output/dot_no_line_markers.png')
64
- end
65
-
66
- def test_no_legend
67
- g = setup_basic_graph(400)
68
- g.title = 'No Legend'
69
- g.hide_legend = true
70
- g.write('test/output/dot_no_legend.png')
71
- end
72
-
73
- def test_no_title
74
- g = setup_basic_graph(400)
75
- g.title = 'No Title'
76
- g.hide_title = true
77
- g.write('test/output/dot_no_title.png')
78
- end
79
-
80
- def test_no_title_or_legend
81
- g = setup_basic_graph(400)
82
- g.title = 'No Title or Legend'
83
- g.hide_legend = true
84
- g.hide_title = true
85
- g.write('test/output/dot_no_title_or_legend.png')
86
- end
87
-
88
- def test_set_marker_count
89
- g = setup_basic_graph(400)
90
- g.title = 'Set marker'
91
- g.marker_count = 10
92
- g.write('test/output/dot_set_marker.png')
93
- end
94
-
95
- def test_set_legend_box_size
96
- g = setup_basic_graph(400)
97
- g.title = 'Set Small Legend Box Size'
98
- g.legend_box_size = 10.0
99
- g.write('test/output/dot_set_legend_box_size_sm.png')
100
-
101
- g = setup_basic_graph(400)
102
- g.title = 'Set Large Legend Box Size'
103
- g.legend_box_size = 50.0
104
- g.write('test/output/dot_set_legend_box_size_lg.png')
105
- end
106
-
107
- def test_x_y_labels
108
- g = setup_basic_graph(400)
109
- g.title = 'X Y Labels'
110
- g.x_axis_label = 'Score (%)'
111
- g.y_axis_label = 'Students'
112
- g.write('test/output/dot_x_y_labels.png')
113
- end
114
-
115
- def test_wide_graph
116
- g = setup_basic_graph('800x400')
117
- g.title = 'Wide Graph'
118
- g.write('test/output/dot_wide_graph.png')
119
-
120
- g = setup_basic_graph('400x200')
121
- g.title = 'Wide Graph Small'
122
- g.write('test/output/dot_wide_graph_small.png')
123
- end
124
-
125
-
126
- def test_tall_graph
127
- g = setup_basic_graph('400x600')
128
- g.title = 'Tall Graph'
129
- g.write('test/output/dot_tall_graph.png')
130
-
131
- g = setup_basic_graph('200x400')
132
- g.title = 'Tall Graph Small'
133
- g.write('test/output/dot_tall_graph_small.png')
134
- end
135
-
136
-
137
- def test_one_value
138
- g = Gruff::Dot.new
139
- g.title = 'One Value Graph Test'
140
- g.labels = {
141
- 0 => '1',
142
- 1 => '2'
143
- }
144
- g.data('one', [1,1])
145
-
146
- g.write('test/output/dot_one_value.png')
147
- end
148
-
149
-
150
- def test_negative
151
- g = Gruff::Dot.new
152
- g.title = 'Pos/Neg Dot Graph Test'
153
- g.labels = {
154
- 0 => '5/6',
155
- 1 => '5/15',
156
- 2 => '5/24',
157
- 3 => '5/30',
158
- }
159
- g.data(:apples, [-1, 0, 4, -4])
160
- g.data(:peaches, [10, 8, 6, 3])
161
-
162
- g.write('test/output/dot_pos_neg.png')
163
- end
164
-
165
-
166
- def test_nearly_zero
167
- g = Gruff::Dot.new
168
- g.title = 'Nearly Zero Graph'
169
- g.labels = {
170
- 0 => '5/6',
171
- 1 => '5/15',
172
- 2 => '5/24',
173
- 3 => '5/30',
174
- }
175
- g.data(:apples, [1, 2, 3, 4])
176
- g.data(:peaches, [4, 3, 2, 1])
177
- g.minimum_value = 0
178
- g.maximum_value = 10
179
- g.write('test/output/dot_nearly_zero_max_10.png')
180
- end
181
-
182
- def test_y_axis_increment
183
- generate_with_y_axis_increment 2.0
184
- generate_with_y_axis_increment 1
185
- generate_with_y_axis_increment 5
186
- generate_with_y_axis_increment 20
187
- end
188
-
189
- def generate_with_y_axis_increment(increment)
190
- g = Gruff::Dot.new
191
- g.title = "Y Axis Set to #{increment}"
192
- g.labels = {
193
- 0 => '5/6',
194
- 1 => '5/15',
195
- 2 => '5/24',
196
- 3 => '5/30',
197
- }
198
- g.y_axis_increment = increment
199
- g.data(:apples, [1, 0.2, 0.5, 0.7])
200
- g.data(:peaches, [2.5, 2.3, 2, 6.1])
201
- g.write("test/output/dot_y_increment_#{increment}.png")
202
- end
203
-
204
-
205
- def test_custom_theme
206
- g = Gruff::Dot.new
207
- g.title = 'Custom Theme'
208
- g.font = File.expand_path('CREABBRG.TTF', ENV['MAGICK_FONT_PATH'])
209
- g.title_font_size = 60
210
- g.legend_font_size = 32
211
- g.marker_font_size = 32
212
- g.theme = {
213
- :colors => %w(#efd250 #666699 #e5573f #9595e2),
214
- :marker_color => 'white',
215
- :font_color => 'blue',
216
- :background_image => 'assets/pc306715.jpg'
217
- }
218
- g.labels = {
219
- 0 => '5/6',
220
- 1 => '5/15',
221
- 2 => '5/24',
222
- 3 => '5/30',
223
- }
224
- g.data(:vancouver, [1, 2, 3, 4])
225
- g.data(:seattle, [2, 4, 6, 8])
226
- g.data(:portland, [3, 1, 7, 3])
227
- g.data(:victoria, [4, 3, 5, 7])
228
- g.minimum_value = 0
229
- g.write('test/output/dot_themed.png')
230
- end
231
-
232
- def test_july_enhancements
233
- g = Gruff::Dot.new(600)
234
- g.hide_legend = true
235
- g.title = 'Full speed ahead'
236
- g.labels = (0..10).inject({}) { |memo, i| memo.merge({ i => (i*10).to_s}) }
237
- g.data(:apples, [1.7, 0.8, 0.1, 1.9, 1.4, 0.6, 1.1, 0.7, 1.4, 0.2])
238
- g.y_axis_increment = 1.0
239
- g.x_axis_label = 'Score (%)'
240
- g.y_axis_label = 'Students'
241
- write_test_file g, 'enhancements_dot.png'
242
- end
243
-
244
-
245
- protected
246
-
247
- def setup_basic_graph(size=800)
248
- g = Gruff::Dot.new(size)
249
- g.title = 'My Dot Graph'
250
- g.labels = {
251
- 0 => '5/6',
252
- 1 => '5/15',
253
- 2 => '5/24',
254
- 3 => '5/30',
255
- }
256
- @datasets.each do |data|
257
- g.data(data[0], data[1])
258
- end
259
- g
260
- end
261
-
262
- end
263
-
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + "/gruff_test_case"
2
-
3
- class TestLabelsForNullData < GruffTestCase
4
-
5
- def setup
6
- @dataset = [nil, 1, 2, 1, nil]
7
-
8
- @labels = {
9
- 0 => '1',
10
- 1 => '2',
11
- 2 => '3',
12
- 3 => '4',
13
- 4 => '5'
14
- }
15
- end
16
-
17
- def test_labels
18
- g = Gruff::Line.new
19
- g.title = 'Labels For Null Data'
20
- g.labels = @labels
21
- g.data('data', @dataset)
22
- g.minimum_value = 0
23
-
24
- g.write("test/output/TestLabelsForNullData.png")
25
- end
26
-
27
- end
@@ -1,68 +0,0 @@
1
- require File.dirname(__FILE__) + '/gruff_test_case'
2
-
3
- class TestGruffLegend < GruffTestCase
4
-
5
- def setup
6
- @datasets = [
7
- [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
8
- [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
9
- [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
10
- [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
11
- [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
12
- [:Arthur, [5, 10, 13, 11, 6, 16, 22, 32]],
13
- [:Vincent, [5, 10, 13, 11, 6, 16, 22, 32]],
14
- [:Jake, [5, 10, 13, 11, 6, 16, 22, 32]],
15
- [:Stephen, [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 full_suite_for(name, type)
31
- [800, 400].each do |width|
32
- [nil, 4, 16, 30].each do |font_size|
33
- g = type.new(width)
34
- g.title = "Wrapped Legend Bar Test #{font_size}pts #{width}px"
35
- g.labels = @sample_labels
36
- 0xEFD250.step(0xFF0000, 60) do |num|
37
- g.colors << '#%x' % num
38
- end
39
-
40
- @datasets.each do |data|
41
- g.data(data[0], data[1])
42
- end
43
-
44
- g.legend_font_size = font_size unless font_size.nil?
45
- g.write("test/output/#{name}_wrapped_legend_#{font_size}_#{width}.png")
46
- end
47
- end
48
- end
49
-
50
- def test_bar_legend_wrap
51
- full_suite_for(:bar, Gruff::Bar)
52
- end
53
-
54
- def test_pie_legend_wrap
55
- full_suite_for(:pie, Gruff::Pie)
56
- end
57
-
58
- def test_more_than_two_lines_of_legends
59
- @datasets = @datasets + [[:Julie2, [22, 29, 35, 38, 36, 40, 46, 57]],
60
- [:Jane2, [95, 95, 95, 90, 85, 80, 88, 100]],
61
- [:Philip2, [90, 34, 23, 12, 78, 89, 98, 88]],
62
- [:Arthur2, [5, 10, 13, 11, 6, 16, 22, 32]],
63
- [:Vincent2, [5, 10, 13, 11, 6, 16, 22, 32]],
64
- [:Jake2, [5, 10, 13, 11, 6, 16, 22, 32]],
65
- [:Stephen2, [5, 10, 13, 11, 6, 16, 22, 32]]]
66
- full_suite_for(:bar2, Gruff::Bar)
67
- end
68
- end