googlecharts 1.2.0 → 1.3.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.tar.gz.sig +0 -0
- data/History.txt +9 -0
- data/lib/gchart.rb +4 -2
- data/lib/gchart/version.rb +1 -1
- data/spec/gchart_spec.rb +37 -3
- data/website/index.html +35 -2
- data/website/index.txt +21 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
+
== 1.3.0
|
2
|
+
* added support for google-o-meter
|
3
|
+
* fixed a bug when the max value of a data set was 0
|
4
|
+
|
5
|
+
== 1.2.0
|
6
|
+
* added support for sparklines
|
7
|
+
|
1
8
|
== 1.1.0
|
2
9
|
* fixed another bug fix related to the uri escaping required to download the file properly.
|
10
|
+
|
3
11
|
== 1.0.0
|
4
12
|
* fixed the (URI::InvalidURIError) issue
|
13
|
+
|
5
14
|
== 0.2.0
|
6
15
|
* added export options (file and image tag)
|
7
16
|
* added support for all arguments to be passed as a string or an array
|
data/lib/gchart.rb
CHANGED
@@ -8,7 +8,7 @@ class Gchart
|
|
8
8
|
include GchartInfo
|
9
9
|
|
10
10
|
@@url = "http://chart.apis.google.com/chart?"
|
11
|
-
@@types = ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline']
|
11
|
+
@@types = ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'jstize', 'sparkline', 'meter']
|
12
12
|
@@simple_chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
|
13
13
|
@@chars = @@simple_chars + ['-', '.']
|
14
14
|
@@ext_pairs = @@chars.map { |char_1| @@chars.map { |char_2| char_1 + char_2 } }.flatten
|
@@ -249,6 +249,8 @@ class Gchart
|
|
249
249
|
"cht=s"
|
250
250
|
when :sparkline
|
251
251
|
"cht=ls"
|
252
|
+
when :meter
|
253
|
+
"cht=gom"
|
252
254
|
end
|
253
255
|
end
|
254
256
|
|
@@ -286,7 +288,7 @@ class Gchart
|
|
286
288
|
dataset = prepare_dataset(dataset)
|
287
289
|
@max_value = dataset.map{|ds| ds.max}.max if @max_value == 'auto'
|
288
290
|
|
289
|
-
if @max_value == false || @max_value == 'false' || @max_value == :false
|
291
|
+
if @max_value == false || @max_value == 'false' || @max_value == :false || @max_value == 0
|
290
292
|
"s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value(number) }.join }.join(',')
|
291
293
|
else
|
292
294
|
"s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value( (@@simple_chars.size - 1) * number / @max_value) }.join }.join(',')
|
data/lib/gchart/version.rb
CHANGED
data/spec/gchart_spec.rb
CHANGED
@@ -84,6 +84,11 @@ describe "generating different type of charts" do
|
|
84
84
|
Gchart.line.include?('cht=lc').should be_true
|
85
85
|
end
|
86
86
|
|
87
|
+
it "should be able to generate a sparkline chart" do
|
88
|
+
Gchart.sparkline.should be_an_instance_of(String)
|
89
|
+
Gchart.sparkline.include?('cht=ls').should be_true
|
90
|
+
end
|
91
|
+
|
87
92
|
it "should be able to generate a line xy chart" do
|
88
93
|
Gchart.line_xy.should be_an_instance_of(String)
|
89
94
|
Gchart.line_xy.include?('cht=lxy').should be_true
|
@@ -109,6 +114,11 @@ describe "generating different type of charts" do
|
|
109
114
|
Gchart.pie.include?('cht=p').should be_true
|
110
115
|
end
|
111
116
|
|
117
|
+
it "should be able to generate a Google-O-Meter" do
|
118
|
+
Gchart.meter.should be_an_instance_of(String)
|
119
|
+
Gchart.meter.include?('cht=gom').should be_true
|
120
|
+
end
|
121
|
+
|
112
122
|
it "should not support other types" do
|
113
123
|
Gchart.sexy.should == "sexy is not a supported chart format, please use one of the following: #{Gchart.supported_types}."
|
114
124
|
end
|
@@ -206,12 +216,16 @@ describe "a line chart" do
|
|
206
216
|
|
207
217
|
it "should be able to have different line colors" do
|
208
218
|
Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
|
209
|
-
|
219
|
+
Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should be able to render a graph where all the data values are 0" do
|
223
|
+
Gchart.line(:data => [0, 0, 0]).include?("chd=s:AAA").should be true
|
210
224
|
end
|
211
225
|
|
212
226
|
end
|
213
227
|
|
214
|
-
describe "a
|
228
|
+
describe "a sparkline chart" do
|
215
229
|
|
216
230
|
before(:each) do
|
217
231
|
@title = 'Chart Title'
|
@@ -275,7 +289,7 @@ describe "a pie chart" do
|
|
275
289
|
|
276
290
|
end
|
277
291
|
|
278
|
-
describe "a
|
292
|
+
describe "a 3d pie chart" do
|
279
293
|
|
280
294
|
before(:each) do
|
281
295
|
@title = 'Chart Title'
|
@@ -301,6 +315,26 @@ describe "a sparkline chart" do
|
|
301
315
|
|
302
316
|
end
|
303
317
|
|
318
|
+
describe "a google-o-meter" do
|
319
|
+
|
320
|
+
before(:each) do
|
321
|
+
@data = [70]
|
322
|
+
@legend = ['arrow points here']
|
323
|
+
@jstized_legend = Gchart.jstize(@legend.join('|'))
|
324
|
+
@chart = Gchart.meter(:data => @data)
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should greate a meter" do
|
328
|
+
@chart.include?('cht=gom').should be_true
|
329
|
+
end
|
330
|
+
|
331
|
+
it "should be able to set a solid background fill" do
|
332
|
+
Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true
|
333
|
+
Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
337
|
+
|
304
338
|
describe 'exporting a chart' do
|
305
339
|
|
306
340
|
it "should be available in the url format by default" do
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Googlecharts</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/googlecharts"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/googlecharts" class="numbers">1.
|
36
|
+
<a href="http://rubyforge.org/projects/googlecharts" class="numbers">1.3.0</a>
|
37
37
|
</div>
|
38
38
|
<h2>→ ‘Sexy Charts using Google <span class="caps">API</span> & Ruby’</h2>
|
39
39
|
|
@@ -55,6 +55,9 @@ If you never added <a href="http://github.com">GitHub</a> as a gem source, you w
|
|
55
55
|
<p><pre class='syntax'><span class="global">$ </span><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">matta</span><span class="punct">-</span><span class="ident">googlecharts</span></pre></p>
|
56
56
|
|
57
57
|
|
58
|
+
<p>or <pre class='syntax'><span class="global">$ </span><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">googlecharts</span></pre></p>
|
59
|
+
|
60
|
+
|
58
61
|
<h2>The basics</h2>
|
59
62
|
|
60
63
|
|
@@ -85,12 +88,22 @@ If you never added <a href="http://github.com">GitHub</a> as a gem source, you w
|
|
85
88
|
<p><img src="http://chart.apis.google.com/chart?chs=100x20&cht=ls&chco=0077CC&chm=B,E6F2FA,0,0,0&chls=1,0,0&chd=t:27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25" title="sparkline" alt="sparkline" />Gchart.sparkline()</p>
|
86
89
|
|
87
90
|
|
91
|
+
<p><img src="http://chart.apis.google.com/chart?chs=225x125&cht=gom&chd=t:70&chl=Flavor" title="google-o-meter" alt="google-o-meter" /> Gchart.meter()</p>
|
92
|
+
|
93
|
+
|
88
94
|
<h2>Demonstration of usage</h2>
|
89
95
|
|
90
96
|
|
91
|
-
install
|
97
|
+
<p>install:</p>
|
98
|
+
|
99
|
+
|
92
100
|
<code>sudo gem install matta-googlecharts</code>
|
93
101
|
|
102
|
+
<p>or use rubyforge:</p>
|
103
|
+
|
104
|
+
|
105
|
+
<code>sudo gem install googlecharts</code>
|
106
|
+
|
94
107
|
<p>require:
|
95
108
|
<pre class='syntax'><span class="ident">require</span> <span class="punct">'</span><span class="string">gchart</span><span class="punct">'</span></pre></p>
|
96
109
|
|
@@ -276,6 +289,20 @@ Data set:
|
|
276
289
|
<p><img src="http://chart.apis.google.com/chart?cht=s&chs=300x200&chd=s:MYkw9,MYkw9,9wkYM" title="scatter" alt="scatter" /></p>
|
277
290
|
|
278
291
|
|
292
|
+
<p><strong>google-o-meter</strong></p>
|
293
|
+
|
294
|
+
|
295
|
+
<p><a href="http://code.google.com/apis/chart/#gom">Google Documentation</a></p>
|
296
|
+
|
297
|
+
|
298
|
+
<p>Supply a single label that will be what the arrow points to. It only supports a solid fill for the background.</p>
|
299
|
+
|
300
|
+
|
301
|
+
<p><pre class='syntax'>
|
302
|
+
<span class="constant">Gchart</span><span class="punct">.</span><span class="ident">meter</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=></span> <span class="punct">[</span><span class="number">70</span><span class="punct">],</span> <span class="symbol">:label</span> <span class="punct">=></span> <span class="punct">['</span><span class="string">Flavor</span><span class="punct">'])</span>
|
303
|
+
</pre></p>
|
304
|
+
|
305
|
+
|
279
306
|
<hr />
|
280
307
|
|
281
308
|
|
@@ -607,6 +634,12 @@ Data set:
|
|
607
634
|
|
608
635
|
|
609
636
|
<p>Comments are welcome. Send an email to <a href="mailto:mattaimonetti@gmail.com">Matt Aimonetti</a></p>
|
637
|
+
|
638
|
+
|
639
|
+
<h3>Contributors</h3>
|
640
|
+
|
641
|
+
|
642
|
+
<p><a href="http://github.com/dbgrandi">David Grandinetti</a></p>
|
610
643
|
<p class="coda">
|
611
644
|
<a href="mattaimonetti@gmail.com">Matt Aimonetti</a>, 7th May 2008<br>
|
612
645
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
data/website/index.txt
CHANGED
@@ -15,6 +15,8 @@ If you never added "GitHub":http://github.com as a gem source, you will need to
|
|
15
15
|
|
16
16
|
<pre syntax="ruby">$ sudo gem install matta-googlecharts</pre>
|
17
17
|
|
18
|
+
or <pre syntax="ruby">$ sudo gem install googlecharts</pre>
|
19
|
+
|
18
20
|
h2. The basics
|
19
21
|
|
20
22
|
This gem supports the following types of charts:
|
@@ -35,12 +37,18 @@ This gem supports the following types of charts:
|
|
35
37
|
|
36
38
|
!http://chart.apis.google.com/chart?chs=100x20&cht=ls&chco=0077CC&chm=B,E6F2FA,0,0,0&chls=1,0,0&chd=t:27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25(sparkline)!Gchart.sparkline()
|
37
39
|
|
40
|
+
!http://chart.apis.google.com/chart?chs=225x125&cht=gom&chd=t:70&chl=Flavor(google-o-meter)! Gchart.meter()
|
38
41
|
|
39
42
|
h2. Demonstration of usage
|
40
43
|
|
41
44
|
install:
|
45
|
+
|
42
46
|
<code>sudo gem install matta-googlecharts</code>
|
43
47
|
|
48
|
+
or use rubyforge:
|
49
|
+
|
50
|
+
<code>sudo gem install googlecharts</code>
|
51
|
+
|
44
52
|
require:
|
45
53
|
<pre syntax="ruby">require 'gchart'</pre>
|
46
54
|
|
@@ -180,6 +188,16 @@ Supply two data sets, the first data set specifies x coordinates, the second set
|
|
180
188
|
|
181
189
|
!http://chart.apis.google.com/chart?cht=s&chs=300x200&chd=s:MYkw9,MYkw9,9wkYM(scatter)!
|
182
190
|
|
191
|
+
*google-o-meter*
|
192
|
+
|
193
|
+
"Google Documentation":http://code.google.com/apis/chart/#gom
|
194
|
+
|
195
|
+
Supply a single label that will be what the arrow points to. It only supports a solid fill for the background.
|
196
|
+
|
197
|
+
<pre syntax="ruby">
|
198
|
+
Gchart.meter(:data => [70], :label => ['Flavor'])
|
199
|
+
</pre>
|
200
|
+
|
183
201
|
---
|
184
202
|
|
185
203
|
*set a chart title*
|
@@ -432,3 +450,6 @@ h2. Contact
|
|
432
450
|
|
433
451
|
Comments are welcome. Send an email to "Matt Aimonetti":mailto:mattaimonetti@gmail.com
|
434
452
|
|
453
|
+
h3. Contributors
|
454
|
+
|
455
|
+
"David Grandinetti":http://github.com/dbgrandi
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|