googlecharts 1.6.8 → 1.6.12
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.
- checksums.yaml +7 -0
- data/.gitignore +4 -1
- data/.travis.yml +8 -0
- data/Gemfile +10 -0
- data/History.txt +10 -0
- data/README.markdown +6 -1
- data/Rakefile +12 -1
- data/googlecharts.gemspec +4 -3
- data/lib/gchart/aliases.rb +0 -1
- data/lib/gchart/version.rb +1 -1
- data/lib/gchart.rb +43 -21
- data/spec/gchart_spec.rb +224 -212
- data/spec/theme_spec.rb +8 -8
- metadata +26 -45
data/spec/gchart_spec.rb
CHANGED
@@ -7,11 +7,16 @@ Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml")
|
|
7
7
|
# http://rspec.rubyforge.org/
|
8
8
|
describe "The Gchart class" do
|
9
9
|
it "should show supported_types on error" do
|
10
|
-
Gchart.supported_types.
|
10
|
+
expect(Gchart.supported_types).to match(/line/)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return supported types" do
|
14
|
-
Gchart.types.include
|
14
|
+
expect(Gchart.types).to include('line')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should support theme option" do
|
18
|
+
chart = Gchart.new(:type => 'line',:theme => :test)
|
19
|
+
expect(chart.send('url')).to include('chco=6886B4,FDD84E')
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
@@ -21,121 +26,122 @@ describe "generating a default Gchart" do
|
|
21
26
|
@chart = Gchart.line
|
22
27
|
end
|
23
28
|
|
29
|
+
it "should create a line break when a pipe character is encountered" do
|
30
|
+
@chart = Gchart.line(:title => "title|subtitle")
|
31
|
+
expect(@chart).to include("chtt=title\nsubtitle")
|
32
|
+
end
|
33
|
+
|
24
34
|
it "should include the Google URL" do
|
25
|
-
@chart.include
|
35
|
+
expect(@chart).to include("http://chart.apis.google.com/chart?")
|
26
36
|
end
|
27
37
|
|
28
38
|
it "should have a default size" do
|
29
|
-
@chart.
|
39
|
+
expect(@chart).to include('chs=300x200')
|
30
40
|
end
|
31
41
|
|
32
42
|
it "should be able to have a custom size" do
|
33
|
-
Gchart.line(:size => '400x600').include
|
34
|
-
Gchart.line(:width => 400, :height => 600).include
|
43
|
+
expect(Gchart.line(:size => '400x600')).to include('chs=400x600')
|
44
|
+
expect(Gchart.line(:width => 400, :height => 600)).to include('chs=400x600')
|
35
45
|
end
|
36
46
|
|
37
47
|
it "should have query parameters in predictable order" do
|
38
|
-
Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').
|
48
|
+
expect(Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600')).to match(/chxt=.+cht=.+chs=/)
|
39
49
|
end
|
40
50
|
|
41
51
|
it "should have a type" do
|
42
|
-
@chart.include
|
52
|
+
expect(@chart).to include('cht=lc')
|
43
53
|
end
|
44
54
|
|
45
55
|
it 'should use theme defaults if theme is set' do
|
46
|
-
Gchart.line(:theme=>:test).
|
47
|
-
|
48
|
-
Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF'))
|
49
|
-
else
|
50
|
-
Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF'))
|
51
|
-
end
|
56
|
+
expect(Gchart.line(:theme=>:test)).to include('chco=6886B4,FDD84E')
|
57
|
+
expect(Gchart.line(:theme=>:test)).to match(/chf=(c,s,FFFFFF\|bg,s,FFFFFF|bg,s,FFFFFF\|c,s,FFFFFF)/)
|
52
58
|
end
|
53
59
|
|
54
60
|
it "should use the simple encoding by default with auto max value" do
|
55
61
|
# 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9
|
56
|
-
Gchart.line(:data => [0, 26]).
|
57
|
-
Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').
|
62
|
+
expect(Gchart.line(:data => [0, 26])).to include('chd=s:A9')
|
63
|
+
expect(Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y')).to include('chxr=0,0,26')
|
58
64
|
end
|
59
65
|
|
60
66
|
it "should support simple encoding with and without max_value" do
|
61
|
-
Gchart.line(:data => [0, 26], :max_value => 26).
|
62
|
-
Gchart.line(:data => [0, 26], :max_value => false).
|
67
|
+
expect(Gchart.line(:data => [0, 26], :max_value => 26)).to include('chd=s:A9')
|
68
|
+
expect(Gchart.line(:data => [0, 26], :max_value => false)).to include('chd=s:Aa')
|
63
69
|
end
|
64
70
|
|
65
71
|
it "should support the extended encoding and encode properly" do
|
66
|
-
Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include
|
67
|
-
Gchart.line(:encoding => 'extended',
|
72
|
+
expect(Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false)).to include('chd=e:AA')
|
73
|
+
expect(Gchart.line(:encoding => 'extended',
|
68
74
|
:max_value => false,
|
69
75
|
:data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]]
|
70
|
-
).include
|
76
|
+
)).to include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0')
|
71
77
|
end
|
72
78
|
|
73
79
|
it "should auto set the max value for extended encoding" do
|
74
|
-
Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).
|
80
|
+
expect(Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false)).to include('chd=e:AAAZ')
|
75
81
|
# Extended encoding max value is '..'
|
76
|
-
Gchart.line(:data => [0, 25], :encoding => 'extended').include
|
82
|
+
expect(Gchart.line(:data => [0, 25], :encoding => 'extended')).to include('chd=e:AA..')
|
77
83
|
end
|
78
84
|
|
79
85
|
it "should be able to have data with text encoding" do
|
80
|
-
Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').
|
86
|
+
expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,4,45,78')
|
81
87
|
end
|
82
88
|
|
83
89
|
it "should be able to have missing data points with text encoding" do
|
84
|
-
Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').
|
90
|
+
expect(Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,_,45,78')
|
85
91
|
end
|
86
92
|
|
87
93
|
it "should handle max and min values with text encoding" do
|
88
|
-
Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').
|
94
|
+
expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=0,78')
|
89
95
|
end
|
90
96
|
|
91
97
|
it "should automatically handle negative values with proper max/min limits when using text encoding" do
|
92
|
-
Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').
|
98
|
+
expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=-10,78')
|
93
99
|
end
|
94
100
|
|
95
101
|
it "should handle negative values with manual max/min limits when using text encoding" do
|
96
|
-
Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include
|
102
|
+
expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100)).to include('chds=-20,100')
|
97
103
|
end
|
98
104
|
|
99
105
|
it "should set the proper axis values when using text encoding and negative values" do
|
100
|
-
Gchart.bar( :data => [[-10], [100]],
|
106
|
+
expect(Gchart.bar( :data => [[-10], [100]],
|
101
107
|
:encoding => 'text',
|
102
108
|
:horizontal => true,
|
103
109
|
:min_value => -20,
|
104
110
|
:max_value => 100,
|
105
111
|
:axis_with_labels => 'x',
|
106
|
-
:bar_colors => ['FD9A3B', '4BC7DC']).
|
112
|
+
:bar_colors => ['FD9A3B', '4BC7DC'])).to include("chxr=0,-20,100")
|
107
113
|
end
|
108
114
|
|
109
115
|
it "should be able to have multiple set of data with text encoding" do
|
110
|
-
Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include
|
116
|
+
expect(Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text')).to include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99'))
|
111
117
|
end
|
112
118
|
|
113
119
|
it "should be able to receive a custom param" do
|
114
|
-
Gchart.line(:custom => 'ceci_est_une_pipe').include
|
120
|
+
expect(Gchart.line(:custom => 'ceci_est_une_pipe')).to include('ceci_est_une_pipe')
|
115
121
|
end
|
116
122
|
|
117
123
|
it "should be able to set label axis" do
|
118
|
-
Gchart.line(:axis_with_labels => 'x,y,r').include
|
119
|
-
Gchart.line(:axis_with_labels => ['x','y','r']).include
|
124
|
+
expect(Gchart.line(:axis_with_labels => 'x,y,r')).to include('chxt=x,y,r')
|
125
|
+
expect(Gchart.line(:axis_with_labels => ['x','y','r'])).to include('chxt=x,y,r')
|
120
126
|
end
|
121
127
|
|
122
128
|
it "should be able to have axis labels" do
|
123
|
-
Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include
|
124
|
-
Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include
|
125
|
-
Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include
|
126
|
-
Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include
|
129
|
+
expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007'))
|
130
|
+
expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan'))
|
131
|
+
expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan'))
|
132
|
+
expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007'))
|
127
133
|
end
|
128
|
-
|
134
|
+
|
129
135
|
def labeled_line(options = {})
|
130
136
|
Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options))
|
131
137
|
end
|
132
138
|
|
133
139
|
it "should display ranges properly" do
|
134
140
|
@data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593]
|
135
|
-
labeled_line(:axis_labels => [((1..24).to_a << 1)]).
|
136
|
-
|
141
|
+
expect(labeled_line(:axis_labels => [((1..24).to_a << 1)])).
|
142
|
+
to include('chxr=0,85,672')
|
137
143
|
end
|
138
|
-
|
144
|
+
|
139
145
|
def labeled_bar(options = {})
|
140
146
|
Gchart.bar({:data => @data,
|
141
147
|
:axis_with_labels => 'x,y',
|
@@ -146,117 +152,121 @@ describe "generating a default Gchart" do
|
|
146
152
|
|
147
153
|
it "should force the y range properly" do
|
148
154
|
@data = [1,1,1,1,1,1,1,1,6,2,1,1]
|
149
|
-
labeled_bar(
|
155
|
+
expect(labeled_bar(
|
150
156
|
:axis_range => [[0,0],[0,16]]
|
151
|
-
).
|
152
|
-
labeled_bar(
|
157
|
+
)).to include('chxr=0,0,0|1,0,16')
|
158
|
+
expect(labeled_bar(
|
153
159
|
:max_value => 16,
|
154
160
|
:axis_range => [[0,0],[0,16]]
|
155
|
-
).
|
161
|
+
)).to include('chxr=0,0,16|1,0,16')
|
156
162
|
|
157
163
|
# nil means ignore axis
|
158
|
-
labeled_bar(
|
164
|
+
expect(labeled_bar(
|
159
165
|
:axis_range => [nil,[0,16]]
|
160
|
-
).
|
166
|
+
)).to include('chxr=1,0,16')
|
161
167
|
|
162
168
|
# empty array means take defaults
|
163
|
-
labeled_bar(
|
169
|
+
expect(labeled_bar(
|
164
170
|
:max_value => 16,
|
165
171
|
:axis_range => [[],[0,16]]
|
166
|
-
).
|
167
|
-
labeled_bar(
|
172
|
+
)).to include('chxr=0,0,16|1,0,16')
|
173
|
+
expect(labeled_bar(
|
168
174
|
:axis_range => [[],[0,16]]
|
169
|
-
).
|
175
|
+
)).to include('chxr=0,0|1,0,16')
|
170
176
|
|
171
|
-
Gchart.line(
|
177
|
+
expect(Gchart.line(
|
172
178
|
:data => [0,20, 40, 60, 140, 230, 60],
|
173
|
-
:axis_with_labels => 'y').
|
179
|
+
:axis_with_labels => 'y')).to include("chxr=0,0,230")
|
174
180
|
end
|
175
|
-
|
181
|
+
|
176
182
|
it "should take in consideration the max value when creating a range" do
|
177
183
|
data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593]
|
178
184
|
url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700)
|
179
|
-
url.
|
185
|
+
expect(url).to include('chxr=0,85,700')
|
180
186
|
end
|
181
|
-
|
187
|
+
|
182
188
|
it 'should generate different labels and legend' do
|
183
|
-
Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).
|
189
|
+
expect(Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three))).to(include('chdl=1|2|3') && include('chl=one|two|three'))
|
184
190
|
end
|
185
|
-
|
186
191
|
end
|
187
192
|
|
188
193
|
describe "generating different type of charts" do
|
189
194
|
|
190
195
|
it "should be able to generate a line chart" do
|
191
|
-
Gchart.line.
|
192
|
-
Gchart.line.include
|
196
|
+
expect(Gchart.line).to be_an_instance_of(String)
|
197
|
+
expect(Gchart.line).to include('cht=lc')
|
193
198
|
end
|
194
199
|
|
195
200
|
it "should be able to generate a sparkline chart" do
|
196
|
-
Gchart.sparkline.
|
197
|
-
Gchart.sparkline.include
|
201
|
+
expect(Gchart.sparkline).to be_an_instance_of(String)
|
202
|
+
expect(Gchart.sparkline).to include('cht=ls')
|
198
203
|
end
|
199
204
|
|
200
205
|
it "should be able to generate a line xy chart" do
|
201
|
-
Gchart.line_xy.
|
202
|
-
Gchart.line_xy.include
|
206
|
+
expect(Gchart.line_xy).to be_an_instance_of(String)
|
207
|
+
expect(Gchart.line_xy).to include('cht=lxy')
|
203
208
|
end
|
204
209
|
|
205
210
|
it "should be able to generate a scatter chart" do
|
206
|
-
Gchart.scatter.
|
207
|
-
Gchart.scatter.include
|
211
|
+
expect(Gchart.scatter).to be_an_instance_of(String)
|
212
|
+
expect(Gchart.scatter).to include('cht=s')
|
208
213
|
end
|
209
214
|
|
210
215
|
it "should be able to generate a bar chart" do
|
211
|
-
Gchart.bar.
|
212
|
-
Gchart.bar.include
|
216
|
+
expect(Gchart.bar).to be_an_instance_of(String)
|
217
|
+
expect(Gchart.bar).to include('cht=bvs')
|
213
218
|
end
|
214
219
|
|
215
220
|
it "should be able to generate a Venn diagram" do
|
216
|
-
Gchart.venn.
|
217
|
-
Gchart.venn.include
|
221
|
+
expect(Gchart.venn).to be_an_instance_of(String)
|
222
|
+
expect(Gchart.venn).to include('cht=v')
|
218
223
|
end
|
219
224
|
|
220
225
|
it "should be able to generate a Pie Chart" do
|
221
|
-
Gchart.pie.
|
222
|
-
Gchart.pie.include
|
226
|
+
expect(Gchart.pie).to be_an_instance_of(String)
|
227
|
+
expect(Gchart.pie).to include('cht=p')
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should be able to generate a Concentric Pie Chart" do
|
231
|
+
expect(Gchart.pie_c).to be_an_instance_of(String)
|
232
|
+
expect(Gchart.pie_c).to include('cht=pc')
|
233
|
+
expect(Gchart.pie_c(size: '240x240', data: [[-1], [2,3]])).to include('-1|1,2,3')
|
223
234
|
end
|
224
235
|
|
225
236
|
it "should be able to generate a Google-O-Meter" do
|
226
|
-
Gchart.meter.
|
227
|
-
Gchart.meter.include
|
237
|
+
expect(Gchart.meter).to be_an_instance_of(String)
|
238
|
+
expect(Gchart.meter).to include('cht=gom')
|
228
239
|
end
|
229
240
|
|
230
241
|
it "should be able to generate a map chart" do
|
231
|
-
Gchart.map.
|
232
|
-
Gchart.map.include
|
242
|
+
expect(Gchart.map).to be_an_instance_of(String)
|
243
|
+
expect(Gchart.map).to include('cht=t')
|
233
244
|
end
|
234
245
|
|
235
246
|
it "should not support other types" do
|
236
247
|
msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}."
|
237
|
-
|
248
|
+
expect{Gchart.sexy}.to raise_error(NoMethodError)
|
238
249
|
end
|
239
|
-
|
240
250
|
end
|
241
251
|
|
242
252
|
|
243
253
|
describe "range markers" do
|
244
254
|
|
245
255
|
it "should be able to generate given a hash of range-marker options" do
|
246
|
-
Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include
|
256
|
+
expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'})).to include('chm=r,ff0000,0,0.59,0.61')
|
247
257
|
end
|
248
258
|
|
249
259
|
it "should be able to generate given an array of range-marker hash options" do
|
250
|
-
Gchart.line(:range_markers => [
|
260
|
+
expect(Gchart.line(:range_markers => [
|
251
261
|
{:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'},
|
252
262
|
{:start_position => 0, :stop_position => 0.6, :color => '666666'},
|
253
263
|
{:color => 'cccccc', :start_position => 0.6, :stop_position => 1}
|
254
|
-
]).include
|
264
|
+
])).to include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1'))
|
255
265
|
end
|
256
266
|
|
257
267
|
it "should allow a :overlaid? to be set" do
|
258
|
-
Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include
|
259
|
-
Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include
|
268
|
+
expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true})).to include('chm=r,ffffff,0,0.59,0.61,1')
|
269
|
+
expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false})).to include('chm=r,ffffff,0,0.59,0.61')
|
260
270
|
end
|
261
271
|
|
262
272
|
describe "when setting the orientation option" do
|
@@ -265,75 +275,76 @@ describe "range markers" do
|
|
265
275
|
end
|
266
276
|
|
267
277
|
it "to vertical (R) if given a valid option" do
|
268
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include
|
269
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include
|
270
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include
|
271
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include
|
272
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include
|
278
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'v'))).to include('chm=R')
|
279
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'V'))).to include('chm=R')
|
280
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'R'))).to include('chm=R')
|
281
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'vertical'))).to include('chm=R')
|
282
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical'))).to include('chm=R')
|
273
283
|
end
|
274
284
|
|
275
285
|
it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do
|
276
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include
|
277
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include
|
278
|
-
Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include
|
286
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal'))).to include('chm=r')
|
287
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'h'))).to include('chm=r')
|
288
|
+
expect(Gchart.line(:range_markers => @options.merge(:orientation => 'etc'))).to include('chm=r')
|
279
289
|
end
|
280
290
|
|
281
291
|
it "if left blank defaults to horizontal (r)" do
|
282
|
-
Gchart.line(:range_markers => @options).include
|
292
|
+
expect(Gchart.line(:range_markers => @options)).to include('chm=r')
|
283
293
|
end
|
284
294
|
end
|
285
|
-
|
286
295
|
end
|
287
296
|
|
288
297
|
|
289
298
|
describe "a bar graph" do
|
290
299
|
|
291
300
|
it "should have a default vertical orientation" do
|
292
|
-
Gchart.bar.include
|
301
|
+
expect(Gchart.bar).to include('cht=bvs')
|
293
302
|
end
|
294
303
|
|
295
304
|
it "should be able to have a different orientation" do
|
296
|
-
Gchart.bar(:orientation => 'vertical').include
|
297
|
-
Gchart.bar(:orientation => 'v').include
|
298
|
-
Gchart.bar(:orientation => 'h').include
|
299
|
-
Gchart.bar(:orientation => 'horizontal').include
|
300
|
-
Gchart.bar(:horizontal => false).include
|
305
|
+
expect(Gchart.bar(:orientation => 'vertical')).to include('cht=bvs')
|
306
|
+
expect(Gchart.bar(:orientation => 'v')).to include('cht=bvs')
|
307
|
+
expect(Gchart.bar(:orientation => 'h')).to include('cht=bhs')
|
308
|
+
expect(Gchart.bar(:orientation => 'horizontal')).to include('cht=bhs')
|
309
|
+
expect(Gchart.bar(:horizontal => false)).to include('cht=bvs')
|
301
310
|
end
|
302
311
|
|
303
312
|
it "should be set to be stacked by default" do
|
304
|
-
Gchart.bar.include
|
313
|
+
expect(Gchart.bar).to include('cht=bvs')
|
305
314
|
end
|
306
315
|
|
307
|
-
it "should be able to stacked or
|
308
|
-
Gchart.bar(:stacked => true).include
|
309
|
-
Gchart.bar(:stacked => false).include
|
310
|
-
Gchart.bar(:grouped => true).include
|
311
|
-
Gchart.bar(:grouped => false).include
|
316
|
+
it "should be able to stacked, grouped or overlapped" do
|
317
|
+
expect(Gchart.bar(:stacked => true)).to include('cht=bvs')
|
318
|
+
expect(Gchart.bar(:stacked => false)).to include('cht=bvs')
|
319
|
+
expect(Gchart.bar(:grouped => true)).to include('cht=bvg')
|
320
|
+
expect(Gchart.bar(:grouped => false)).to include('cht=bvs')
|
321
|
+
expect(Gchart.bar(:overlapped => true)).to include('cht=bvo')
|
322
|
+
expect(Gchart.bar(:overlapped => false)).to include('cht=bvs')
|
312
323
|
end
|
313
324
|
|
314
325
|
it "should be able to have different bar colors" do
|
315
|
-
Gchart.bar(:bar_colors => 'efefef,00ffff').include
|
316
|
-
Gchart.bar(:bar_colors => 'efefef,00ffff').include
|
326
|
+
expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=')
|
327
|
+
expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=efefef,00ffff')
|
317
328
|
# alias
|
318
|
-
Gchart.bar(:bar_color => 'efefef').include
|
329
|
+
expect(Gchart.bar(:bar_color => 'efefef')).to include('chco=efefef')
|
319
330
|
end
|
320
331
|
|
321
332
|
it "should be able to have different bar colors when using an array of colors" do
|
322
|
-
Gchart.bar(:bar_colors => ['efefef','00ffff']).include
|
333
|
+
expect(Gchart.bar(:bar_colors => ['efefef','00ffff'])).to include('chco=efefef,00ffff')
|
323
334
|
end
|
324
335
|
|
325
336
|
it 'should be able to accept a string of width and spacing options' do
|
326
|
-
Gchart.bar(:bar_width_and_spacing => '25,6').include
|
337
|
+
expect(Gchart.bar(:bar_width_and_spacing => '25,6')).to include('chbh=25,6')
|
327
338
|
end
|
328
339
|
|
329
340
|
it 'should be able to accept a single fixnum width and spacing option to set the bar width' do
|
330
|
-
Gchart.bar(:bar_width_and_spacing => 25).include
|
341
|
+
expect(Gchart.bar(:bar_width_and_spacing => 25)).to include('chbh=25')
|
331
342
|
end
|
332
343
|
|
333
344
|
it 'should be able to accept an array of width and spacing options' do
|
334
|
-
Gchart.bar(:bar_width_and_spacing => [25,6,12]).include
|
335
|
-
Gchart.bar(:bar_width_and_spacing => [25,6]).include
|
336
|
-
Gchart.bar(:bar_width_and_spacing => [25]).include
|
345
|
+
expect(Gchart.bar(:bar_width_and_spacing => [25,6,12])).to include('chbh=25,6,12')
|
346
|
+
expect(Gchart.bar(:bar_width_and_spacing => [25,6])).to include('chbh=25,6')
|
347
|
+
expect(Gchart.bar(:bar_width_and_spacing => [25])).to include('chbh=25')
|
337
348
|
end
|
338
349
|
|
339
350
|
describe "with a hash of width and spacing options" do
|
@@ -345,19 +356,36 @@ describe "a bar graph" do
|
|
345
356
|
end
|
346
357
|
|
347
358
|
it 'should be able to have a custom bar width' do
|
348
|
-
Gchart.bar(:bar_width_and_spacing => {:width => 19}).include
|
359
|
+
expect(Gchart.bar(:bar_width_and_spacing => {:width => 19})).to include("chbh=19,#{@default_spacing},#{@default_group_spacing}")
|
349
360
|
end
|
350
361
|
|
351
362
|
it 'should be able to have custom spacing' do
|
352
|
-
Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include
|
363
|
+
expect(Gchart.bar(:bar_width_and_spacing => {:spacing => 19})).to include("chbh=#{@default_width},19,#{@default_group_spacing}")
|
353
364
|
end
|
354
365
|
|
355
366
|
it 'should be able to have custom group spacing' do
|
356
|
-
Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include
|
367
|
+
expect(Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19})).to include("chbh=#{@default_width},#{@default_spacing},19")
|
357
368
|
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
describe "a radar chart" do
|
358
373
|
|
374
|
+
before(:each) do
|
375
|
+
@chart = Gchart.radar(:title => 'Chart Title')
|
376
|
+
end
|
377
|
+
|
378
|
+
it "should be able have a chart title" do
|
379
|
+
expect(@chart).to include("chtt=Chart+Title")
|
359
380
|
end
|
360
381
|
|
382
|
+
it "should allow axis labels positions to be used" do
|
383
|
+
expect(Gchart.radar(:custom_axis_with_labels => '0,0,50,100')).to include('chxp=0,0,50,100')
|
384
|
+
end
|
385
|
+
|
386
|
+
it "should allow array of axis labels positions to be used " do
|
387
|
+
expect(Gchart.radar(:custom_axis_with_labels => ['0', '0', '50', '100'])).to include('chxp=0,0,50,100')
|
388
|
+
end
|
361
389
|
end
|
362
390
|
|
363
391
|
describe "a line chart" do
|
@@ -369,80 +397,73 @@ describe "a line chart" do
|
|
369
397
|
end
|
370
398
|
|
371
399
|
it 'should be able have a chart title' do
|
372
|
-
@chart.include
|
400
|
+
expect(@chart).to include("chtt=Chart+Title")
|
373
401
|
end
|
374
402
|
|
375
403
|
it "should be able to a custom color, size and alignment for title" do
|
376
|
-
Gchart.line(:title => @title, :title_color => 'FF0000').include
|
377
|
-
Gchart.line(:title => @title, :title_size => '20').include
|
378
|
-
Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).include
|
404
|
+
expect(Gchart.line(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000')
|
405
|
+
expect(Gchart.line(:title => @title, :title_size => '20')).to include('chts=454545,20')
|
406
|
+
expect(Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left)).to include('chts=454545,20,l')
|
379
407
|
end
|
380
408
|
|
381
409
|
it "should be able to have multiple legends" do
|
382
|
-
@chart.include
|
410
|
+
expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label"))
|
383
411
|
end
|
384
412
|
|
385
413
|
it "should escape text values in url" do
|
386
414
|
title = 'Chart & Title'
|
387
415
|
legend = ['first data & set label', 'n data set label']
|
388
416
|
chart = Gchart.line(:title => title, :legend => legend)
|
389
|
-
chart.include
|
417
|
+
expect(chart).to include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label"))
|
390
418
|
end
|
391
419
|
|
392
420
|
it "should be able to have one legend" do
|
393
421
|
chart = Gchart.line(:legend => 'legend label')
|
394
|
-
chart.include
|
422
|
+
expect(chart).to include("chdl=legend+label")
|
395
423
|
end
|
396
|
-
|
424
|
+
|
397
425
|
it "should be able to set the position of the legend" do
|
398
426
|
title = 'Chart & Title'
|
399
427
|
legend = ['first data & set label', 'n data set label']
|
400
|
-
|
428
|
+
|
401
429
|
chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical)
|
402
|
-
chart.include
|
403
|
-
|
430
|
+
expect(chart).to include("chdlp=bv")
|
431
|
+
|
404
432
|
chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r')
|
405
|
-
chart.include
|
433
|
+
expect(chart).to include("chdlp=r")
|
406
434
|
end
|
407
435
|
|
408
436
|
it "should be able to set the background fill" do
|
409
|
-
Gchart.line(:bg => 'efefef').
|
410
|
-
Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).
|
437
|
+
expect(Gchart.line(:bg => 'efefef')).to include("chf=bg,s,efefef")
|
438
|
+
expect(Gchart.line(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef")
|
411
439
|
|
412
|
-
Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).
|
413
|
-
Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).
|
414
|
-
Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).
|
440
|
+
expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
|
441
|
+
expect(Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
|
442
|
+
expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1")
|
415
443
|
|
416
|
-
Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).
|
444
|
+
expect(Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2")
|
417
445
|
end
|
418
446
|
|
419
447
|
it "should be able to set a graph fill" do
|
420
|
-
Gchart.line(:graph_bg => 'efefef').
|
421
|
-
Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include
|
422
|
-
Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include
|
423
|
-
Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include
|
424
|
-
Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include
|
448
|
+
expect(Gchart.line(:graph_bg => 'efefef')).to include("chf=c,s,efefef")
|
449
|
+
expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef")
|
450
|
+
expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
|
451
|
+
expect(Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
|
452
|
+
expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1")
|
425
453
|
end
|
426
454
|
|
427
455
|
it "should be able to set both a graph and a background fill" do
|
428
|
-
Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').
|
429
|
-
Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true
|
430
|
-
if RUBY_VERSION.to_f < 1.9
|
431
|
-
Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true
|
432
|
-
else
|
433
|
-
Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true
|
434
|
-
end
|
456
|
+
expect(Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB')).to match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/
|
435
457
|
end
|
436
458
|
|
437
459
|
it "should be able to have different line colors" do
|
438
|
-
Gchart.line(:line_colors => 'efefef|00ffff').include
|
439
|
-
Gchart.line(:line_color => 'efefef|00ffff').include
|
460
|
+
expect(Gchart.line(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
|
461
|
+
expect(Gchart.line(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
|
440
462
|
end
|
441
463
|
|
442
464
|
it "should be able to render a graph where all the data values are 0" do
|
443
|
-
Gchart.line(:data => [0, 0, 0]).
|
465
|
+
expect(Gchart.line(:data => [0, 0, 0])).to include("chd=s:AAA")
|
444
466
|
end
|
445
|
-
|
446
467
|
end
|
447
468
|
|
448
469
|
describe "a sparkline chart" do
|
@@ -456,61 +477,54 @@ describe "a sparkline chart" do
|
|
456
477
|
end
|
457
478
|
|
458
479
|
it "should create a sparkline" do
|
459
|
-
@chart.include
|
480
|
+
expect(@chart).to include('cht=ls')
|
460
481
|
end
|
461
482
|
|
462
483
|
it 'should be able have a chart title' do
|
463
|
-
@chart.include
|
484
|
+
expect(@chart).to include("chtt=Chart+Title")
|
464
485
|
end
|
465
486
|
|
466
487
|
it "should be able to a custom color and size title" do
|
467
|
-
Gchart.sparkline(:title => @title, :title_color => 'FF0000').include
|
468
|
-
Gchart.sparkline(:title => @title, :title_size => '20').include
|
488
|
+
expect(Gchart.sparkline(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000')
|
489
|
+
expect(Gchart.sparkline(:title => @title, :title_size => '20')).to include('chts=454545,20')
|
469
490
|
end
|
470
491
|
|
471
492
|
it "should be able to have multiple legends" do
|
472
|
-
@chart.include
|
493
|
+
expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label"))
|
473
494
|
end
|
474
495
|
|
475
496
|
it "should be able to have one legend" do
|
476
497
|
chart = Gchart.sparkline(:legend => 'legend label')
|
477
|
-
chart.include
|
498
|
+
expect(chart).to include("chdl=legend+label")
|
478
499
|
end
|
479
500
|
|
480
501
|
it "should be able to set the background fill" do
|
481
|
-
Gchart.sparkline(:bg => 'efefef').include
|
482
|
-
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include
|
502
|
+
expect(Gchart.sparkline(:bg => 'efefef')).to include("chf=bg,s,efefef")
|
503
|
+
expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef")
|
483
504
|
|
484
|
-
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include
|
485
|
-
Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include
|
486
|
-
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include
|
505
|
+
expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
|
506
|
+
expect(Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
|
507
|
+
expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1")
|
487
508
|
|
488
|
-
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include
|
509
|
+
expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2")
|
489
510
|
end
|
490
511
|
|
491
512
|
it "should be able to set a graph fill" do
|
492
|
-
Gchart.sparkline(:graph_bg => 'efefef').include
|
493
|
-
Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include
|
494
|
-
Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include
|
495
|
-
Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include
|
496
|
-
Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include
|
513
|
+
expect(Gchart.sparkline(:graph_bg => 'efefef')).to include("chf=c,s,efefef")
|
514
|
+
expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef")
|
515
|
+
expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
|
516
|
+
expect(Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
|
517
|
+
expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1")
|
497
518
|
end
|
498
519
|
|
499
520
|
it "should be able to set both a graph and a background fill" do
|
500
|
-
Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').
|
501
|
-
Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true
|
502
|
-
if RUBY_VERSION.to_f < 1.9
|
503
|
-
Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true
|
504
|
-
else
|
505
|
-
Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true
|
506
|
-
end
|
521
|
+
expect(Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB')).to match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/)
|
507
522
|
end
|
508
523
|
|
509
524
|
it "should be able to have different line colors" do
|
510
|
-
Gchart.sparkline(:line_colors => 'efefef|00ffff').include
|
511
|
-
Gchart.sparkline(:line_color => 'efefef|00ffff').include
|
525
|
+
expect(Gchart.sparkline(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
|
526
|
+
expect(Gchart.sparkline(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
|
512
527
|
end
|
513
|
-
|
514
528
|
end
|
515
529
|
|
516
530
|
describe "a 3d pie chart" do
|
@@ -524,13 +538,12 @@ describe "a 3d pie chart" do
|
|
524
538
|
end
|
525
539
|
|
526
540
|
it "should create a pie" do
|
527
|
-
@chart.include
|
541
|
+
expect(@chart).to include('cht=p')
|
528
542
|
end
|
529
543
|
|
530
544
|
it "should be able to be in 3d" do
|
531
|
-
Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include
|
545
|
+
expect(Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)).to include('cht=p3')
|
532
546
|
end
|
533
|
-
|
534
547
|
end
|
535
548
|
|
536
549
|
describe "a google-o-meter" do
|
@@ -543,19 +556,18 @@ describe "a google-o-meter" do
|
|
543
556
|
end
|
544
557
|
|
545
558
|
it "should create a meter" do
|
546
|
-
@chart.include
|
559
|
+
expect(@chart).to include('cht=gom')
|
547
560
|
end
|
548
561
|
|
549
562
|
it "should be able to set a solid background fill" do
|
550
|
-
Gchart.meter(:bg => 'efefef').include
|
551
|
-
Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include
|
563
|
+
expect(Gchart.meter(:bg => 'efefef')).to include("chf=bg,s,efefef")
|
564
|
+
expect(Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef")
|
552
565
|
end
|
553
566
|
|
554
567
|
it "should be able to set labels by using the legend or labesl accessor" do
|
555
|
-
Gchart.meter(:title => @title, :labels => @legend, :data => @data).
|
556
|
-
Gchart.meter(:title => @title, :labels => @legend, :data => @data).
|
568
|
+
expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to include("chl=#{@jstized_legend}")
|
569
|
+
expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to eq(Gchart.meter(:title => @title, :legend => @legend, :data => @data))
|
557
570
|
end
|
558
|
-
|
559
571
|
end
|
560
572
|
|
561
573
|
describe "a map chart" do
|
@@ -571,81 +583,80 @@ describe "a map chart" do
|
|
571
583
|
end
|
572
584
|
|
573
585
|
it "should create a map" do
|
574
|
-
@chart.include
|
586
|
+
expect(@chart).to include('cht=t')
|
575
587
|
end
|
576
588
|
|
577
589
|
it "should set the geographical area" do
|
578
|
-
@chart.include
|
590
|
+
expect(@chart).to include('chtm=usa')
|
579
591
|
end
|
580
592
|
|
581
593
|
it "should set the map colors" do
|
582
|
-
@chart.include
|
594
|
+
expect(@chart).to include('chco=FFFFFF,FF0000,FFFF00,00FF00')
|
583
595
|
end
|
584
596
|
|
585
597
|
it "should set the country/state codes" do
|
586
|
-
@chart.include
|
598
|
+
expect(@chart).to include('chld=MTWYIDSD')
|
587
599
|
end
|
588
600
|
|
589
601
|
it "should set the chart data" do
|
590
|
-
@chart.include
|
602
|
+
expect(@chart).to include('chd=t:0,100,50,32')
|
591
603
|
end
|
592
|
-
|
593
604
|
end
|
594
605
|
|
595
606
|
describe 'exporting a chart' do
|
596
607
|
|
597
608
|
it "should be available in the url format by default" do
|
598
|
-
Gchart.line(:data => [0, 26], :format => 'url').
|
609
|
+
expect(Gchart.line(:data => [0, 26], :format => 'url')).to eq(Gchart.line(:data => [0, 26]))
|
599
610
|
end
|
600
611
|
|
601
612
|
it "should be available as an image tag" do
|
602
|
-
Gchart.line(:data => [0, 26], :format => 'image_tag').
|
613
|
+
expect(Gchart.line(:data => [0, 26], :format => 'image_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/)
|
603
614
|
end
|
604
615
|
|
605
616
|
it "should be available as an image tag using img_tag alias" do
|
606
|
-
Gchart.line(:data => [0, 26], :format => 'img_tag').
|
617
|
+
expect(Gchart.line(:data => [0, 26], :format => 'img_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/)
|
607
618
|
end
|
608
619
|
|
609
620
|
it "should be available as an image tag using custom dimensions" do
|
610
|
-
Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').
|
621
|
+
expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400')).to match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/)
|
611
622
|
end
|
612
623
|
|
613
624
|
it "should be available as an image tag using custom alt text" do
|
614
|
-
Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').
|
625
|
+
expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/)
|
615
626
|
end
|
616
627
|
|
617
628
|
it "should be available as an image tag using custom title text" do
|
618
|
-
Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').
|
629
|
+
expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/)
|
619
630
|
end
|
620
631
|
|
621
632
|
it "should be available as an image tag using custom css id selector" do
|
622
|
-
Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').
|
633
|
+
expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart')).to match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/)
|
623
634
|
end
|
624
635
|
|
625
636
|
it "should be available as an image tag using custom css class selector" do
|
626
|
-
Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').
|
637
|
+
expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/)
|
627
638
|
end
|
628
639
|
|
629
640
|
it "should use ampersands to separate key/value pairs in URLs by default" do
|
630
|
-
Gchart.line(:data => [0, 26]).
|
631
|
-
Gchart.line(:data => [0, 26]).
|
641
|
+
expect(Gchart.line(:data => [0, 26])).to include "&"
|
642
|
+
expect(Gchart.line(:data => [0, 26])).not_to include "&"
|
632
643
|
end
|
633
644
|
|
634
645
|
it "should escape ampersands in URLs when used as an image tag" do
|
635
|
-
Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').
|
646
|
+
expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to satisfy {|chart| expect(chart).to include "&" }
|
636
647
|
end
|
637
648
|
|
638
649
|
it "should be available as a file" do
|
639
650
|
File.delete('chart.png') if File.exist?('chart.png')
|
640
651
|
Gchart.line(:data => [0, 26], :format => 'file')
|
641
|
-
File.exist?('chart.png').
|
652
|
+
expect(File.exist?('chart.png')).to be
|
642
653
|
File.delete('chart.png') if File.exist?('chart.png')
|
643
654
|
end
|
644
655
|
|
645
656
|
it "should be available as a file using a custom file name" do
|
646
657
|
File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')
|
647
658
|
Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png')
|
648
|
-
File.exist?('custom_file_name.png').
|
659
|
+
expect(File.exist?('custom_file_name.png')).to be
|
649
660
|
File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')
|
650
661
|
end
|
651
662
|
|
@@ -658,21 +669,22 @@ describe 'exporting a chart' do
|
|
658
669
|
:format => "file",
|
659
670
|
:filename => "foo.png"
|
660
671
|
)
|
661
|
-
File.exist?('foo.png').
|
672
|
+
expect(File.exist?('foo.png')).to be
|
662
673
|
File.delete('foo.png') if File.exist?('foo.png')
|
663
674
|
end
|
664
|
-
|
665
675
|
end
|
666
676
|
|
667
677
|
describe 'SSL support' do
|
668
678
|
it 'should change url if is presented' do
|
669
|
-
Gchart.line(:use_ssl => true).
|
679
|
+
expect(Gchart.line(:use_ssl => true)).to include('https://chart.googleapis.com/chart?')
|
670
680
|
end
|
671
|
-
|
681
|
+
|
672
682
|
it "should be available as a file" do
|
683
|
+
pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)"
|
673
684
|
File.delete('chart.png') if File.exist?('chart.png')
|
674
685
|
Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true)
|
675
|
-
File.exist?('chart.png').
|
686
|
+
expect(File.exist?('chart.png')).to be_true
|
676
687
|
File.delete('chart.png') if File.exist?('chart.png')
|
677
688
|
end
|
678
689
|
end
|
690
|
+
|