gchart 0.4.2 → 0.5.0
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.
- data/CHANGELOG.txt +12 -0
- data/Manifest.txt +20 -0
- data/README.txt +96 -3
- data/lib/gchart.rb +19 -4
- data/lib/gchart/axis.rb +139 -0
- data/lib/gchart/axis/bottom_axis.rb +10 -0
- data/lib/gchart/axis/horizontal_axis.rb +11 -0
- data/lib/gchart/axis/left_axis.rb +10 -0
- data/lib/gchart/axis/right_axis.rb +10 -0
- data/lib/gchart/axis/top_axis.rb +10 -0
- data/lib/gchart/axis/vertical_axis.rb +11 -0
- data/lib/gchart/base.rb +149 -18
- data/lib/gchart/colors.rb +690 -0
- data/lib/gchart/map.rb +71 -0
- data/lib/gchart/meter.rb +29 -0
- data/lib/gchart/sparkline.rb +15 -0
- data/lib/version.rb +1 -1
- data/spec/gchart/axis/bottom_axis_spec.rb +13 -0
- data/spec/gchart/axis/left_axis_spec.rb +13 -0
- data/spec/gchart/axis/right_axis_spec.rb +13 -0
- data/spec/gchart/axis/top_axis_spec.rb +13 -0
- data/spec/gchart/axis_spec.rb +216 -0
- data/spec/gchart/base_spec.rb +107 -0
- data/spec/gchart/colors_spec.rb +79 -0
- data/spec/gchart/map_spec.rb +56 -0
- data/spec/gchart/meter_spec.rb +48 -0
- data/spec/gchart/sparkline_spec.rb +12 -0
- metadata +26 -5
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
+
|
3
|
+
describe GChart, ".expand_color" do
|
4
|
+
{ "693" => "669933", "fff" => "ffffff", "000" => "000000" }.each do |_3_char_color, _6_char_color|
|
5
|
+
it "expands #{_3_char_color} into #{_6_char_color}" do
|
6
|
+
GChart.expand_color(_3_char_color).should == _6_char_color
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
{ :red => "ff0000", :alice_blue => "f0f8ff", :yellow => "ffff00" }.each do |color_symbol, expanded|
|
11
|
+
it "expands #{color_symbol} into #{expanded}" do
|
12
|
+
GChart.expand_color(color_symbol).should == expanded
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
[ :canary_burnt_sienna, 3, 7.4, ['fff'], {'693' => 'cool'}, nil ].each do |non_color|
|
17
|
+
it "does not expand #{non_color}" do
|
18
|
+
GChart.expand_color(non_color).should == non_color
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
%w(669933 ffffff 000000).each do |_6_character_color|
|
23
|
+
it "does not expand #{_6_character_color}" do
|
24
|
+
GChart.expand_color(_6_character_color).should == _6_character_color
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe GChart, ".valid_color?" do
|
31
|
+
it "verifies a 3-hex-character rgb color definition as being valid" do
|
32
|
+
GChart.valid_color?('ffF').should == true
|
33
|
+
GChart.valid_color?('123').should == true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "verifies a 6-hex-character rrggbb color definition as being valid" do
|
37
|
+
GChart.valid_color?('123fFf').should == true
|
38
|
+
GChart.valid_color?('a1B2c3').should == true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "verifies an 8-hex-character rrggbbtt (transparency) color definition as being valid" do
|
42
|
+
GChart.valid_color?('123fffAa').should == true
|
43
|
+
GChart.valid_color?('a1b2c300').should == true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "verifies a COLORS symbol color definition as being valid" do
|
47
|
+
GChart.valid_color?(:red).should == true
|
48
|
+
GChart.valid_color?(:slate_blue4).should == true
|
49
|
+
end
|
50
|
+
|
51
|
+
it "states as being invalid any non-String/non-Symbol" do
|
52
|
+
GChart.valid_color?([:purple]).should == false
|
53
|
+
GChart.valid_color?({:red => true}).should == false
|
54
|
+
GChart.valid_color?(true).should == false
|
55
|
+
GChart.valid_color?(7).should == false
|
56
|
+
GChart.valid_color?(99.99).should == false
|
57
|
+
GChart.valid_color?(Object.new).should == false
|
58
|
+
GChart.valid_color?(GChart.class).should == false
|
59
|
+
end
|
60
|
+
|
61
|
+
it "states as being invalid any String of length not equal to 3, 6 or 8" do
|
62
|
+
GChart.valid_color?('ab').should == false
|
63
|
+
GChart.valid_color?('abcd').should == false
|
64
|
+
GChart.valid_color?('abcde').should == false
|
65
|
+
GChart.valid_color?('abcdef1').should == false
|
66
|
+
GChart.valid_color?('abcdef123').should == false
|
67
|
+
end
|
68
|
+
|
69
|
+
it "states as being invalid any String of length equal to 3, 6 or 8 with non-hex characters" do
|
70
|
+
GChart.valid_color?('efg').should == false
|
71
|
+
GChart.valid_color?('bcdefg').should == false
|
72
|
+
GChart.valid_color?('abcdefZZ').should == false
|
73
|
+
end
|
74
|
+
|
75
|
+
it "states as being invalid any symbol which is not in the COLORS table" do
|
76
|
+
GChart.valid_color?(:awesome_blue).should == false
|
77
|
+
GChart.valid_color?(:burnt_cyborg).should == false
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
+
|
3
|
+
describe GChart::Map do
|
4
|
+
before(:each) { @chart = GChart::Map.new }
|
5
|
+
|
6
|
+
it "initializes to a default area of 'world'" do
|
7
|
+
@chart.area.should == 'world'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "defaults to maximum size of 440x220" do
|
11
|
+
@chart.size.should == '440x220'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "renders the correct chart type" do
|
15
|
+
@chart.render_chart_type.should == "t"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe GChart::Map, "#query_params" do
|
20
|
+
before(:each) { @chart = GChart::Map.new }
|
21
|
+
|
22
|
+
it "contains the chart's type" do
|
23
|
+
@chart.query_params["cht"].should == "t"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "contains the map's area" do
|
27
|
+
@chart.area = "usa"
|
28
|
+
@chart.query_params.keys.include?("chtm").should be_true
|
29
|
+
@chart.query_params["chtm"].should == "usa"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "defaults to a blank map" do
|
33
|
+
@chart.query_params["chd"].should =~ /^[es]:__?/
|
34
|
+
end
|
35
|
+
|
36
|
+
it "checks for a valid area" do
|
37
|
+
lambda { @chart.area = 'usa' }.should_not raise_error(ArgumentError)
|
38
|
+
lambda { @chart.area = 'mars' }.should raise_error(ArgumentError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "makes sure the areas have one value" do
|
42
|
+
@chart.data = [['NY',1],['VA',2],['WY',3]]
|
43
|
+
@chart.area_codes.length.should == @chart.data.size * 2
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe GChart::Map, "#data" do
|
48
|
+
it "accepts data as a hash or pair of arrays" do
|
49
|
+
lambda { GChart::Map.new(:data => {"VA"=>5}) }.should_not raise_error(ArgumentError)
|
50
|
+
lambda { GChart::Map.new(:data => {"VA"=>5, "NY"=>1}) }.should_not raise_error(ArgumentError)
|
51
|
+
lambda { GChart::Map.new(:data => [["VA",5],["NY",1]]) }.should_not raise_error(ArgumentError)
|
52
|
+
lambda { GChart::Map.new(:data => [["VA","NY"],[5,1]]) }.should raise_error(ArgumentError)
|
53
|
+
lambda { GChart::Map.new(:data => [1, 2, 3]) }.should raise_error(ArgumentError)
|
54
|
+
lambda { GChart::Map.new(:data => [[1, 2, 3]]) }.should raise_error(ArgumentError)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
+
|
3
|
+
describe GChart::Meter do
|
4
|
+
it "renders the correct chart type" do
|
5
|
+
GChart::Meter.new.render_chart_type.should == "gom"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe GChart::Meter, "#query_params" do
|
10
|
+
before(:each) do
|
11
|
+
@meter = GChart::Meter.new
|
12
|
+
@meter.data = 50
|
13
|
+
end
|
14
|
+
it "encodes the data correctly" do
|
15
|
+
for data in [70, 70.0, "70", "70.0", "70%"] do
|
16
|
+
@meter.data = data
|
17
|
+
@meter.query_params["chd"].should == "t:70.0"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
it "allows a label" do
|
21
|
+
@meter.label = "Label"
|
22
|
+
@meter.query_params.keys.include?("chl").should be_true
|
23
|
+
@meter.query_params["chl"].should == "Label"
|
24
|
+
end
|
25
|
+
it "allows a legend" do
|
26
|
+
@meter.legend = "Legend"
|
27
|
+
@meter.query_params.keys.include?("chl").should be_true
|
28
|
+
@meter.query_params["chl"].should == "Legend"
|
29
|
+
end
|
30
|
+
it "makes label take precedence over legend" do
|
31
|
+
@meter.legend = "Legend"
|
32
|
+
@meter.label = "Label"
|
33
|
+
@meter.query_params.keys.include?("chl").should be_true
|
34
|
+
@meter.query_params["chl"].should == "Label"
|
35
|
+
end
|
36
|
+
it "complains about more than one label" do
|
37
|
+
lambda { @meter.label = "set1" }.should_not raise_error(ArgumentError)
|
38
|
+
lambda { @meter.label = ["set1"] }.should_not raise_error(ArgumentError)
|
39
|
+
lambda { @meter.label = "set1|set2" }.should raise_error(ArgumentError)
|
40
|
+
lambda { @meter.label = ['set1','set2'] }.should raise_error(ArgumentError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe GChart::Map, "#render_data" do
|
45
|
+
it "allows only one data point" do
|
46
|
+
lambda { @meter.data = "set1" }.should_not raise_error(ArgumentError)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
+
|
3
|
+
describe GChart::Sparkline do
|
4
|
+
it "renders the correct chart type" do
|
5
|
+
GChart::Sparkline.new.render_chart_type.should == "ls"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "defaults to 60x20" do
|
9
|
+
GChart::Sparkline.new.size.should == "60x20"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gchart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Barnette
|
@@ -9,19 +9,20 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-05-11 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hoe
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
20
21
|
- - ">="
|
21
22
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
23
|
+
version: 1.5.1
|
23
24
|
version:
|
24
|
-
description: "== PROBLEMS/TODO * Add
|
25
|
+
description: "== PROBLEMS/TODO * Add grid lines, linear stripes, shape markers, gradient fills * Make venn data specification friendlier * Make documentation more digestible There are lots of missing features. Until they're implemented, you can directly specify query parameters using the :extras key, e.g., # provides a legend for each data set g = GChart.line(:data => [[1, 2], [3, 4]], :extras => { \"chdl\" => \"First|Second\"})"
|
25
26
|
email: jbarnette@rubyforge.org
|
26
27
|
executables: []
|
27
28
|
|
@@ -37,21 +38,41 @@ files:
|
|
37
38
|
- README.txt
|
38
39
|
- Rakefile
|
39
40
|
- lib/gchart.rb
|
41
|
+
- lib/gchart/axis.rb
|
42
|
+
- lib/gchart/axis/bottom_axis.rb
|
43
|
+
- lib/gchart/axis/horizontal_axis.rb
|
44
|
+
- lib/gchart/axis/left_axis.rb
|
45
|
+
- lib/gchart/axis/right_axis.rb
|
46
|
+
- lib/gchart/axis/top_axis.rb
|
47
|
+
- lib/gchart/axis/vertical_axis.rb
|
40
48
|
- lib/gchart/bar.rb
|
41
49
|
- lib/gchart/base.rb
|
50
|
+
- lib/gchart/colors.rb
|
42
51
|
- lib/gchart/line.rb
|
52
|
+
- lib/gchart/map.rb
|
53
|
+
- lib/gchart/meter.rb
|
43
54
|
- lib/gchart/pie.rb
|
44
55
|
- lib/gchart/pie_3d.rb
|
45
56
|
- lib/gchart/scatter.rb
|
57
|
+
- lib/gchart/sparkline.rb
|
46
58
|
- lib/gchart/venn.rb
|
47
59
|
- lib/gchart/xy_line.rb
|
48
60
|
- lib/version.rb
|
61
|
+
- spec/gchart/axis/bottom_axis_spec.rb
|
62
|
+
- spec/gchart/axis/left_axis_spec.rb
|
63
|
+
- spec/gchart/axis/right_axis_spec.rb
|
64
|
+
- spec/gchart/axis/top_axis_spec.rb
|
65
|
+
- spec/gchart/axis_spec.rb
|
49
66
|
- spec/gchart/bar_spec.rb
|
50
67
|
- spec/gchart/base_spec.rb
|
68
|
+
- spec/gchart/colors_spec.rb
|
51
69
|
- spec/gchart/line_spec.rb
|
70
|
+
- spec/gchart/map_spec.rb
|
71
|
+
- spec/gchart/meter_spec.rb
|
52
72
|
- spec/gchart/pie_3d_spec.rb
|
53
73
|
- spec/gchart/pie_spec.rb
|
54
74
|
- spec/gchart/scatter_spec.rb
|
75
|
+
- spec/gchart/sparkline_spec.rb
|
55
76
|
- spec/gchart/venn_spec.rb
|
56
77
|
- spec/gchart/xy_line_spec.rb
|
57
78
|
- spec/gchart_spec.rb
|
@@ -80,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
101
|
requirements: []
|
81
102
|
|
82
103
|
rubyforge_project: gchart
|
83
|
-
rubygems_version: 1.
|
104
|
+
rubygems_version: 1.1.1
|
84
105
|
signing_key:
|
85
106
|
specification_version: 2
|
86
107
|
summary: GChart uses the Google Chart API to create pretty pictures.
|