googlecharts 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/README.txt CHANGED
@@ -14,6 +14,7 @@ This gem supports the following types of charts:
14
14
 
15
15
  * line,
16
16
  * line_xy
17
+ * sparkline
17
18
  * scatter
18
19
  * bar
19
20
  * venn
@@ -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']
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,8 @@ class Gchart
247
247
  "cht=v"
248
248
  when :scatter
249
249
  "cht=s"
250
+ when :sparkline
251
+ "cht=ls"
250
252
  end
251
253
  end
252
254
 
@@ -1,7 +1,7 @@
1
1
  module GchartInfo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 1
4
+ MINOR = 2
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
File without changes
File without changes
File without changes
@@ -213,6 +213,70 @@ end
213
213
 
214
214
  describe "a pie chart" do
215
215
 
216
+ before(:each) do
217
+ @title = 'Chart Title'
218
+ @legend = ['first data set label', 'n data set label']
219
+ @jstized_legend = Gchart.jstize(@legend.join('|'))
220
+ @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]
221
+ @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend)
222
+ end
223
+
224
+ it "should create a sparkline" do
225
+ @chart.include?('cht=ls').should be_true
226
+ end
227
+
228
+ it 'should be able have a chart title' do
229
+ @chart.include?("chtt=Chart+Title").should be_true
230
+ end
231
+
232
+ it "should be able to a custom color and size title" do
233
+ Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true
234
+ Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true
235
+ end
236
+
237
+ it "should be able to have multiple legends" do
238
+ @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true
239
+ end
240
+
241
+ it "should be able to have one legend" do
242
+ chart = Gchart.sparkline(:legend => 'legend label')
243
+ chart.include?("chdl=legend+label").should be_true
244
+ end
245
+
246
+ it "should be able to set the background fill" do
247
+ Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true
248
+ Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true
249
+
250
+ Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
251
+ Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
252
+ Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true
253
+
254
+ Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true
255
+ end
256
+
257
+ it "should be able to set a graph fill" do
258
+ Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true
259
+ Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true
260
+ Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
261
+ Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
262
+ Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true
263
+ end
264
+
265
+ it "should be able to set both a graph and a background fill" do
266
+ Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true
267
+ Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true
268
+ Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true
269
+ end
270
+
271
+ it "should be able to have different line colors" do
272
+ Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
273
+ Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
274
+ end
275
+
276
+ end
277
+
278
+ describe "a sparkline chart" do
279
+
216
280
  before(:each) do
217
281
  @title = 'Chart Title'
218
282
  @legend = ['first data set label', 'n data set label']
@@ -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.1.0</a>
36
+ <a href="http://rubyforge.org/projects/googlecharts" class="numbers">1.2.0</a>
37
37
  </div>
38
38
  <h2>&#x2192; &#8216;Sexy Charts using Google <span class="caps">API</span> &#38; Ruby&#8217;</h2>
39
39
 
@@ -47,7 +47,12 @@
47
47
  <h2>Installing</h2>
48
48
 
49
49
 
50
- <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">googlecharts</span></pre></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>
51
56
 
52
57
 
53
58
  <h2>The basics</h2>
@@ -77,11 +82,14 @@
77
82
  <p><img src="http://chart.apis.google.com/chart?cht=p3&#38;chd=s:Uf9a&#38;chs=200x100&#38;chl=A|B|C|D" title="pie_3d" alt="pie_3d" /> Gchart.pie_3d()</p>
78
83
 
79
84
 
85
+ <p><img src="http://chart.apis.google.com/chart?chs=100x20&#38;cht=ls&#38;chco=0077CC&#38;chm=B,E6F2FA,0,0,0&#38;chls=1,0,0&#38;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
+
87
+
80
88
  <h2>Demonstration of usage</h2>
81
89
 
82
90
 
83
91
  install:
84
- <code>sudo gem install googlecharts</code>
92
+ <code>sudo gem install matta-googlecharts</code>
85
93
 
86
94
  <p>require:
87
95
  <pre class='syntax'><span class="ident">require</span> <span class="punct">'</span><span class="string">gchart</span><span class="punct">'</span></pre></p>
@@ -135,6 +143,21 @@ install:
135
143
  <p><a href="http://code.google.com/apis/chart/#chart_colors">more info about color settings</a></p>
136
144
 
137
145
 
146
+ <p><strong>sparkline chart</strong></p>
147
+
148
+
149
+ <p><pre class='syntax'>
150
+ <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>
151
+ <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">=&gt;</span> <span class="ident">data</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">120x40</span><span class="punct">',</span> <span class="symbol">:line_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">0077CC</span><span class="punct">')</span>
152
+ </pre></p>
153
+
154
+
155
+ <p><img src="http://chart.apis.google.com/chart?chd=s:QPPPPQ9SPVPPXPSPPPPPPPRPP9RQSPQQRPQPPPPPVUUPPPVPPWUUWWXPPPP&#38;chco=0077CC&#38;chs=120x40&#38;cht=ls" title="sparline" alt="sparline" /></p>
156
+
157
+
158
+ <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>
159
+
160
+
138
161
  <p><strong>bar chart</strong></p>
