svg-graph 1.0.5 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/History.txt +18 -0
  3. data/README.markdown +90 -6
  4. data/Rakefile +26 -14
  5. data/lib/SVG/Graph/Bar.rb +2 -2
  6. data/lib/SVG/Graph/BarBase.rb +25 -24
  7. data/lib/SVG/Graph/BarHorizontal.rb +1 -1
  8. data/lib/SVG/Graph/ErrBar.rb +189 -0
  9. data/lib/SVG/Graph/Graph.rb +141 -64
  10. data/lib/SVG/Graph/Line.rb +1 -1
  11. data/lib/SVG/Graph/Pie.rb +76 -49
  12. data/lib/SVG/Graph/Plot.rb +2 -2
  13. data/lib/SVG/Graph/Schedule.rb +18 -19
  14. data/lib/SVG/Graph/TimeSeries.rb +26 -22
  15. data/lib/svggraph.rb +12 -10
  16. data/test/test_svg_graph.rb +48 -6
  17. metadata +41 -136
  18. data.tar.gz.sig +0 -2
  19. data/Manifest.txt +0 -56
  20. data/build.xml +0 -143
  21. data/dist.xml.in +0 -46
  22. data/images/bar.png +0 -0
  23. data/images/bar.svg +0 -76
  24. data/images/bar.svgz +0 -0
  25. data/images/barhorizontal.png +0 -0
  26. data/images/barhorizontal.svg +0 -76
  27. data/images/barhorizontal.svgz +0 -0
  28. data/images/line.png +0 -0
  29. data/images/line.svg +0 -80
  30. data/images/line.svgz +0 -0
  31. data/images/pie.png +0 -0
  32. data/images/pie.svg +0 -70
  33. data/images/pie.svgz +0 -0
  34. data/images/plot.png +0 -0
  35. data/images/plot.svg +0 -131
  36. data/images/plot.svgz +0 -0
  37. data/images/schedule.png +0 -0
  38. data/images/schedule.svg +0 -67
  39. data/images/timeseries.png +0 -0
  40. data/images/timeseries.svg +0 -179
  41. data/images/timeseries.svgz +0 -0
  42. data/index.xml +0 -281
  43. data/install.rb +0 -161
  44. data/screenshots.xml +0 -148
  45. data/style/common.xsl +0 -37
  46. data/style/release_html.xsl +0 -169
  47. data/style/release_txt.xsl +0 -25
  48. data/svg-graph.gemspec +0 -58
  49. data/test/data.txt +0 -4
  50. data/test/plot.rb +0 -51
  51. data/test/schedule.rb +0 -43
  52. data/test/single.rb +0 -33
  53. data/test/test.rb +0 -54
  54. data/test/test_data_point.rb +0 -67
  55. data/test/test_plot.rb +0 -282
  56. data/test/timeseries.rb +0 -58
  57. metadata.gz.sig +0 -1
