svg-graph-test 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/GPL.txt +340 -0
- data/History.txt +97 -0
- data/LICENSE.txt +57 -0
- data/README.md +132 -0
- data/README.txt +89 -0
- data/Rakefile +42 -0
- data/lib/SVG/Graph/Bar.rb +154 -0
- data/lib/SVG/Graph/BarBase.rb +149 -0
- data/lib/SVG/Graph/BarHorizontal.rb +155 -0
- data/lib/SVG/Graph/C3js.rb +274 -0
- data/lib/SVG/Graph/DataPoint.rb +86 -0
- data/lib/SVG/Graph/ErrBar.rb +198 -0
- data/lib/SVG/Graph/Graph.rb +1338 -0
- data/lib/SVG/Graph/Line.rb +467 -0
- data/lib/SVG/Graph/Pie.rb +442 -0
- data/lib/SVG/Graph/Plot.rb +636 -0
- data/lib/SVG/Graph/Schedule.rb +386 -0
- data/lib/SVG/Graph/TimeSeries.rb +263 -0
- data/lib/svggraph.rb +18 -0
- data/test/test_svg_graph.rb +68 -0
- metadata +79 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../lib/svggraph'
|
2
|
+
require_relative '../lib/SVG/Graph/DataPoint'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/reporters'
|
5
|
+
|
6
|
+
reporter_options = { :color => true }
|
7
|
+
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(reporter_options)]
|
8
|
+
|
9
|
+
|
10
|
+
class TestSvgGraph < Minitest::Test
|
11
|
+
|
12
|
+
def test_bar_line_and_pie
|
13
|
+
fields = %w(Jan Feb Mar);
|
14
|
+
data_sales_02 = [12, 45, 21]
|
15
|
+
[SVG::Graph::Bar, SVG::Graph::BarHorizontal, SVG::Graph::Line, SVG::Graph::Pie].each do
|
16
|
+
|klass|
|
17
|
+
graph = klass.new(
|
18
|
+
:height => 500,
|
19
|
+
:width => 300,
|
20
|
+
:fields => fields
|
21
|
+
)
|
22
|
+
graph.add_data(
|
23
|
+
:data => data_sales_02,
|
24
|
+
:title => 'Sales 2002'
|
25
|
+
)
|
26
|
+
out=graph.burn
|
27
|
+
assert(out=~/Created with SVG::Graph/)
|
28
|
+
end
|
29
|
+
end # test_bar_line_and_pie
|
30
|
+
|
31
|
+
def test_pie_100_percent
|
32
|
+
fields = %w(Internet TV Newspaper Magazine Radio)
|
33
|
+
#data1 = [2, 3, 1, 3, 1]
|
34
|
+
#data2 = [0, 2, 1, 5, 4]
|
35
|
+
data1 = [0, 3, 0, 0, 0]
|
36
|
+
data2 = [0, 6, 0, 0, 0]
|
37
|
+
|
38
|
+
graph = SVG::Graph::Pie.new(
|
39
|
+
:height => 500,
|
40
|
+
:width => 300,
|
41
|
+
:fields => fields,
|
42
|
+
:graph_title => "100% pie",
|
43
|
+
:show_graph_title => true,
|
44
|
+
:show_data_labels => true,
|
45
|
+
:show_x_guidelines => true,
|
46
|
+
:show_x_title => true,
|
47
|
+
:x_title => "Time"
|
48
|
+
)
|
49
|
+
graph.add_data(
|
50
|
+
:data => data1,
|
51
|
+
:title => 'data1'
|
52
|
+
)
|
53
|
+
|
54
|
+
graph.add_data(
|
55
|
+
:data => data2,
|
56
|
+
:title => 'data2'
|
57
|
+
)
|
58
|
+
out = graph.burn
|
59
|
+
File.open(File.expand_path("pie_100.svg",__dir__), "w") {|fout|
|
60
|
+
fout.print( out )
|
61
|
+
}
|
62
|
+
assert_match(/TV 100%/, out, "100% text not found in graph")
|
63
|
+
assert_match(/circle/, out, "no circle was found in graph")
|
64
|
+
|
65
|
+
end # test_pie_100_percent
|
66
|
+
|
67
|
+
end
|
68
|
+
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: svg-graph-test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- test
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rexml
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Testfile.
|
28
|
+
email: []
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE.txt
|
33
|
+
- README.md
|
34
|
+
- README.txt
|
35
|
+
files:
|
36
|
+
- GPL.txt
|
37
|
+
- History.txt
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- README.txt
|
41
|
+
- Rakefile
|
42
|
+
- lib/SVG/Graph/Bar.rb
|
43
|
+
- lib/SVG/Graph/BarBase.rb
|
44
|
+
- lib/SVG/Graph/BarHorizontal.rb
|
45
|
+
- lib/SVG/Graph/C3js.rb
|
46
|
+
- lib/SVG/Graph/DataPoint.rb
|
47
|
+
- lib/SVG/Graph/ErrBar.rb
|
48
|
+
- lib/SVG/Graph/Graph.rb
|
49
|
+
- lib/SVG/Graph/Line.rb
|
50
|
+
- lib/SVG/Graph/Pie.rb
|
51
|
+
- lib/SVG/Graph/Plot.rb
|
52
|
+
- lib/SVG/Graph/Schedule.rb
|
53
|
+
- lib/SVG/Graph/TimeSeries.rb
|
54
|
+
- lib/svggraph.rb
|
55
|
+
- test/test_svg_graph.rb
|
56
|
+
homepage: ''
|
57
|
+
licenses:
|
58
|
+
- GPL-2.0
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubygems_version: 3.4.19
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: ''
|
79
|
+
test_files: []
|