matta-googlecharts 1.1.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/History.txt +9 -0
- data/README.txt +1 -0
- data/lib/gchart/version.rb +1 -1
- data/lib/gchart.rb +6 -2
- data/spec/gchart_spec.rb +100 -2
- data/website/index.html +61 -5
- data/website/index.txt +34 -0
- metadata +2 -2
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/README.txt
CHANGED
data/lib/gchart/version.rb
CHANGED
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']
|
|
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
|
|
@@ -247,6 +247,10 @@ class Gchart
|
|
|
247
247
|
"cht=v"
|
|
248
248
|
when :scatter
|
|
249
249
|
"cht=s"
|
|
250
|
+
when :sparkline
|
|
251
|
+
"cht=ls"
|
|
252
|
+
when :meter
|
|
253
|
+
"cht=gom"
|
|
250
254
|
end
|
|
251
255
|
end
|
|
252
256
|
|
|
@@ -284,7 +288,7 @@ class Gchart
|
|
|
284
288
|
dataset = prepare_dataset(dataset)
|
|
285
289
|
@max_value = dataset.map{|ds| ds.max}.max if @max_value == 'auto'
|
|
286
290
|
|
|
287
|
-
if @max_value == false || @max_value == 'false' || @max_value == :false
|
|
291
|
+
if @max_value == false || @max_value == 'false' || @max_value == :false || @max_value == 0
|
|
288
292
|
"s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value(number) }.join }.join(',')
|
|
289
293
|
else
|
|
290
294
|
"s:" + dataset.map { |ds| ds.map { |number| convert_to_simple_value( (@@simple_chars.size - 1) * number / @max_value) }.join }.join(',')
|
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,80 @@ 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
|
|
229
|
+
|
|
230
|
+
before(:each) do
|
|
231
|
+
@title = 'Chart Title'
|
|
232
|
+
@legend = ['first data set label', 'n data set label']
|
|
233
|
+
@jstized_legend = Gchart.jstize(@legend.join('|'))
|
|
234
|
+
@data = [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]
|
|
235
|
+
@chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
it "should create a sparkline" do
|
|
239
|
+
@chart.include?('cht=ls').should be_true
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
it 'should be able have a chart title' do
|
|
243
|
+
@chart.include?("chtt=Chart+Title").should be_true
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it "should be able to a custom color and size title" do
|
|
247
|
+
Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true
|
|
248
|
+
Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
it "should be able to have multiple legends" do
|
|
252
|
+
@chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it "should be able to have one legend" do
|
|
256
|
+
chart = Gchart.sparkline(:legend => 'legend label')
|
|
257
|
+
chart.include?("chdl=legend+label").should be_true
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
it "should be able to set the background fill" do
|
|
261
|
+
Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true
|
|
262
|
+
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true
|
|
263
|
+
|
|
264
|
+
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
|
|
265
|
+
Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
|
|
266
|
+
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true
|
|
267
|
+
|
|
268
|
+
Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
it "should be able to set a graph fill" do
|
|
272
|
+
Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true
|
|
273
|
+
Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true
|
|
274
|
+
Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
|
|
275
|
+
Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
|
|
276
|
+
Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
it "should be able to set both a graph and a background fill" do
|
|
280
|
+
Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true
|
|
281
|
+
Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true
|
|
282
|
+
Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
it "should be able to have different line colors" do
|
|
286
|
+
Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
|
|
287
|
+
Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
describe "a 3d pie chart" do
|
|
215
293
|
|
|
216
294
|
before(:each) do
|
|
217
295
|
@title = 'Chart Title'
|
|
@@ -237,6 +315,26 @@ describe "a pie chart" do
|
|
|
237
315
|
|
|
238
316
|
end
|
|
239
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
|
+
|
|
240
338
|
describe 'exporting a chart' do
|
|
241
339
|
|
|
242
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
|
|
|
@@ -47,7 +47,15 @@
|
|
|
47
47
|
<h2>Installing</h2>
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
<p
|
|
50
|
+
<p>This project is now hosted at <a href="http://github.com">GitHub</a>
|
|
51
|
+
If you never added <a href="http://github.com">GitHub</a> as a gem source, you will need to do the following:
|
|
52
|
+
<pre class='syntax'><span class="global">$ </span><span class="ident">gem</span> <span class="ident">sources</span> <span class="punct">-</span><span class="ident">a</span> <span class="ident">http</span><span class="punct">:/</span><span class="regex"></span><span class="punct">/</span><span class="ident">gems</span><span class="punct">.</span><span class="ident">github</span><span class="punct">.</span><span class="ident">com</span><span class="punct">/</span></pre> (you only need to do this once)</p>
|
|
53
|
+
|
|
54
|
+
|
|
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
|
+
|
|
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>
|
|
51
59
|
|
|
52
60
|
|
|
53
61
|
<h2>The basics</h2>
|
|
@@ -77,10 +85,23 @@
|
|
|
77
85
|
<p><img src="http://chart.apis.google.com/chart?cht=p3&chd=s:Uf9a&chs=200x100&chl=A|B|C|D" title="pie_3d" alt="pie_3d" /> Gchart.pie_3d()</p>
|
|
78
86
|
|
|
79
87
|
|
|
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>
|
|
89
|
+
|
|
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
|
+
|
|
80
94
|
<h2>Demonstration of usage</h2>
|
|
81
95
|
|
|
82
96
|
|
|
83
|
-
install
|
|
97
|
+
<p>install:</p>
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<code>sudo gem install matta-googlecharts</code>
|
|
101
|
+
|
|
102
|
+
<p>or use rubyforge:</p>
|
|
103
|
+
|
|
104
|
+
|
|
84
105
|
<code>sudo gem install googlecharts</code>
|
|
85
106
|
|
|
86
107
|
<p>require:
|
|
@@ -135,6 +156,21 @@ install:
|
|
|
135
156
|
<p><a href="http://code.google.com/apis/chart/#chart_colors">more info about color settings</a></p>
|
|
136
157
|
|
|
137
158
|
|
|
159
|
+
<p><strong>sparkline chart</strong></p>
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
<p><pre class='syntax'>
|
|
163
|
+
<span class="ident">data</span> <span class="punct">=</span> <span class="punct">[</span><span class="number">27</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">27</span><span class="punct">,</span><span class="number">100</span><span class="punct">,</span><span class="number">31</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">36</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">39</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">31</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">28</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">100</span><span class="punct">,</span><span class="number">28</span><span class="punct">,</span><span class="number">27</span><span class="punct">,</span><span class="number">31</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">27</span><span class="punct">,</span><span class="number">27</span><span class="punct">,</span><span class="number">29</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">27</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">35</span><span class="punct">,</span><span class="number">33</span><span class="punct">,</span><span class="number">34</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">36</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">26</span><span class="punct">,</span><span class="number">37</span><span class="punct">,</span><span class="number">33</span><span class="punct">,</span><span class="number">33</span><span class="punct">,</span><span class="number">37</span><span class="punct">,</span><span class="number">37</span><span class="punct">,</span><span class="number">39</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">,</span><span class="number">25</span><span class="punct">]</span>
|
|
164
|
+
<span class="constant">Gchart</span><span class="punct">.</span><span class="ident">sparkline</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=></span> <span class="ident">data</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">120x40</span><span class="punct">',</span> <span class="symbol">:line_colors</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">0077CC</span><span class="punct">')</span>
|
|
165
|
+
</pre></p>
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
<p><img src="http://chart.apis.google.com/chart?chd=s:QPPPPQ9SPVPPXPSPPPPPPPRPP9RQSPQQRPQPPPPPVUUPPPVPPWUUWWXPPPP&chco=0077CC&chs=120x40&cht=ls" title="sparline" alt="sparline" /></p>
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
<p>A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default.</p>
|
|
172
|
+
|
|
173
|
+
|
|
138
174
|
<p><strong>bar chart</strong></p>
|
|
139
175
|
|
|
140
176
|
|
|
@@ -253,6 +289,20 @@ Data set:
|
|
|
253
289
|
<p><img src="http://chart.apis.google.com/chart?cht=s&chs=300x200&chd=s:MYkw9,MYkw9,9wkYM" title="scatter" alt="scatter" /></p>
|
|
254
290
|
|
|
255
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
|
+
|
|
256
306
|
<hr />
|
|
257
307
|
|
|
258
308
|
|
|
@@ -571,7 +621,7 @@ Data set:
|
|
|
571
621
|
<h2>Repository</h2>
|
|
572
622
|
|
|
573
623
|
|
|
574
|
-
<p>The trunk repository is <code>
|
|
624
|
+
<p>The trunk repository is <code>http://github.com/matta/googlecharts/</code> for anonymous access.</p>
|
|
575
625
|
|
|
576
626
|
|
|
577
627
|
<h2>License</h2>
|
|
@@ -584,8 +634,14 @@ Data set:
|
|
|
584
634
|
|
|
585
635
|
|
|
586
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>
|
|
587
643
|
<p class="coda">
|
|
588
|
-
<a href="mattaimonetti@gmail.com">Matt Aimonetti</a>,
|
|
644
|
+
<a href="mattaimonetti@gmail.com">Matt Aimonetti</a>, 7th May 2008<br>
|
|
589
645
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
|
590
646
|
</p>
|
|
591
647
|
</div>
|
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:
|
|
@@ -32,13 +34,21 @@ This gem supports the following types of charts:
|
|
|
32
34
|
!http://chart.apis.google.com/chart?cht=p&chd=s:world5&chs=200x125&chl=A|B|C|D|E|Fe(pie)! Gchart.pie()
|
|
33
35
|
|
|
34
36
|
!http://chart.apis.google.com/chart?cht=p3&chd=s:Uf9a&chs=200x100&chl=A|B|C|D(pie_3d)! Gchart.pie_3d()
|
|
37
|
+
|
|
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()
|
|
35
39
|
|
|
40
|
+
!http://chart.apis.google.com/chart?chs=225x125&cht=gom&chd=t:70&chl=Flavor(google-o-meter)! Gchart.meter()
|
|
36
41
|
|
|
37
42
|
h2. Demonstration of usage
|
|
38
43
|
|
|
39
44
|
install:
|
|
45
|
+
|
|
40
46
|
<code>sudo gem install matta-googlecharts</code>
|
|
41
47
|
|
|
48
|
+
or use rubyforge:
|
|
49
|
+
|
|
50
|
+
<code>sudo gem install googlecharts</code>
|
|
51
|
+
|
|
42
52
|
require:
|
|
43
53
|
<pre syntax="ruby">require 'gchart'</pre>
|
|
44
54
|
|
|
@@ -78,6 +88,17 @@ Inserted in an image tag, it will look like that:
|
|
|
78
88
|
|
|
79
89
|
"more info about color settings":http://code.google.com/apis/chart/#chart_colors
|
|
80
90
|
|
|
91
|
+
*sparkline chart*
|
|
92
|
+
|
|
93
|
+
<pre syntax="ruby">
|
|
94
|
+
data = [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]
|
|
95
|
+
Gchart.sparkline(:data => data, :size => '120x40', :line_colors => '0077CC')
|
|
96
|
+
</pre>
|
|
97
|
+
|
|
98
|
+
!http://chart.apis.google.com/chart?chd=s:QPPPPQ9SPVPPXPSPPPPPPPRPP9RQSPQQRPQPPPPPVUUPPPVPPWUUWWXPPPP&chco=0077CC&chs=120x40&cht=ls(sparline)!
|
|
99
|
+
|
|
100
|
+
A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default.
|
|
101
|
+
|
|
81
102
|
*bar chart*
|
|
82
103
|
|
|
83
104
|
<pre syntax="ruby">
|
|
@@ -167,6 +188,16 @@ Supply two data sets, the first data set specifies x coordinates, the second set
|
|
|
167
188
|
|
|
168
189
|
!http://chart.apis.google.com/chart?cht=s&chs=300x200&chd=s:MYkw9,MYkw9,9wkYM(scatter)!
|
|
169
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
|
+
|
|
170
201
|
---
|
|
171
202
|
|
|
172
203
|
*set a chart title*
|
|
@@ -419,3 +450,6 @@ h2. Contact
|
|
|
419
450
|
|
|
420
451
|
Comments are welcome. Send an email to "Matt Aimonetti":mailto:mattaimonetti@gmail.com
|
|
421
452
|
|
|
453
|
+
h3. Contributors
|
|
454
|
+
|
|
455
|
+
"David Grandinetti":http://github.com/dbgrandi
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: matta-googlecharts
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Aimonetti
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-
|
|
12
|
+
date: 2008-05-07 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|