@@ -1,67 +0,0 @@
1
- $: << File.dirname(__FILE__) + '/../lib'
2
- require "test/unit"
3
- require "SVG/Graph/DataPoint"
4
-
5
- class TestDataPoint < Test::Unit::TestCase
6
- def setup
7
- DataPoint.reset_shape_criteria
8
- end
9
- def teardown
10
- DataPoint.reset_shape_criteria
11
- end
12
- def test_default_shape_is_circle_with_2_point_5_radius
13
- assert_equal([['circle', {
14
- "cx" => 100.0,
15
- "cy" => 100.0,
16
- "r" => "2.5",
17
- "class" => "dataPoint1"
18
- }]], DataPoint.new(100.0, 100.0, 1).shape)
19
- end
20
- def test_default_shape_based_on_description_without_criteria_is_circle_with_2_point_5_radius
21
- assert_equal([['circle', {
22
- "cx" => 100.0,
23
- "cy" => 100.0,
24
- "r" => "2.5",
25
- "class" => "dataPoint1"
26
- }]], DataPoint.new(100.0, 100.0, 1).shape("description"))
27
- end
28
- def test_shape_for_matching_regular_expression_is_lambda_value
29
- DataPoint.configure_shape_criteria(
30
- [/angle/, lambda{|x,y,line| ['rect', {
31
- "x" => x,
32
- "y" => y,
33
- "width" => "5",
34
- "height" => "5",
35
- "class" => "dataPoint#{line}"
36
- }]
37
- }]
38
- )
39
- assert_equal([['rect', {
40
- "x" => 100.0,
41
- "y" => 50.0,
42
- "width" => "5",
43
- "height" => "5",
44
- "class" => "dataPoint2"
45
- }]], DataPoint.new(100.0, 50.0, 2).shape("rectangle"))
46
- end
47
- def test_multiple_criteria_generate_shapes_in_order
48
- DataPoint.configure_shape_criteria(
49
- [/3/, lambda{|x,y,line| "three" }],
50
- [/2/, lambda{|x,y,line| "two" }],
51
- [/1/, lambda{|x,y,line| "one" }]
52
- )
53
- assert_equal(["three", "two", "one"], DataPoint.new(100.0, 50.0, 2).shape("1 3 2"))
54
- end
55
- def test_overlay_match_is_last_and_does_not_prevent_default
56
- DataPoint.configure_shape_criteria(
57
- [/3/, lambda{|x,y,line| "three" }, DataPoint::OVERLAY]
58
- )
59
- default_circle = ['circle', {
60
- "cx" => 100.0,
61
- "cy" => 50.0,
62
- "r" => "2.5",
63
- "class" => "dataPoint2"
64
- }]
65
- assert_equal([default_circle, "three"], DataPoint.new(100.0, 50.0, 2).shape("1 3 2"))
66
- end
67
- end
data/test/test_plot.rb DELETED
@@ -1,282 +0,0 @@
1
- $: << File.dirname(__FILE__) + '/../lib'
2
- require "test/unit"
3
- require "svggraph"
4
- require "SVG/Graph/DataPoint"
5
-
6
- class TestSvgGraphPlot < Test::Unit::TestCase
7
- def setup
8
- DataPoint.reset_shape_criteria
9
- end
10
- def teardown
11
- DataPoint.reset_shape_criteria
12
- end
13
- def test_plot
14
-
15
- projection = [
16
- 6, 11, 0, 5, 18, 7, 1, 11, 13, 9, 1, 2, 19, 0, 3, 13,
17
- 7, 9
18
- ]
19
- actual = [
20
- 0, 18, 8, 15, 9, 4, 18, 14, 10, 2, 11, 6, 14, 12,
21
- 15, 6, 4, 17, 2, 12
22
- ]
23
-
24
- graph = SVG::Graph::Plot.new({
25
- :height => 500,
26
- :width => 300,
27
- :key => true,
28
- :scale_x_integers => true,
29
- :scale_y_integerrs => true,
30
- })
31
-
32
- graph.add_data({
33
- :data => projection,
34
- :title => 'Projected',
35
- })
36
-
37
- graph.add_data({
38
- :data => actual,
39
- :title => 'Actual',
40
- })
41
-
42
- out=graph.burn()
43
- assert(out=~/Created with SVG::Graph/)
44
- end
45
- def test_default_plot_emits_polyline_connecting_data_points
46
- actual = [
47
- 0, 18, 8, 15, 9, 4, 18, 14, 10, 2, 11, 6, 14, 12,
48
- 15, 6, 4, 17, 2, 12
49
- ]
50
-
51
- graph = SVG::Graph::Plot.new({
52
- :height => 500,
53
- :width => 300,
54
- :key => true,
55
- :scale_x_integers => true,
56
- :scale_y_integerrs => true,
57
- })
58
-
59
- graph.add_data({
60
- :data => actual,
61
- :title => 'Actual',
62
- })
63
- out=graph.burn()
64
- assert_match(/path.*class='line1'/, out)
65
- end
66
-
67
- def test_disabling_show_lines_does_not_emit_polyline_connecting_data_points
68
- actual = [
69
- 0, 18, 8, 15, 9, 4, 18, 14, 10, 2, 11, 6, 14, 12,
70
- 15, 6, 4, 17, 2, 12
71
- ]
72
-
73
- graph = SVG::Graph::Plot.new({
74
- :height => 500,
75
- :width => 300,
76
- :key => true,
77
- :scale_x_integers => true,
78
- :scale_y_integers => true,
79
- :show_lines => false,
80
- })
81
-
82
- graph.add_data({
83
- :data => actual,
84
- :title => 'Actual',
85
- })
86
-
87
- out=graph.burn()
88
- assert_no_match(/path class='line1' d='M.* L.*'/, out)
89
- end
90
-
91
- def test_popup_values_round_to_integer_by_default_in_popups
92
- actual = [
93
- 0.1, 18, 8.55, 15.1234, 9.09876765, 4,
94
- ]
95
-
96
- graph = SVG::Graph::Plot.new({
97
- :height => 500,
98
- :width => 300,
99
- :key => true,
100
- :scale_x_integers => true,
101
- :scale_y_integers => true,
102
- :add_popups => true,
103
- })
104
-
105
- graph.add_data({
106
- :data => actual,
107
- :title => 'Actual',
108
- })
109
-
110
- out=graph.burn()
111
- assert_no_match(/\(0.1, 18\)/, out)
112
- assert_match(/\(0, 18\)/, out)
113
- assert_no_match(/\(8.55, 15.1234\)/, out)
114
- assert_match(/\(8, 15\)/, out)
115
- assert_no_match(/\(9.09876765, 4\)/, out)
116
- assert_match(/\(9, 4\)/, out)
117
- end
118
-
119
- def test_do_not_round_popup_values_shows_decimal_values_in_popups
120
- actual = [
121
- 0.1, 18, 8.55, 15.1234, 9.09876765, 4,
122
- ]
123
-
124
- graph = SVG::Graph::Plot.new({
125
- :height => 500,
126
- :width => 300,
127
- :key => true,
128
- :scale_x_integers => true,
129
- :scale_y_integers => true,
130
- :add_popups => true,
131
- :round_popups => false,
132
- })
133
-
134
- graph.add_data({
135
- :data => actual,
136
- :title => 'Actual',
137
- })
138
-
139
- out=graph.burn()
140
- assert_match(/\(0.1, 18\)/, out)
141
- assert_no_match(/\(0, 18\)/, out)
142
- assert_match(/\(8.55, 15.1234\)/, out)
143
- assert_no_match(/\(8, 15\)/, out)
144
- assert_match(/\(9.09876765, 4\)/, out)
145
- assert_no_match(/\(9, 4\)/, out)
146
- end
147
-
148
- def test_description_is_shown_in_popups_if_provided
149
- actual = [
150
- 8.55, 15.1234, 9.09876765, 4, 0.1, 18,
151
- ]
152
- description = [
153
- 'first', 'second', 'third',
154
- ]
155
-
156
- graph = SVG::Graph::Plot.new({
157
- :height => 500,
158
- :width => 300,
159
- :key => true,
160
- :scale_x_integers => true,
161
- :scale_y_integers => true,
162
- :add_popups => true,
163
- :round_popups => false,
164
- })
165
-
166
- graph.add_data({
167
- :data => actual,
168
- :title => 'Actual',
169
- :description => description,
170
- })
171
-
172
- out=graph.burn()
173
- assert_match(/\(8.55, 15.1234, first\)/, out)
174
- assert_no_match(/\(8.55, 15.1234\)/, out)
175
- assert_match(/\(9.09876765, 4, second\)/, out)
176
- assert_no_match(/\(9.09876765, 4\)/, out)
177
- assert_match(/\(0.1, 18, third\)/, out)
178
- assert_no_match(/\(0.1, 18\)/, out)
179
- end
180
- def test_combine_different_shapes_based_on_description
181
- actual = [
182
- 8.55, 15.1234, 9.09876765, 4, 2.1, 18,
183
- ]
184
- description = [
185
- 'one is a circle', 'two is a rectangle', 'three is a rectangle with strikethrough',
186
- ]
187
-
188
- DataPoint.configure_shape_criteria(
189
- [/^t.*/, lambda{|x,y,line| ['polygon', {
190
- "points" => "#{x-1.5},#{y+2.5} #{x+1.5},#{y+2.5} #{x+1.5},#{y-2.5} #{x-1.5},#{y-2.5}",
191
- "class" => "dataPoint#{line}"
192
- }]
193
- }],
194
- [/^three.*/, lambda{|x,y,line| ['line', {
195
- "x1" => "#{x-4}",
196
- "y1" => y.to_s,
197
- "x2" => "#{x+4}",
198
- "y2" => y.to_s,
199
- "class" => "axis"
200
- }]
201
- }]
202
- )
203
- graph = SVG::Graph::Plot.new({
204
- :height => 500,
205
- :width => 300,
206
- :key => true,
207
- :scale_x_integers => true,
208
- :scale_y_integers => true,
209
- :add_popups => true,
210
- :round_popups => false,
211
- })
212
-
213
- graph.add_data({
214
- :data => actual,
215
- :title => 'Actual',
216
- :description => description,
217
- })
218
-
219
- out=graph.burn()
220
- assert_match(/polygon.*points/, out)
221
- assert_match(/line.*axis/, out)
222
- end
223
- def test_popup_radius_is_10_by_default
224
- actual = [
225
- 1, 1, 5, 5, 10, 10,
226
- ]
227
- description = [
228
- 'first', 'second', 'third',
229
- ]
230
-
231
- graph = SVG::Graph::Plot.new({
232
- :height => 500,
233
- :width => 300,
234
- :key => true,
235
- :scale_x_integers => true,
236
- :scale_y_integers => true,
237
- :add_popups => true,
238
- :round_popups => false,
239
- })
240
-
241
- graph.add_data({
242
- :data => actual,
243
- :title => 'Actual',
244
- :description => description,
245
- })
246
-
247
- out=graph.burn()
248
- assert_match(/circle .* r='10'/, out)
249
- assert_match(/circle .* onmouseover=.*/, out)
250
-
251
- end
252
- def test_popup_radius_is_overridable
253
- actual = [
254
- 1, 1, 5, 5, 10, 10,
255
- ]
256
- description = [
257
- 'first', 'second', 'third',
258
- ]
259
-
260
- graph = SVG::Graph::Plot.new({
261
- :height => 500,
262
- :width => 300,
263
- :key => true,
264
- :scale_x_integers => true,
265
- :scale_y_integers => true,
266
- :add_popups => true,
267
- :round_popups => false,
268
- :popup_radius => 1.23
269
- })
270
-
271
- graph.add_data({
272
- :data => actual,
273
- :title => 'Actual',
274
- :description => description,
275
- })
276
-
277
- out=graph.burn()
278
- assert_match(/circle .* r='1.23'/, out)
279
- assert_match(/circle .* onmouseover=.*/, out)
280
-
281
- end
282
- end
data/test/timeseries.rb DELETED
@@ -1,58 +0,0 @@
1
- require 'SVG/Graph/TimeSeries'
2
-
3
-
4
- title = "Plot"
5
- #data1 = []
6
- #(rand(10)+5).times{
7
- # data1 << rand(20)
8
- # data1 << rand(20)
9
- #}
10
- data1 = ["6/17/74", 11, "1/11/74", 7, "4/13/04 17:31", 11, "9/11/01", 9, "9/1/85", 2, "9/1/88", 1, "1/15/95", 13]
11
- #data2 = []
12
- #(rand(10)+5).times{
13
- # data2 << rand(20)
14
- # data2 << rand(20)
15
- #}
16
- data2 = ["8/1/73", 18, "10/21/76", 15, "01/11/80", 4, "4/3/83", 14, "6/23/86", 6, "9/13/89", 12, "12/3/92", 6, "2/24/96", 17, "5/16/99", 12, "8/5/02", 7]
17
- data3 = ["1/1/78", 5, "1/1/83", 13, "1/1/93", 10, "1/1/03", 5]
18
-
19
-
20
- graph = SVG::Graph::TimeSeries.new( {
21
- :width => 640,
22
- :height => 480,
23
- :graph_title => title,
24
- :show_graph_title => true,
25
- :no_css => true,
26
- :key => true,
27
- :scale_x_integers => true,
28
- :scale_y_integers => true,
29
- :show_data_values => true,
30
- :show_x_guidelines => true,
31
- :show_x_title => true,
32
- :x_title => "Time",
33
- :show_y_title => true,
34
- :y_title => "Units",
35
- :y_title_text_direction => :bt,
36
- :stagger_x_labels => true,
37
- :x_label_format => "%Y",
38
- :min_x_value => "1/1/73",
39
- :timescale_divisions => "5 years",
40
- :add_popups => true,
41
- :popup_format => "%m/%d/%y",
42
- #:area_fill => true,
43
- :min_y_value => 0,
44
- })
45
- graph.add_data(
46
- :data => data1,
47
- :title => "Ice Cream"
48
- )
49
- graph.add_data(
50
- :data => data2,
51
- :title => "Ice Cream Cones"
52
- )
53
- graph.add_data(
54
- :data => data3,
55
- :title => "Sprinkles"
56
- )
57
- puts graph.burn
58
-
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- P�)��3��!�/n/Y���nRʃSr'��0�L~�Ɛ� �W��rk�m���w��NO-HWч�}��4�ю�*�T('�&�՜<�?.��f����n��{T�$����%�^�ٲ�9E�QP��\!��,6��P�������R��ee�M�~���,ju�g��(he;.{�J���&�f��A�|}t����y$~W���Y��<%`���e�\����;�'� �ӨG+�Ō޿Ai(oy&���fuN�����oq