svg-graph 1.0.5 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
Binary file
data/index.xml DELETED
@@ -1,281 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
- <article>
5
- <title>SVG::Graph</title>
6
-
7
- <subtitle>@ANT_VERSION@</subtitle>
8
-
9
- <articleinfo>
10
- <date>@ANT_DATE@</date>
11
-
12
- <author>
13
- <firstname>Sean</firstname>
14
-
15
- <surname>Russell</surname>
16
-
17
- <email>serATgermaneHYPHENsoftwareDOTcom</email>
18
- </author>
19
- </articleinfo>
20
-
21
- <sect1>
22
- <title>What is it?</title>
23
-
24
- <para>SVG:::Graph is a pure Ruby library for generating charts, which are
25
- a type of graph where the values of one axis are not scalar. SVG::Graph
26
- has a verry similar API to the Perl library SVG::TT::Graph, and the
27
- resulting charts also look the same. This isn't surprising, because
28
- SVG::Graph started as a loose port of SVG::TT::Graph, although the
29
- internal code no longer resembles the Perl original at all.</para>
30
-
31
- <para>SVG::Graph isn't only for charts. With version 0.4.0, support for
32
- Plot charts was added, so scalar data may now be charted.</para>
33
- </sect1>
34
-
35
- <sect1>
36
- <title>What's new?</title>
37
- <para>You can find that out in the <ulink
38
- url='changelog.html'>change log.</ulink></para>
39
- </sect1>
40
-
41
- <sect1>
42
- <title>Screenshot</title>
43
-
44
- <para>Gotta have one.</para>
45
-
46
- <mediaobject>
47
- <imageobject>
48
- <imagedata fileref="images/pie.svg" format="SVG" />
49
- </imageobject>
50
- </mediaobject>
51
-
52
- <para>Here's a PNG version of the above image for the
53
- SVG-challenged:</para>
54
-
55
- <mediaobject>
56
- <imageobject>
57
- <imagedata fileref="images/pie.png" format="PNG" />
58
- </imageobject>
59
- </mediaobject>
60
-
61
- <para>The SVG version is <emphasis>much</emphasis> cooler. <ulink
62
- url="screenshots.html">More screenshots are available</ulink>.</para>
63
- </sect1>
64
-
65
- <sect1>
66
- <title>Why use it?</title>
67
-
68
- <para>If you're a Ruby programmer, you can't use SVG::TT::Graph directly.
69
- This package is for you.</para>
70
-
71
- <para>If you want one of the features that this package has that the Perl
72
- version doesn't, and you don't mind doing your graph code in Ruby, then
73
- this package is for you.</para>
74
-
75
- <para>If you want to generate SVGs that aren't CSS styled (and work with
76
- more SVG renderers), use this package.</para>
77
-
78
- <para>If you're a Perl wienie or you have something against Ruby, use
79
- SVG::TT::Graph. If it doesn't provide you with the features you want, hack
80
- it yourself.</para>
81
- </sect1>
82
-
83
- <sect1>
84
- <title>Getting it</title>
85
-
86
- <para>The source archives contain the example script(s) and an install
87
- script. Documentation must be downloaded separately.<itemizedlist>
88
- <listitem>
89
- <para><ulink
90
- url="http://www.germane-software.com/archives/svg_graph_@ANT_VERSION@.tgz">Gzipped
91
- sources</ulink></para>
92
- </listitem>
93
-
94
- <listitem>
95
- <para><ulink
96
- url="http://www.germane-software.com/archives/svg_graph_api_@ANT_VERSION@.tgz">Gzipped
97
- documentation</ulink></para>
98
- </listitem>
99
-
100
- <listitem>
101
- <para><ulink
102
- url="http://www.germane-software.com/archives/svg_graph_@ANT_VERSION@.zip">Zipped
103
- sources</ulink></para>
104
- </listitem>
105
-
106
- <listitem>
107
- <para><ulink
108
- url="http://www.germane-software.com/archives/svg_graph_api_@ANT_VERSION@.zip">Zipped
109
- documentation</ulink></para>
110
- </listitem>
111
- </itemizedlist></para>
112
- </sect1>
113
-
114
- <sect1>
115
- <title>Why?</title>
116
-
117
- <para>The SVG::TT:Graph package is just fine. It lacked a couple of
118
- features that I wanted, and it was in Perl<footnote>
119
- <para>Perl is from Hell. The language is bad enough, but working with
120
- the package system -- CPAN, etc. -- is an exercize in masochism. I'd
121
- rather chew on glass.</para>
122
- </footnote>, so I re-implemented it.</para>
123
-
124
- <para>SVG::Graph is not a straight port of SVG::TT::Graph, because the
125
- Perl version uses templates, and I don't believe that this is a job for
126
- templates. Templates are great when you have lots of context containing a
127
- little bit of evaluated code, but the Graph classes are mostly code with a
128
- little SVG; therefore, it makes more sense (and is a hell of a lot more
129
- readable) to have the SVG embedded in the code rather than vice versa.
130
- However, some of the logic was directly cut and paste out of
131
- SVG::TT::Graph, as was the entire CSS code and chunks of the
132
- documentation, and the part of the API that the user sees is almost
133
- identical to the original.</para>
134
-
135
- <para>In version 0.2.0 I completely refactored the code to make it more
136
- modular. As a result, the core Graph class contains most of the graph
137
- drawing primatives, and the specializations (Bar, BarHorizontal, Line,
138
- Pie, etc.) only draw the plot itself. This results in many fewer lines of
139
- code, and that code is more robust. SVG::TT::Graph re-implemented most of
140
- the code for every plot type, whereas SVG::Graph reuses most of the
141
- code.</para>
142
-
143
- <para>I intend SVG::Graph to have more features than SVG::TT::Graph, which
144
- is the main reason for the re-implementation. One such feature is the
145
- ability to change the stacking of the data sets. For instance, SVG::Graph
146
- allows you to place the data bars from multiple data sets on the same
147
- graph side-by-side, rather than overlapping.</para>
148
-
149
- <para>SVG::Graph also has an option to disable CSS styling of the graphs.
150
- This has a number of consequences, both positive and negative. The SVGs
151
- generated can be larger without CSS, and they are harder to dynamically
152
- style (you can't use your own styles with CSS disabled). However, a number
153
- of SVG renderers do not support or do not fully support CSS in SVG (KSVG
154
- in Konqueror and librsvg, for instance). Adobe and Batik both support CSS,
155
- so if those are your targets, you can use CSS. For maximum compatability,
156
- disable CSS with the :no_css attriibute.</para>
157
-
158
- <para>The currently supported graph types are:</para>
159
-
160
- <itemizedlist>
161
- <listitem>
162
- <para>Bar</para>
163
- </listitem>
164
-
165
- <listitem>
166
- <para>BarHorizontal</para>
167
- </listitem>
168
-
169
- <listitem>
170
- <para>Line</para>
171
- </listitem>
172
-
173
- <listitem>
174
- <para>Pie</para>
175
- </listitem>
176
-
177
- <listitem>
178
- <para>Plot (this is scalar data)</para>
179
- </listitem>
180
-
181
- <listitem>
182
- <para>TimeSeries (also scalar data, with one axis being dates)</para>
183
- </listitem>
184
-
185
- <listitem>
186
- <para>Schedule (scalar time range data, with non-scalar Y axis)</para>
187
- </listitem>
188
- </itemizedlist>
189
- </sect1>
190
-
191
- <sect1>
192
- <title>Dependancies</title>
193
-
194
- <para>REXML 3.0+, or Ruby 1.8+. If you want to use the SVG compression
195
- feature, which generates zlib compressed SVGs, you must also have the Ruby
196
- zlib library installed.</para>
197
- </sect1>
198
-
199
- <sect1>
200
- <title>Usage</title>
201
-
202
- <para>There's API documentation available, either <ulink
203
- url="http://www.germane-software.com/software/SVG/SVG::Graph/doc">online</ulink>
204
- or for <ulink
205
- url="http://www.germane-software.com/archive/svg_graph_api_@ANT_VERSION@.tgz">download</ulink>.
206
- Or, you can use rdoc to generate it yourself. The API documentation is
207
- pretty comprehensive (Leo Lapworth did a really good job on the docs, and
208
- I stole most of them), and there's an example application in the main
209
- directory.</para>
210
- </sect1>
211
-
212
- <sect1>
213
- <title>Notes</title>
214
-
215
- <sect2>
216
- <title>SVG feature support</title>
217
-
218
- <para>Some SVG renderers (librsvg) do not understand CSS. This is a
219
- problem with Perl's SVG::TT::Graph, because <emphasis>all</emphasis> of
220
- the styling of the charts it generates is done with CSS. SVG::Graph is
221
- able to inline the styles, rendering graphs that are compatible with
222
- more viewers.</para>
223
-
224
- <para>The Pie chart uses the feGaussianBlur filter to generate the
225
- shadow, whiich is also unsupperted by some renderers (librsvg). The
226
- shadow will not look as smooth on those displays, although it will
227
- render.</para>
228
- </sect2>
229
-
230
- <sect2>
231
- <title>Sizes</title>
232
-
233
- <para>The bar charts PNGs tend to be smaller than the uncompressed SVGs.
234
- In the best case (for PNG), the PNG is 66% of the size of the
235
- uncompressed SVG.</para>
236
-
237
- <para>For line and pie charts, which are a little more visually complex,
238
- the SVGs are smaller than the PNGs. In the best case, the PNG is 130%
239
- the size of the SVG. In the worst case, the PNG is 220% the size of the
240
- uncompressed SVG.</para>
241
-
242
- <para>The compressed SVGs are always much smaller than the PNGs. In the
243
- best case (a vertical bar chart), the PNG is 4.4 times the size of the
244
- compressed SVG, and in the worst case (for a pie chart), it is over 12
245
- times the size of the compressed SVG.</para>
246
-
247
- <para>These values were measured with inline styled SVGs, and the PNGs
248
- were reduced to 8-bit, indexed images, and were crushed with
249
- pngcrush.</para>
250
- </sect2>
251
- </sect1>
252
-
253
- <sect1>
254
- <title>Bugs</title>
255
-
256
- <para>SVG::Graph probably contains bugs. In fact, it is probably mostly
257
- bugs, held together with some working code around them. In particular,
258
- SVG::Graph is probably really intolerant of *your* bugs, and is likely
259
- entirely unhelpful in helping you track down problems. We can only pray
260
- that this situation improves<footnote>
261
- <para>Prayer is much more effective when accompanied by sums of cash
262
- sent to the author.</para>
263
- </footnote>.</para>
264
-
265
- <para>There is a <ulink
266
- url="http://www.germane-software.com/cgi-bin/roundup/svg-graph">bug and
267
- feature request database</ulink>; use this, and please create a user
268
- account if you don't have one, so that I can email you if I have
269
- questions. Alternatively, post anonymously, and check the database
270
- often.</para>
271
- </sect1>
272
-
273
- <sect1>
274
- <title>Repository</title>
275
-
276
- <para>The sourcecode repository is a <ulink
277
- url="http://subversion.tigris.org">Subversion</ulink> repository, located
278
- <ulink
279
- url="http://www.germane-software.com/repositories/public/SVG">here</ulink>.</para>
280
- </sect1>
281
- </article>
data/install.rb DELETED
@@ -1,161 +0,0 @@
1
- #! /usr/bin/env ruby
2
- ################################################################################
3
- # #
4
- # Name: install.rb #
5
- # Author: Sean E Russell <ser@germane-software.com> #
6
- # Version: $Id: $
7
- # Date: *2002-174 #
8
- # Description: #
9
- # This is a generic installation script for pure ruby sources. Features #
10
- # include: #
11
- # * Clean uninstall #
12
- # * Installation into an absolute path #
13
- # * Installation into a temp path (useful for systems like Portage) #
14
- # * Noop mode, for testing #
15
- # To set for a different system, change the SRC directory to point to the #
16
- # package name / source directory for the project. #
17
- # #
18
- ################################################################################
19
-
20
- # CHANGE THIS
21
- SRC = ['SVG' ]
22
- STRIP = ''
23
- SETVERSION = 'SVG'
24
- SRCVERSION = '@ANT_VERSION@'
25
- DATE = '@ANT_DATE@'
26
-
27
- ################################################################################
28
- # CHANGE NOTHING BELOW THIS LINE
29
-
30
- Dir.chdir ".." if Dir.pwd =~ /bin.?$/
31
-
32
- require 'getoptlong'
33
- require 'rbconfig'
34
- require 'ftools'
35
- require 'find'
36
-
37
- opts = GetoptLong.new( [ '--uninstall', '-u', GetoptLong::NO_ARGUMENT],
38
- [ '--destdir', '-d', GetoptLong::REQUIRED_ARGUMENT ],
39
- [ '--target', '-t', GetoptLong::REQUIRED_ARGUMENT ],
40
- [ '--concurrent', '-c', GetoptLong::NO_ARGUMENT],
41
- [ '--help', '-h', GetoptLong::NO_ARGUMENT],
42
- [ '--noop', '-n', GetoptLong::NO_ARGUMENT])
43
-
44
-
45
- destdir = File.join(Config::CONFIG['sitedir'],
46
- "#{Config::CONFIG['MAJOR']}.#{Config::CONFIG['MINOR']}")
47
-
48
- uninstall = false
49
- prepend = nil
50
- help = false
51
- opts.each do |opt,arg|
52
- case opt
53
- when '--concurrent'
54
- CONCURRENT = true
55
- when '--destdir'
56
- prepend = arg
57
- when '--uninstall'
58
- uninstall = true
59
- when '--target'
60
- destdir = arg
61
- when '--help'
62
- help = true
63
- when '--noop'
64
- NOOP = true
65
- end
66
- end
67
-
68
- destdir = File.join prepend, destdir if prepend
69
-
70
- def transmogrify( dir )
71
- dir = dir.sub( /^#{STRIP}\//, '' )
72
- if defined? CONCURRENT
73
- dir.sub( /#{SETVERSION}/, "#{SETVERSION}-#{SRCVERSION}")
74
- else
75
- dir
76
- end
77
- end
78
-
79
- if help
80
- puts "Installs #{SRC.inspect}.\nUsage: #$0 [[-u] [-n] [-c] [-t <dir>|-d <dir>]|-h]"
81
- puts " -u --uninstall\n Uninstalls the package"
82
- puts " -c --concurrent\n Install concurrently, IE, into"
83
- for d in SRC
84
- puts " #{destdir}/#{transmogrify( d )}"
85
- end
86
- puts " The default behavior is to upgrade the current installation,"
87
- puts " by installing into"
88
- for d in SRC
89
- puts " #{destdir}/#{transmogrify( d )}"
90
- end
91
- puts " -t --target\n Installs the software at an absolute location, EG:"
92
- puts " #$0 -t /usr/local/lib/ruby"
93
- puts " will put the software directly underneath /usr/local/lib/ruby;"
94
- for d in SRC
95
- puts " /usr/local/lib/ruby/#{transmogrify( d )}"
96
- end
97
- puts " -d --destdir\n Installs the software at a relative location, EG:"
98
- puts " #$0 -d /tmp"
99
- puts " will put the software under tmp, using your ruby environment."
100
- for d in SRC
101
- puts " /tmp#{destdir}/#{transmogrify( d )}"
102
- end
103
- puts " -n --noop\n Don't actually do anything; just print out what it"
104
- puts " would do."
105
- exit 0
106
- end
107
-
108
- def install destdir
109
- puts "Installing in #{destdir}"
110
- begin
111
- for src in SRC
112
- Find.find(src) { |file|
113
- dstfile = transmogrify( file )
114
- next if file =~ /CVS|\.svn/
115
- dst = File.join( destdir, dstfile )
116
- if defined? NOOP
117
- puts ">> #{dst}" if file =~ /\.rb$/
118
- else
119
- File.makedirs( File.dirname(dst) )
120
- File.install(file, dst, 0644, true) if file =~ /\.rb$/
121
- end
122
- }
123
- end
124
- rescue
125
- puts $!
126
- end
127
- end
128
-
129
- def uninstall destdir
130
- puts "Uninstalling in #{destdir}"
131
- begin
132
- puts "Deleting:"
133
- dirs = []
134
- Find.find(File.join(destdir,SRC)) do |file|
135
- file.sub!( /#{SRC}/, "#{SRC}-#{SRCVERSION}") if defined? CONCURRENT
136
- if defined? NOOP
137
- puts "-- #{file}" if File.file? file
138
- else
139
- File.rm_f file,true if File.file? file
140
- end
141
- dirs << file if File.directory? file
142
- end
143
- dirs.sort { |x,y|
144
- y.length <=> x.length
145
- }.each { |d|
146
- if defined? NOOP
147
- puts "-- #{d}"
148
- else
149
- puts d
150
- Dir.delete d
151
- end
152
- }
153
- rescue
154
- end
155
- end
156
-
157
- if uninstall
158
- uninstall destdir
159
- else
160
- install destdir
161
- end
data/screenshots.xml DELETED
@@ -1,148 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
- <article>
5
- <title>Screenshots</title>
6
-
7
- <sect1>
8
- <title>SVGs</title>
9
-
10
- <para>Here are the SVG screenshots in all their glory. KSVG doesn't handle
11
- CSS properly yet, and neither does librsvg. Adobe and Batik both
12
- do.<mediaobject>
13
- <imageobject>
14
- <imagedata fileref="images/bar.svg" format="SVG" />
15
- </imageobject>
16
-
17
- <caption>
18
- <para>SVG::Chart::Bar</para>
19
- </caption>
20
- </mediaobject><mediaobject>
21
- <imageobject>
22
- <imagedata fileref="images/barhorizontal.svg" format="SVG" />
23
- </imageobject>
24
-
25
- <caption>
26
- <para>SVG::Chart::BarHorizontal</para>
27
- </caption>
28
- </mediaobject><mediaobject>
29
- <imageobject>
30
- <imagedata fileref="images/line.svg" format="SVG" />
31
- </imageobject>
32
-
33
- <caption>
34
- <para>SVG::Chart::Line</para>
35
- </caption>
36
- </mediaobject><mediaobject>
37
- <imageobject>
38
- <imagedata fileref="images/pie.svg" format="SVG" />
39
- </imageobject>
40
-
41
- <caption>
42
- <para>SVG::Chart::Pie</para>
43
- </caption>
44
- </mediaobject><mediaobject>
45
- <imageobject>
46
- <imagedata fileref="images/plot.svg" format="SVG" />
47
- </imageobject>
48
-
49
- <caption>
50
- <para>SVG::Chart::Plot</para>
51
- </caption>
52
- </mediaobject><mediaobject>
53
- <imageobject>
54
- <imagedata fileref="images/timeseries.svg" format="SVG" />
55
- </imageobject>
56
-
57
- <caption>
58
- <para>SVG::Chart::TimeSeries</para>
59
- </caption>
60
- </mediaobject><mediaobject>
61
- <imageobject>
62
- <imagedata fileref="images/schedule.svg" format="SVG" />
63
- </imageobject>
64
-
65
- <caption>
66
- <para>SVG::Chart::Schedule</para>
67
- </caption>
68
- </mediaobject></para>
69
- </sect1>
70
-
71
- <sect1>
72
- <title>PNGs</title>
73
-
74
- <para>Here are the icky, bitmapped PNGs. PNG is a beautiful file format,
75
- don't get me wrong; but it is best for things that vector graphics
76
- <emphasis>aren't</emphasis> good at, such as pictures.</para>
77
-
78
- <mediaobject>
79
- <imageobject>
80
- <imagedata fileref="images/bar.png" format="PNG" />
81
- </imageobject>
82
-
83
- <caption>
84
- <para>SVG::Chart::Bar</para>
85
- </caption>
86
- </mediaobject>
87
-
88
- <mediaobject>
89
- <imageobject>
90
- <imagedata fileref="images/barhorizontal.png" format="PNG" />
91
- </imageobject>
92
-
93
- <caption>
94
- <para>SVG::Chart::BarHorizontal</para>
95
- </caption>
96
- </mediaobject>
97
-
98
- <mediaobject>
99
- <imageobject>
100
- <imagedata fileref="images/line.png" format="PNG" />
101
- </imageobject>
102
-
103
- <caption>
104
- <para>SVG::Chart::Line</para>
105
- </caption>
106
- </mediaobject>
107
-
108
- <mediaobject>
109
- <imageobject>
110
- <imagedata fileref="images/pie.png" format="PNG" />
111
- </imageobject>
112
-
113
- <caption>
114
- <para>SVG::Chart::Pie</para>
115
- </caption>
116
- </mediaobject>
117
-
118
- <mediaobject>
119
- <imageobject>
120
- <imagedata fileref="images/plot.png" format="PNG" />
121
- </imageobject>
122
-
123
- <caption>
124
- <para>SVG::Chart::Plot</para>
125
- </caption>
126
- </mediaobject>
127
-
128
- <mediaobject>
129
- <imageobject>
130
- <imagedata fileref="images/timeseries.png" format="PNG" />
131
- </imageobject>
132
-
133
- <caption>
134
- <para>SVG::Chart::TimeSeries</para>
135
- </caption>
136
- </mediaobject>
137
-
138
- <mediaobject>
139
- <imageobject>
140
- <imagedata fileref="images/schedule.png" format="PNG" />
141
- </imageobject>
142
-
143
- <caption>
144
- <para>SVG::Chart::Schedule</para>
145
- </caption>
146
- </mediaobject>
147
- </sect1>
148
- </article>