139
162
 
140
163
 
@@ -571,7 +594,7 @@ Data set:
571
594
  <h2>Repository</h2>
572
595
 
573
596
 
574
- <p>The trunk repository is <code>svn://rubyforge.org/var/svn/Gchart/trunk</code> for anonymous access.</p>
597
+ <p>The trunk repository is <code>http://github.com/matta/googlecharts/</code> for anonymous access.</p>
575
598
 
576
599
 
577
600
  <h2>License</h2>
@@ -585,7 +608,7 @@ Data set:
585
608
 
586
609
  <p>Comments are welcome. Send an email to <a href="mailto:mattaimonetti@gmail.com">Matt Aimonetti</a></p>
587
610
  <p class="coda">
588
- <a href="mattaimonetti@gmail.com">Matt Aimonetti</a>, 19th December 2007<br>
611
+ <a href="mattaimonetti@gmail.com">Matt Aimonetti</a>, 7th May 2008<br>
589
612
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
590
613
  </p>
591
614
  </div>
@@ -9,7 +9,11 @@ h2. What
9
9
 
10
10
  h2. Installing
11
11
 
12
- <pre syntax="ruby">sudo gem install googlecharts</pre>
12
+ This project is now hosted at "GitHub":http://github.com
13
+ If you never added "GitHub":http://github.com as a gem source, you will need to do the following:
14
+ <pre syntax="ruby">$ gem sources -a http://gems.github.com/</pre> (you only need to do this once)
15
+
16
+ <pre syntax="ruby">$ sudo gem install matta-googlecharts</pre>
13
17
 
14
18
  h2. The basics
15
19
 
@@ -28,12 +32,14 @@ This gem supports the following types of charts:
28
32
  !http://chart.apis.google.com/chart?cht=p&chd=s:world5&chs=200x125&chl=A|B|C|D|E|Fe(pie)! Gchart.pie()
29
33
 
30
34
  !http://chart.apis.google.com/chart?cht=p3&chd=s:Uf9a&chs=200x100&chl=A|B|C|D(pie_3d)! Gchart.pie_3d()
35
+
36
+ !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()
31
37
 
32
38
 
33
39
  h2. Demonstration of usage
34
40
 
35
41
  install:
36
- <code>sudo gem install googlecharts</code>
42
+ <code>sudo gem install matta-googlecharts</code>
37
43
 
38
44
  require:
39
45
  <pre syntax="ruby">require 'gchart'</pre>
@@ -74,6 +80,17 @@ Inserted in an image tag, it will look like that:
74
80
 
75
81
  "more info about color settings":http://code.google.com/apis/chart/#chart_colors
76
82
 
83
+ *sparkline chart*
84
+
85
+ <pre syntax="ruby">
86
+ 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]
87
+ Gchart.sparkline(:data => data, :size => '120x40', :line_colors => '0077CC')
88
+ </pre>
89
+
90
+ !http://chart.apis.google.com/chart?chd=s:QPPPPQ9SPVPPXPSPPPPPPPRPP9RQSPQQRPQPPPPPVUUPPPVPPWUUWWXPPPP&chco=0077CC&chs=120x40&cht=ls(sparline)!
91
+
92
+ 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.
93
+
77
94
  *bar chart*
78
95
 
79
96
  <pre syntax="ruby">
@@ -405,7 +422,7 @@ The max value option is a simple way of scaling your graph. The data is converte
405
422
 
406
423
  h2. Repository
407
424
 
408
- The trunk repository is <code>svn://rubyforge.org/var/svn/Gchart/trunk</code> for anonymous access.
425
+ The trunk repository is <code>http://github.com/matta/googlecharts/</code> for anonymous access.
409
426
 
410
427
  h2. License
411
428
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlecharts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Aimonetti
@@ -30,7 +30,7 @@ cert_chain:
30
30
  ZR7qHIpykzr3ezcNiWtBWw==
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2008-02-06 00:00:00 -08:00
33
+ date: 2008-05-07 00:00:00 -07:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  requirements: []
98
98
 
99
99
  rubyforge_project: googlecharts
100
- rubygems_version: 1.0.1
100
+ rubygems_version: 1.1.1
101
101
  signing_key:
102
102
  specification_version: 2
103
103
  summary: description of gem
metadata.gz.sig CHANGED
Binary file