rmagick4j 0.3.4-java → 0.3.9-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.txt +84 -0
- data/LICENSE.txt +31 -0
- data/README.txt +25 -0
- data/Rakefile +65 -0
- data/lib/magick4j.jar +0 -0
- data/lib/{RMagick.rb → rmagick.rb} +574 -405
- data/lib/rmagick4j/constants.rb +34 -0
- data/lib/rmagick4j/draw.rb +124 -0
- data/lib/rmagick4j/enum.rb +120 -0
- data/lib/rmagick4j/gradient_fill.rb +14 -0
- data/lib/rmagick4j/image.rb +351 -0
- data/lib/rmagick4j/image_list.rb +25 -0
- data/lib/rmagick4j/pixel.rb +170 -0
- data/lib/rmagick4j/rmagick4j.rb +15 -430
- data/lib/rmagick4j/texture_fill.rb +14 -0
- data/lib/rmagick4j/type_metric.rb +8 -0
- data/lib/rmagick4j/version.rb +5 -0
- data/lib/rvg/clippath.rb +2 -2
- data/lib/rvg/container.rb +2 -2
- data/lib/rvg/describable.rb +2 -2
- data/lib/rvg/embellishable.rb +2 -2
- data/lib/rvg/misc.rb +3 -3
- data/lib/rvg/paint.rb +7 -2
- data/lib/rvg/pathdata.rb +2 -2
- data/lib/rvg/rvg.rb +3 -3
- data/lib/rvg/stretchable.rb +15 -3
- data/lib/rvg/stylable.rb +2 -2
- data/lib/rvg/text.rb +2 -2
- data/lib/rvg/transformable.rb +2 -2
- data/lib/rvg/units.rb +2 -2
- data/test/RMagickTestSuite.rb +129 -0
- data/test/eyetests/bullseye.rb +151 -0
- data/test/eyetests/doc.rb +79 -0
- data/test/eyetests/tests/draw_arc_basic.rb +16 -0
- data/test/eyetests/tests/draw_circle_affine.rb +19 -0
- data/test/eyetests/tests/draw_circle_basic.rb +16 -0
- data/test/eyetests/tests/draw_clip_path.rb +44 -0
- data/test/eyetests/tests/draw_ellipse_affine.rb +19 -0
- data/test/eyetests/tests/draw_ellipse_basic.rb +16 -0
- data/test/eyetests/tests/draw_line_affine.rb +24 -0
- data/test/eyetests/tests/draw_line_basic.rb +21 -0
- data/test/eyetests/tests/draw_multiline_type_metrics.rb +42 -0
- data/test/eyetests/tests/draw_pattern_1.rb +35 -0
- data/test/eyetests/tests/draw_polygon_affine.rb +22 -0
- data/test/eyetests/tests/draw_polygon_basic.rb +19 -0
- data/test/eyetests/tests/draw_polyline_affine.rb +19 -0
- data/test/eyetests/tests/draw_polyline_basic.rb +18 -0
- data/test/eyetests/tests/draw_pop_push.rb +16 -0
- data/test/eyetests/tests/draw_pop_push_translate.rb +22 -0
- data/test/eyetests/tests/draw_rectangle_affine.rb +16 -0
- data/test/eyetests/tests/draw_rectangle_basic.rb +16 -0
- data/test/eyetests/tests/draw_rectangle_narrow.rb +18 -0
- data/test/eyetests/tests/draw_rmagick_test_01.rb +35 -0
- data/test/eyetests/tests/draw_rmagick_test_02.rb +40 -0
- data/test/eyetests/tests/draw_rmagick_test_03.rb +17 -0
- data/test/eyetests/tests/draw_rmagick_test_04.rb +21 -0
- data/test/eyetests/tests/draw_rotate_01.rb +33 -0
- data/test/eyetests/tests/draw_roundrectangle_affine.rb +19 -0
- data/test/eyetests/tests/draw_roundrectangle_basic.rb +16 -0
- data/test/eyetests/tests/draw_scale_01.rb +33 -0
- data/test/eyetests/tests/draw_skewx_01.rb +34 -0
- data/test/eyetests/tests/draw_skewy_01.rb +33 -0
- data/test/eyetests/tests/draw_stroke_miterlimit.rb +21 -0
- data/test/eyetests/tests/effect_blur.rb +9 -0
- data/test/eyetests/tests/effect_charcoal.rb +9 -0
- data/test/eyetests/tests/effect_edge.rb +9 -0
- data/test/eyetests/tests/effect_implode.rb +9 -0
- data/test/eyetests/tests/effect_negate.rb +9 -0
- data/test/eyetests/tests/effect_negate_true.rb +9 -0
- data/test/eyetests/tests/effect_normalize.rb +9 -0
- data/test/eyetests/tests/effect_shade.rb +9 -0
- data/test/eyetests/tests/effect_solarize.rb +10 -0
- data/test/eyetests/tests/effect_wave.rb +9 -0
- data/test/eyetests/tests/gradient_fill_horizontal_diagonal_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_horizontal_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_point_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_vertical_diagonal_fill.rb +9 -0
- data/test/eyetests/tests/gradient_fill_vertical_fill.rb +9 -0
- data/test/eyetests/tests/gruff_accumulator_bar.rb +29 -0
- data/test/eyetests/tests/gruff_area_1.rb +16 -0
- data/test/eyetests/tests/gruff_area_2.rb +27 -0
- data/test/eyetests/tests/gruff_bar_1.rb +29 -0
- data/test/eyetests/tests/gruff_bar_2.rb +19 -0
- data/test/eyetests/tests/gruff_dot_1.rb +19 -0
- data/test/eyetests/tests/gruff_line_1.rb +13 -0
- data/test/eyetests/tests/gruff_line_2.rb +20 -0
- data/test/eyetests/tests/gruff_net_1.rb +16 -0
- data/test/eyetests/tests/gruff_net_2.rb +16 -0
- data/test/eyetests/tests/gruff_pie_1.rb +21 -0
- data/test/eyetests/tests/gruff_pie_2.rb +22 -0
- data/test/eyetests/tests/gruff_scene_1.rb +14 -0
- data/test/eyetests/tests/gruff_scene_2.rb +14 -0
- data/test/eyetests/tests/gruff_sidebar.rb +32 -0
- data/test/eyetests/tests/gruff_sidestacked_bar_1.rb +26 -0
- data/test/eyetests/tests/gruff_sidestacked_bar_2.rb +26 -0
- data/test/eyetests/tests/gruff_spider_1.rb +22 -0
- data/test/eyetests/tests/gruff_spider_2.rb +15 -0
- data/test/eyetests/tests/gruff_stacked_area_1.rb +23 -0
- data/test/eyetests/tests/gruff_stacked_bar_1.rb +23 -0
- data/test/eyetests/tests/gruff_stacked_bar_2.rb +26 -0
- data/test/eyetests/tests/hatch_fill.rb +9 -0
- data/test/eyetests/tests/image_list_flatten_images.rb +15 -0
- data/test/eyetests/tests/new_image.rb +31 -0
- data/test/eyetests/tests/path_a_command_01.rb +16 -0
- data/test/eyetests/tests/path_a_command_02.rb +19 -0
- data/test/eyetests/tests/path_c_command_01.rb +16 -0
- data/test/eyetests/tests/path_c_command_02.rb +16 -0
- data/test/eyetests/tests/path_complex_01.rb +16 -0
- data/test/eyetests/tests/path_espiral_01.rb +29 -0
- data/test/eyetests/tests/path_h_command_01.rb +16 -0
- data/test/eyetests/tests/path_h_command_02.rb +16 -0
- data/test/eyetests/tests/path_l_command_01.rb +16 -0
- data/test/eyetests/tests/path_l_command_02.rb +16 -0
- data/test/eyetests/tests/path_m_command_01.rb +16 -0
- data/test/eyetests/tests/path_m_command_02.rb +16 -0
- data/test/eyetests/tests/path_m_command_03.rb +16 -0
- data/test/eyetests/tests/path_q_command_01.rb +16 -0
- data/test/eyetests/tests/path_q_command_02.rb +16 -0
- data/test/eyetests/tests/path_q_command_03.rb +25 -0
- data/test/eyetests/tests/path_s_command_01.rb +16 -0
- data/test/eyetests/tests/path_s_command_02.rb +16 -0
- data/test/eyetests/tests/path_star_01.rb +19 -0
- data/test/eyetests/tests/path_t_command_01.rb +16 -0
- data/test/eyetests/tests/path_t_command_02.rb +16 -0
- data/test/eyetests/tests/path_v_command_01.rb +16 -0
- data/test/eyetests/tests/path_v_command_02.rb +16 -0
- data/test/eyetests/tests/store_pixel_smiley.rb +123 -0
- data/test/eyetests/tests/texture_fill.rb +11 -0
- data/test/gruff_tests/test/gruff_test_case.rb +123 -0
- data/test/gruff_tests/test/monkey_gruff.rb +7 -0
- data/test/gruff_tests/test/test_accumulator_bar.rb +50 -0
- data/test/gruff_tests/test/test_area.rb +134 -0
- data/test/gruff_tests/test/test_bar.rb +295 -0
- data/test/gruff_tests/test/test_base.rb +8 -0
- data/test/gruff_tests/test/test_bullet.rb +26 -0
- data/test/gruff_tests/test/test_dot.rb +273 -0
- data/test/gruff_tests/test/test_legend.rb +68 -0
- data/test/gruff_tests/test/test_line.rb +554 -0
- data/test/gruff_tests/test/test_mini_bar.rb +33 -0
- data/test/gruff_tests/test/test_mini_pie.rb +20 -0
- data/test/gruff_tests/test/test_mini_side_bar.rb +37 -0
- data/test/gruff_tests/test/test_net.rb +230 -0
- data/test/gruff_tests/test/test_photo.rb +41 -0
- data/test/gruff_tests/test/test_pie.rb +154 -0
- data/test/gruff_tests/test/test_scene.rb +100 -0
- data/test/gruff_tests/test/test_side_bar.rb +12 -0
- data/test/gruff_tests/test/test_sidestacked_bar.rb +89 -0
- data/test/gruff_tests/test/test_spider.rb +216 -0
- data/test/gruff_tests/test/test_stacked_area.rb +52 -0
- data/test/gruff_tests/test/test_stacked_bar.rb +52 -0
- data/test/images/clown.jpg +0 -0
- data/test/images/texture.jpg +0 -0
- data/test/implemented_methods.rb +18 -0
- data/test/spec/draw_spec.rb +43 -0
- data/test/spec/features/step_definitions/geometry_steps.rb +22 -0
- data/test/spec/features/step_definitions/image_filling_steps.rb +49 -0
- data/test/spec/features/support/env.rb +3 -0
- data/test/spec/image_constants.rb +76 -0
- data/test/spec/image_spec.rb +83 -0
- data/test/spec/pixel_spec.rb +89 -0
- metadata +333 -45
- data/lib/RMagick.jar +0 -0
- data/lib/jhlabs-filters.jar +0 -0
@@ -0,0 +1,26 @@
|
|
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 127, 150
|
23
|
+
# g.write("test/output/bullet_no_options.png")
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# end
|
@@ -0,0 +1,273 @@
|
|
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_keynote.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 = Gruff::Dot.new(400)
|
46
|
+
g.title = "Visual Multi-Line Dot Graph Test"
|
47
|
+
g.labels = {
|
48
|
+
0 => '5/6',
|
49
|
+
1 => '5/15',
|
50
|
+
2 => '5/24',
|
51
|
+
3 => '5/30',
|
52
|
+
}
|
53
|
+
@datasets.each do |data|
|
54
|
+
g.data(data[0], data[1])
|
55
|
+
end
|
56
|
+
|
57
|
+
g.write("test/output/dot_keynote_small.png")
|
58
|
+
end
|
59
|
+
|
60
|
+
# Somewhat worthless test. Should an error be thrown?
|
61
|
+
# def test_nil_font
|
62
|
+
# g = setup_basic_graph 400
|
63
|
+
# g.title = "Nil Font"
|
64
|
+
# g.font = nil
|
65
|
+
# g.write "test/output/dot_nil_font.png"
|
66
|
+
# end
|
67
|
+
|
68
|
+
|
69
|
+
def test_no_line_markers
|
70
|
+
g = setup_basic_graph(400)
|
71
|
+
g.title = "No Line Markers"
|
72
|
+
g.hide_line_markers = true
|
73
|
+
g.write("test/output/dot_no_line_markers.png")
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_no_legend
|
77
|
+
g = setup_basic_graph(400)
|
78
|
+
g.title = "No Legend"
|
79
|
+
g.hide_legend = true
|
80
|
+
g.write("test/output/dot_no_legend.png")
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_no_title
|
84
|
+
g = setup_basic_graph(400)
|
85
|
+
g.title = "No Title"
|
86
|
+
g.hide_title = true
|
87
|
+
g.write("test/output/dot_no_title.png")
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_no_title_or_legend
|
91
|
+
g = setup_basic_graph(400)
|
92
|
+
g.title = "No Title or Legend"
|
93
|
+
g.hide_legend = true
|
94
|
+
g.hide_title = true
|
95
|
+
g.write("test/output/dot_no_title_or_legend.png")
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_set_marker_count
|
99
|
+
g = setup_basic_graph(400)
|
100
|
+
g.title = "Set marker"
|
101
|
+
g.marker_count = 10
|
102
|
+
g.write("test/output/dot_set_marker.png")
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_set_legend_box_size
|
106
|
+
g = setup_basic_graph(400)
|
107
|
+
g.title = "Set Small Legend Box Size"
|
108
|
+
g.legend_box_size = 10.0
|
109
|
+
g.write("test/output/dot_set_legend_box_size_sm.png")
|
110
|
+
|
111
|
+
g = setup_basic_graph(400)
|
112
|
+
g.title = "Set Large Legend Box Size"
|
113
|
+
g.legend_box_size = 50.0
|
114
|
+
g.write("test/output/dot_set_legend_box_size_lg.png")
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_x_y_labels
|
118
|
+
g = setup_basic_graph(400)
|
119
|
+
g.title = "X Y Labels"
|
120
|
+
g.x_axis_label = 'Score (%)'
|
121
|
+
g.y_axis_label = "Students"
|
122
|
+
g.write("test/output/dot_x_y_labels.png")
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_wide_graph
|
126
|
+
g = setup_basic_graph('800x400')
|
127
|
+
g.title = "Wide Graph"
|
128
|
+
g.write("test/output/dot_wide_graph.png")
|
129
|
+
|
130
|
+
g = setup_basic_graph('400x200')
|
131
|
+
g.title = "Wide Graph Small"
|
132
|
+
g.write("test/output/dot_wide_graph_small.png")
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def test_tall_graph
|
137
|
+
g = setup_basic_graph('400x600')
|
138
|
+
g.title = "Tall Graph"
|
139
|
+
g.write("test/output/dot_tall_graph.png")
|
140
|
+
|
141
|
+
g = setup_basic_graph('200x400')
|
142
|
+
g.title = "Tall Graph Small"
|
143
|
+
g.write("test/output/dot_tall_graph_small.png")
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
def test_one_value
|
148
|
+
g = Gruff::Dot.new
|
149
|
+
g.title = "One Value Graph Test"
|
150
|
+
g.labels = {
|
151
|
+
0 => '1',
|
152
|
+
1 => '2'
|
153
|
+
}
|
154
|
+
g.data('one', [1,1])
|
155
|
+
|
156
|
+
g.write("test/output/dot_one_value.png")
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
def test_negative
|
161
|
+
g = Gruff::Dot.new
|
162
|
+
g.title = "Pos/Neg Dot Graph Test"
|
163
|
+
g.labels = {
|
164
|
+
0 => '5/6',
|
165
|
+
1 => '5/15',
|
166
|
+
2 => '5/24',
|
167
|
+
3 => '5/30',
|
168
|
+
}
|
169
|
+
g.data(:apples, [-1, 0, 4, -4])
|
170
|
+
g.data(:peaches, [10, 8, 6, 3])
|
171
|
+
|
172
|
+
g.write("test/output/dot_pos_neg.png")
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def test_nearly_zero
|
177
|
+
g = Gruff::Dot.new
|
178
|
+
g.title = "Nearly Zero Graph"
|
179
|
+
g.labels = {
|
180
|
+
0 => '5/6',
|
181
|
+
1 => '5/15',
|
182
|
+
2 => '5/24',
|
183
|
+
3 => '5/30',
|
184
|
+
}
|
185
|
+
g.data(:apples, [1, 2, 3, 4])
|
186
|
+
g.data(:peaches, [4, 3, 2, 1])
|
187
|
+
g.minimum_value = 0
|
188
|
+
g.maximum_value = 10
|
189
|
+
g.write("test/output/dot_nearly_zero_max_10.png")
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_y_axis_increment
|
193
|
+
generate_with_y_axis_increment 2.0
|
194
|
+
generate_with_y_axis_increment 1
|
195
|
+
generate_with_y_axis_increment 5
|
196
|
+
generate_with_y_axis_increment 20
|
197
|
+
end
|
198
|
+
|
199
|
+
def generate_with_y_axis_increment(increment)
|
200
|
+
g = Gruff::Dot.new
|
201
|
+
g.title = "Y Axis Set to #{increment}"
|
202
|
+
g.labels = {
|
203
|
+
0 => '5/6',
|
204
|
+
1 => '5/15',
|
205
|
+
2 => '5/24',
|
206
|
+
3 => '5/30',
|
207
|
+
}
|
208
|
+
g.y_axis_increment = increment
|
209
|
+
g.data(:apples, [1, 0.2, 0.5, 0.7])
|
210
|
+
g.data(:peaches, [2.5, 2.3, 2, 6.1])
|
211
|
+
g.write("test/output/dot_y_increment_#{increment}.png")
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
def test_custom_theme
|
216
|
+
g = Gruff::Dot.new
|
217
|
+
g.title = "Custom Theme"
|
218
|
+
g.font = File.expand_path('CREABBRG.TTF', ENV['MAGICK_FONT_PATH'])
|
219
|
+
g.title_font_size = 60
|
220
|
+
g.legend_font_size = 32
|
221
|
+
g.marker_font_size = 32
|
222
|
+
g.theme = {
|
223
|
+
:colors => %w(#efd250 #666699 #e5573f #9595e2),
|
224
|
+
:marker_color => 'white',
|
225
|
+
:font_color => 'blue',
|
226
|
+
:background_image => "assets/pc306715.jpg"
|
227
|
+
}
|
228
|
+
g.labels = {
|
229
|
+
0 => '5/6',
|
230
|
+
1 => '5/15',
|
231
|
+
2 => '5/24',
|
232
|
+
3 => '5/30',
|
233
|
+
}
|
234
|
+
g.data(:vancouver, [1, 2, 3, 4])
|
235
|
+
g.data(:seattle, [2, 4, 6, 8])
|
236
|
+
g.data(:portland, [3, 1, 7, 3])
|
237
|
+
g.data(:victoria, [4, 3, 5, 7])
|
238
|
+
g.minimum_value = 0
|
239
|
+
g.write("test/output/dot_themed.png")
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_july_enhancements
|
243
|
+
g = Gruff::Dot.new(600)
|
244
|
+
g.hide_legend = true
|
245
|
+
g.title = "Full speed ahead"
|
246
|
+
g.labels = (0..10).inject({}) { |memo, i| memo.merge({ i => (i*10).to_s}) }
|
247
|
+
g.data(:apples, (0..9).map { rand(20)/10.0 })
|
248
|
+
g.y_axis_increment = 1.0
|
249
|
+
g.x_axis_label = 'Score (%)'
|
250
|
+
g.y_axis_label = 'Students'
|
251
|
+
write_test_file g, 'enhancements.png'
|
252
|
+
end
|
253
|
+
|
254
|
+
|
255
|
+
protected
|
256
|
+
|
257
|
+
def setup_basic_graph(size=800)
|
258
|
+
g = Gruff::Dot.new(size)
|
259
|
+
g.title = "My Dot Graph"
|
260
|
+
g.labels = {
|
261
|
+
0 => '5/6',
|
262
|
+
1 => '5/15',
|
263
|
+
2 => '5/24',
|
264
|
+
3 => '5/30',
|
265
|
+
}
|
266
|
+
@datasets.each do |data|
|
267
|
+
g.data(data[0], data[1])
|
268
|
+
end
|
269
|
+
g
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
@@ -0,0 +1,68 @@
|
|
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
|
@@ -0,0 +1,554 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + "/gruff_test_case"
|
4
|
+
|
5
|
+
class TestGruffLine < GruffTestCase
|
6
|
+
|
7
|
+
# TODO Delete old output files once when starting tests
|
8
|
+
|
9
|
+
def test_should_render_with_transparent_theme
|
10
|
+
g = Gruff::Line.new(400)
|
11
|
+
g.title = "Transparent Background"
|
12
|
+
g.theme = {
|
13
|
+
:colors => ['black', 'grey'],
|
14
|
+
:marker_color => 'grey',
|
15
|
+
:font_color => 'black',
|
16
|
+
:background_colors => 'transparent'
|
17
|
+
}
|
18
|
+
|
19
|
+
g.labels = {
|
20
|
+
0 => '5/6',
|
21
|
+
1 => '5/15',
|
22
|
+
2 => '5/24',
|
23
|
+
3 => '5/30',
|
24
|
+
}
|
25
|
+
g.data(:apples, [-1, 0, 4, -4])
|
26
|
+
g.data(:peaches, [10, 8, 6, 3])
|
27
|
+
g.write("test/output/line_transparent.png")
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_line_graph_with_themes
|
31
|
+
line_graph_with_themes()
|
32
|
+
line_graph_with_themes(400)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_one_value
|
36
|
+
g = Gruff::Line.new
|
37
|
+
g.title = "One Value"
|
38
|
+
g.labels = {
|
39
|
+
0 => '1',
|
40
|
+
1 => '2'
|
41
|
+
}
|
42
|
+
g.data('one', 1)
|
43
|
+
|
44
|
+
g.write("test/output/line_one_value.png")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_one_value_array
|
48
|
+
g = Gruff::Line.new
|
49
|
+
g.title = "One Value in an Array"
|
50
|
+
g.labels = {
|
51
|
+
0 => '1',
|
52
|
+
1 => '2'
|
53
|
+
}
|
54
|
+
g.data('one', [1])
|
55
|
+
|
56
|
+
g.write("test/output/line_one_value_array.png")
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def test_should_not_hang_with_0_0_100
|
61
|
+
g = Gruff::Line.new(320)
|
62
|
+
g.title = "Hang Value Graph Test"
|
63
|
+
g.data('test', [0,0,100])
|
64
|
+
|
65
|
+
g.write("test/output/line_hang_value.png")
|
66
|
+
end
|
67
|
+
|
68
|
+
# TODO
|
69
|
+
# def test_fix_crash
|
70
|
+
# g = Gruff::Line.new(370)
|
71
|
+
# g.title = "Crash Test"
|
72
|
+
# g.data "ichi", [5]
|
73
|
+
# g.data "ni", [0]
|
74
|
+
# g.data "san", [0]
|
75
|
+
# g.data "shi", [0]
|
76
|
+
# g.write("test/output/line_crash_fix_test.png")
|
77
|
+
# end
|
78
|
+
|
79
|
+
|
80
|
+
def test_line_small_values
|
81
|
+
@datasets = [
|
82
|
+
[:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
|
83
|
+
[:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
|
84
|
+
]
|
85
|
+
|
86
|
+
g = Gruff::Line.new
|
87
|
+
g.title = "Small Values Line Graph Test"
|
88
|
+
@datasets.each do |data|
|
89
|
+
g.data(data[0], data[1])
|
90
|
+
end
|
91
|
+
g.write("test/output/line_small.png")
|
92
|
+
|
93
|
+
g = Gruff::Line.new(400)
|
94
|
+
g.title = "Small Values Line Graph Test 400px"
|
95
|
+
@datasets.each do |data|
|
96
|
+
g.data(data[0], data[1])
|
97
|
+
end
|
98
|
+
g.write("test/output/line_small_small.png")
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_line_starts_with_zero
|
102
|
+
@datasets = [
|
103
|
+
[:first0, [0, 5, 10, 8, 18]],
|
104
|
+
[:normal, [1, 2, 3, 4, 5]]
|
105
|
+
]
|
106
|
+
|
107
|
+
g = Gruff::Line.new
|
108
|
+
g.title = "Small Values Line Graph Test"
|
109
|
+
@datasets.each do |data|
|
110
|
+
g.data(data[0], data[1])
|
111
|
+
end
|
112
|
+
g.write("test/output/line_small_zero.png")
|
113
|
+
|
114
|
+
g = Gruff::Line.new(400)
|
115
|
+
g.title = "Small Values Line Graph Test 400px"
|
116
|
+
@datasets.each do |data|
|
117
|
+
g.data(data[0], data[1])
|
118
|
+
end
|
119
|
+
g.write("test/output/line_small_small_zero.png")
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def test_line_large_values
|
124
|
+
@datasets = [
|
125
|
+
[:large, [100_005, 35_000, 28_000, 27_000]],
|
126
|
+
[:large2, [35_000, 28_000, 27_000, 100_005]],
|
127
|
+
[:large3, [28_000, 27_000, 100_005, 35_000]],
|
128
|
+
[:large4, [1_238, 39_092, 27_938, 48_876]]
|
129
|
+
]
|
130
|
+
|
131
|
+
g = Gruff::Line.new
|
132
|
+
g.title = "Very Large Values Line Graph Test"
|
133
|
+
g.baseline_value = 50_000
|
134
|
+
g.baseline_color = 'green'
|
135
|
+
@datasets.each do |data|
|
136
|
+
g.data(data[0], data[1])
|
137
|
+
end
|
138
|
+
|
139
|
+
g.write("test/output/line_large.png")
|
140
|
+
end
|
141
|
+
|
142
|
+
# def test_long_title
|
143
|
+
#
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# def test_add_colors
|
147
|
+
#
|
148
|
+
# end
|
149
|
+
#
|
150
|
+
|
151
|
+
def test_request_too_many_colors
|
152
|
+
g = Gruff::Line.new
|
153
|
+
g.title = "More Sets Than in Color Array"
|
154
|
+
# g.theme = {} # Sets theme with only black and white
|
155
|
+
@datasets.each do |data|
|
156
|
+
g.data(data[0], data[1])
|
157
|
+
end
|
158
|
+
@datasets.each do |data|
|
159
|
+
g.data("#{data[0]}-B", data[1].map {|d| d + 20})
|
160
|
+
end
|
161
|
+
g.write("test/output/line_more_sets_than_colors.png")
|
162
|
+
end
|
163
|
+
|
164
|
+
#
|
165
|
+
# def test_add_data
|
166
|
+
#
|
167
|
+
# end
|
168
|
+
|
169
|
+
def test_many_datapoints
|
170
|
+
g = Gruff::Line.new
|
171
|
+
g.title = "Many Multi-Line Graph Test"
|
172
|
+
g.labels = {
|
173
|
+
0 => 'June',
|
174
|
+
10 => 'July',
|
175
|
+
30 => 'August',
|
176
|
+
50 => 'September',
|
177
|
+
}
|
178
|
+
g.data('many points', (0..50).collect {|i| rand(100) })
|
179
|
+
g.x_axis_label = "Months"
|
180
|
+
|
181
|
+
# Default theme
|
182
|
+
g.write("test/output/line_many.png")
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
def test_similar_high_end_values
|
187
|
+
@dataset = %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}
|
188
|
+
|
189
|
+
g = Gruff::Line.new
|
190
|
+
g.title = "Similar High End Values Test"
|
191
|
+
g.data('similar points', @dataset )
|
192
|
+
g.write("test/output/line_similar_high_end_values.png")
|
193
|
+
|
194
|
+
g = Gruff::Line.new
|
195
|
+
g.title = "Similar High End Values With Floor"
|
196
|
+
g.data('similar points', @dataset )
|
197
|
+
g.minimum_value = 0
|
198
|
+
g.y_axis_label = "Barometric Pressure"
|
199
|
+
g.write("test/output/line_similar_high_end_values_with_floor.png")
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_many_lines_graph_small
|
203
|
+
g = Gruff::Line.new(400)
|
204
|
+
g.title = "Many Values Line Test 400px"
|
205
|
+
g.labels = {
|
206
|
+
0 => '5/6',
|
207
|
+
10 => '5/15',
|
208
|
+
20 => '5/24',
|
209
|
+
30 => '5/30',
|
210
|
+
40 => '6/4',
|
211
|
+
50 => '6/16'
|
212
|
+
}
|
213
|
+
%w{jimmy jane philip arthur julie bert}.each do |student_name|
|
214
|
+
g.data(student_name, (0..50).collect { |i| rand 100 })
|
215
|
+
end
|
216
|
+
|
217
|
+
# Default theme
|
218
|
+
g.write("test/output/line_many_lines_small.png")
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_graph_tiny
|
222
|
+
g = Gruff::Line.new(300)
|
223
|
+
g.title = "Tiny Test 300px"
|
224
|
+
g.labels = {
|
225
|
+
0 => '5/6',
|
226
|
+
10 => '5/15',
|
227
|
+
20 => '5/24',
|
228
|
+
30 => '5/30',
|
229
|
+
40 => '6/4',
|
230
|
+
50 => '6/16'
|
231
|
+
}
|
232
|
+
%w{jimmy jane philip arthur julie bert}.each do |student_name|
|
233
|
+
g.data(student_name, (0..50).collect { |i| rand 100 })
|
234
|
+
end
|
235
|
+
|
236
|
+
# Default theme
|
237
|
+
g.write("test/output/line_tiny.png")
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_no_data
|
241
|
+
g = Gruff::Line.new(400)
|
242
|
+
g.title = "No Data"
|
243
|
+
# Default theme
|
244
|
+
g.write("test/output/line_no_data.png")
|
245
|
+
|
246
|
+
g = Gruff::Line.new(400)
|
247
|
+
g.title = "No Data Title"
|
248
|
+
g.no_data_message = 'There is no data'
|
249
|
+
g.write("test/output/line_no_data_msg.png")
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
def test_all_zeros
|
254
|
+
g = Gruff::Line.new(400)
|
255
|
+
g.title = "All Zeros"
|
256
|
+
|
257
|
+
g.data(:gus, [0,0,0,0])
|
258
|
+
|
259
|
+
# Default theme
|
260
|
+
g.write("test/output/line_no_data_other.png")
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
def test_some_nil_points
|
265
|
+
g = Gruff::Line.new
|
266
|
+
g.title = "Some Nil Points"
|
267
|
+
|
268
|
+
@datasets = [
|
269
|
+
[:data1, [1, 2, 3, nil, 3, 5, 6]],
|
270
|
+
[:data2, [5, nil, nil, nil, nil, nil, 5]],
|
271
|
+
[:data3, [4, nil, 2, 1, 0]],
|
272
|
+
[:data4, [nil, nil, 3, 1, 2]]
|
273
|
+
]
|
274
|
+
|
275
|
+
@datasets.each do |data|
|
276
|
+
g.data(*data)
|
277
|
+
end
|
278
|
+
|
279
|
+
# Default theme
|
280
|
+
g.write("test/output/line_some_nil_points.png")
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_no_title
|
284
|
+
g = Gruff::Line.new(400)
|
285
|
+
g.labels = @labels
|
286
|
+
@datasets.each do |data|
|
287
|
+
g.data(data[0], data[1])
|
288
|
+
end
|
289
|
+
|
290
|
+
g.write("test/output/line_no_title.png")
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_no_line_markers
|
294
|
+
g = setup_basic_graph(400)
|
295
|
+
g.title = "No Line Markers"
|
296
|
+
g.hide_line_markers = true
|
297
|
+
g.write("test/output/line_no_line_markers.png")
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_no_legend
|
301
|
+
g = setup_basic_graph(400)
|
302
|
+
g.title = "No Legend"
|
303
|
+
g.hide_legend = true
|
304
|
+
g.write("test/output/line_no_legend.png")
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_nothing_but_the_graph
|
308
|
+
g = setup_basic_graph(400)
|
309
|
+
g.title = "THIS TITLE SHOULD NOT DISPLAY!!!"
|
310
|
+
g.hide_line_markers = true
|
311
|
+
g.hide_legend = true
|
312
|
+
g.hide_title = true
|
313
|
+
g.write("test/output/line_nothing_but_the_graph.png")
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_baseline_larger_than_data
|
317
|
+
g = setup_basic_graph(400)
|
318
|
+
g.title = "Baseline Larger Than Data"
|
319
|
+
g.baseline_value = 150
|
320
|
+
g.write("test/output/line_large_baseline.png")
|
321
|
+
end
|
322
|
+
|
323
|
+
|
324
|
+
def test_hide_dots
|
325
|
+
g = setup_basic_graph(400)
|
326
|
+
g.title = "Hide Dots"
|
327
|
+
g.hide_dots = true
|
328
|
+
g.write("test/output/line_hide_dots.png")
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_hide_lines
|
332
|
+
g = setup_basic_graph(400)
|
333
|
+
g.title = "Hide Lines"
|
334
|
+
g.hide_lines = true
|
335
|
+
g.write("test/output/line_hide_lines.png")
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_wide_graph
|
339
|
+
g = setup_basic_graph('800x400')
|
340
|
+
g.title = "Wide Graph"
|
341
|
+
g.write("test/output/line_wide_graph.png")
|
342
|
+
|
343
|
+
g = setup_basic_graph('400x200')
|
344
|
+
g.title = "Wide Graph Small"
|
345
|
+
g.write("test/output/line_wide_graph_small.png")
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_negative
|
349
|
+
g = setup_pos_neg(800)
|
350
|
+
g.write("test/output/line_pos_neg.png")
|
351
|
+
|
352
|
+
g = setup_pos_neg(400)
|
353
|
+
g.title = 'Pos/Neg Line Test Small'
|
354
|
+
g.write("test/output/line_pos_neg_400.png")
|
355
|
+
end
|
356
|
+
|
357
|
+
def test_all_negative
|
358
|
+
g = setup_all_neg(800)
|
359
|
+
g.write("test/output/line_all_neg.png")
|
360
|
+
|
361
|
+
g = setup_all_neg(400)
|
362
|
+
g.title = 'All Neg Line Test Small'
|
363
|
+
g.write("test/output/line_all_neg_400.png")
|
364
|
+
end
|
365
|
+
|
366
|
+
def test_many_numbers
|
367
|
+
g = Gruff::Line.new('400x170')
|
368
|
+
g.title = "Line Test, Many Numbers"
|
369
|
+
|
370
|
+
data = [
|
371
|
+
{ :date => '01',
|
372
|
+
:wpm => 0,
|
373
|
+
:errors => 0,
|
374
|
+
:accuracy => 0 },
|
375
|
+
{ :date => '02',
|
376
|
+
:wpm => 10,
|
377
|
+
:errors => 2,
|
378
|
+
:accuracy => 80 },
|
379
|
+
{ :date => '03',
|
380
|
+
:wpm => 15,
|
381
|
+
:errors => 0,
|
382
|
+
:accuracy => 100 },
|
383
|
+
{ :date => '04',
|
384
|
+
:wpm => 16,
|
385
|
+
:errors => 2,
|
386
|
+
:accuracy => 87 },
|
387
|
+
{ :date => '05',
|
388
|
+
:wpm => nil,
|
389
|
+
:errors => nil,
|
390
|
+
:accuracy => nil },
|
391
|
+
{ :date => '06',
|
392
|
+
:wpm => 18,
|
393
|
+
:errors => 1,
|
394
|
+
:accuracy => 94 },
|
395
|
+
{ :date => '07'},
|
396
|
+
{ :date => '08' },
|
397
|
+
{ :date => '09',
|
398
|
+
:wpm => 21,
|
399
|
+
:errors => 1,
|
400
|
+
:accuracy => 95 },
|
401
|
+
{ :date => '10'},
|
402
|
+
{ :date => '11'},
|
403
|
+
{ :date => '12'},
|
404
|
+
{ :date => '13'},
|
405
|
+
{ :date => '14'},
|
406
|
+
{ :date => '15'},
|
407
|
+
{ :date => '16'},
|
408
|
+
{ :date => '17'},
|
409
|
+
{ :date => '18'},
|
410
|
+
{ :date => '19',
|
411
|
+
:wpm => 28,
|
412
|
+
:errors => 5,
|
413
|
+
:accuracy => 82 },
|
414
|
+
{ :date => '20'},
|
415
|
+
{ :date => '21'},
|
416
|
+
{ :date => '22'},
|
417
|
+
{ :date => '23'},
|
418
|
+
{ :date => '24'},
|
419
|
+
{ :date => '25'},
|
420
|
+
{ :date => '26'},
|
421
|
+
{ :date => '27',
|
422
|
+
:wpm => 37,
|
423
|
+
:errors => 3,
|
424
|
+
:accuracy => 92 },
|
425
|
+
]
|
426
|
+
|
427
|
+
[:wpm, :errors, :accuracy].each do |field|
|
428
|
+
g.data(field.to_s, data.collect {|d| d[field] })
|
429
|
+
end
|
430
|
+
|
431
|
+
labels = Hash.new
|
432
|
+
data.each_with_index do |d, i|
|
433
|
+
labels[i] = d[:date]
|
434
|
+
end
|
435
|
+
g.labels = labels
|
436
|
+
|
437
|
+
g.write('test/output/line_many_numbers.png')
|
438
|
+
end
|
439
|
+
|
440
|
+
def test_no_hide_line_no_labels
|
441
|
+
g = Gruff::Line.new
|
442
|
+
g.title = "No Hide Line No Labels"
|
443
|
+
@datasets.each do |data|
|
444
|
+
g.data(data[0], data[1])
|
445
|
+
end
|
446
|
+
g.hide_line_markers = false
|
447
|
+
g.write('test/output/line_no_hide.png')
|
448
|
+
end
|
449
|
+
|
450
|
+
|
451
|
+
def test_jruby_error
|
452
|
+
g = Gruff::Line.new
|
453
|
+
g.theme = {
|
454
|
+
:colors => ['#7F0099', '#2F85ED', '#2FED09','#EC962F'],
|
455
|
+
:marker_color => '#aaa',
|
456
|
+
:background_colors => ['#E8E8E8','#B9FD6C']
|
457
|
+
}
|
458
|
+
g.hide_title = true
|
459
|
+
|
460
|
+
g.legend_font_size = 12
|
461
|
+
g.marker_font_size = 16
|
462
|
+
g.hide_dots = false
|
463
|
+
g.label_max_decimals = 1
|
464
|
+
|
465
|
+
g.write('test/output/line_jruby_error.png')
|
466
|
+
end
|
467
|
+
|
468
|
+
private
|
469
|
+
|
470
|
+
def bmi(params={})
|
471
|
+
g = basic_graph()
|
472
|
+
|
473
|
+
g.y_axis_label = 'BMI'
|
474
|
+
|
475
|
+
bmis = [24.3, 23.9, 23.7, 23.7, 23.6, 23.9, 23.6, 23.7, 23.4, 23.4, 23.4, 22.9]
|
476
|
+
|
477
|
+
g.data( 'BMI', bmis )
|
478
|
+
g.hide_legend = true
|
479
|
+
return g
|
480
|
+
end
|
481
|
+
|
482
|
+
# TODO Reset data after each theme
|
483
|
+
def line_graph_with_themes(size=nil)
|
484
|
+
g = Gruff::Line.new(size)
|
485
|
+
g.title = "Multi-Line Graph Test #{size}"
|
486
|
+
g.labels = @labels
|
487
|
+
g.baseline_value = 90
|
488
|
+
@datasets.each do |data|
|
489
|
+
g.data(data[0], data[1])
|
490
|
+
end
|
491
|
+
# Default theme
|
492
|
+
g.write("test/output/line_theme_keynote_#{size}.png")
|
493
|
+
|
494
|
+
g = Gruff::Line.new(size)
|
495
|
+
g.title = "Multi-Line Graph Test #{size}"
|
496
|
+
g.labels = @labels
|
497
|
+
g.baseline_value = 90
|
498
|
+
g.theme_37signals
|
499
|
+
@datasets.each do |data|
|
500
|
+
g.data(data[0], data[1])
|
501
|
+
end
|
502
|
+
g.write("test/output/line_theme_37signals_#{size}.png")
|
503
|
+
|
504
|
+
g = Gruff::Line.new(size)
|
505
|
+
g.title = "Multi-Line Graph Test #{size}"
|
506
|
+
g.labels = @labels
|
507
|
+
g.baseline_value = 90
|
508
|
+
g.theme_rails_keynote
|
509
|
+
@datasets.each do |data|
|
510
|
+
g.data(data[0], data[1])
|
511
|
+
end
|
512
|
+
g.write("test/output/line_theme_rails_keynote_#{size}.png")
|
513
|
+
|
514
|
+
g = Gruff::Line.new(size)
|
515
|
+
g.title = "Multi-Line Graph Test #{size}"
|
516
|
+
g.labels = @labels
|
517
|
+
g.baseline_value = 90
|
518
|
+
g.theme_odeo
|
519
|
+
@datasets.each do |data|
|
520
|
+
g.data(data[0], data[1])
|
521
|
+
end
|
522
|
+
g.write("test/output/line_theme_odeo_#{size}.png")
|
523
|
+
end
|
524
|
+
|
525
|
+
def setup_pos_neg(size=800)
|
526
|
+
g = Gruff::Line.new(size)
|
527
|
+
g.title = "Pos/Neg Line Graph Test"
|
528
|
+
g.labels = {
|
529
|
+
0 => '5/6',
|
530
|
+
1 => '5/15',
|
531
|
+
2 => '5/24',
|
532
|
+
3 => '5/30',
|
533
|
+
}
|
534
|
+
g.data(:apples, [-1, 0, 4, -4])
|
535
|
+
g.data(:peaches, [10, 8, 6, 3])
|
536
|
+
return g
|
537
|
+
end
|
538
|
+
|
539
|
+
|
540
|
+
def setup_all_neg(size=800)
|
541
|
+
g = Gruff::Line.new(size)
|
542
|
+
g.title = "All Neg Line Graph Test"
|
543
|
+
g.labels = {
|
544
|
+
0 => '5/6',
|
545
|
+
1 => '5/15',
|
546
|
+
2 => '5/24',
|
547
|
+
3 => '5/30',
|
548
|
+
}
|
549
|
+
g.data(:apples, [-1, -5, -20, -4])
|
550
|
+
g.data(:peaches, [-10, -8, -6, -3])
|
551
|
+
g
|
552
|
+
end
|
553
|
+
|
554
|
+
end
|