googlecharts 0.0.3 → 0.1.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/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.0.4 2007-12-11
2
+ * fixed the axis labels
3
+
1
4
  == 0.0.3 2007-12-11
2
5
  * added :chart_background alias and fixed a bug related to the background colors.
3
6
 
data/lib/gchart.rb CHANGED
@@ -192,9 +192,8 @@ class Gchart
192
192
 
193
193
  def set_axis_labels
194
194
  labels_arr = []
195
- axis_labels.each_with_index{|labels,index| labels_arr << "#{index}:#{labels}"}
195
+ axis_labels.each_with_index{|labels,index| labels_arr << "#{index}:|#{labels}"}
196
196
  "chxl=#{labels_arr.join('|')}"
197
- #"chxl=0:Jan|July|Jan|July|Jan|1:0|100|2:A|B|C|3:2005|2006|2007"
198
197
  end
199
198
 
200
199
  def set_type
@@ -1,8 +1,8 @@
1
1
  module GchartInfo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 0
5
- TINY = 3
4
+ MINOR = 1
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/spec/gchart_spec.rb CHANGED
@@ -68,7 +68,8 @@ describe "generating a default Gchart" do
68
68
  end
69
69
 
70
70
  it "should be able to have axis labels" do
71
- Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?('chxl=0:Jan|July|Jan|July|Jan|1:0|100|2:A|B|C|3:2005|2006|2007').should be_true
71
+ Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007').should be_true
72
+ Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?('chxl=0:|Jan|July|Jan|July|Jan').should be_true
72
73
  end
73
74
 
74
75
  end
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">0.0.2</a>
36
+ <a href="http://rubyforge.org/projects/googlecharts" class="numbers">0.1.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
 
@@ -97,10 +97,11 @@ install:
97
97
  <hr />
98
98
 
99
99
 
100
- <strong>simple line chart</strong>
101
- <pre syntax"ruby">
102
- Gchart.line(:data =&gt; [0, 40, 10, 70, 20])
103
- </pre>
100
+ <p><strong>simple line chart</strong>
101
+ <pre class='syntax'>
102
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">70</span><span class="punct">,</span> <span class="number">20</span><span class="punct">])</span>
103
+ </pre></p>
104
+
104
105
 
105
106
  <p>Generate the following url: http://chart.apis.google.com/chart?chs=300&#215;200&#38;chd=s:AiI9R&#38;cht=lc</p>
106
107
 
@@ -111,10 +112,11 @@ install:
111
112
  <p><img src="http://chart.apis.google.com/chart?chs=300x200&#38;chd=s:AiI9R&#38;cht=lc" title="simple line chart" alt="simple line chart" /></p>
112
113
 
113
114
 
114
- <strong>multiple line charts</strong>
115
- <pre syntax"ruby">
116
- Gchart.line(:data =&gt; [[0, 40, 10, 70, 20],[41, 10, 80, 50]])
117
- </pre>
115
+ <p><strong>multiple line charts</strong>
116
+ <pre class='syntax'>
117
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">0</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">70</span><span class="punct">,</span> <span class="number">20</span><span class="punct">],[</span><span class="number">41</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">80</span><span class="punct">,</span> <span class="number">50</span><span class="punct">]])</span>
118
+ </pre></p>
119
+
118
120
 
119
121
  <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:AeH1P,fH9m" title="multiple lines chart" alt="multiple lines chart" /></p>
120
122
 
@@ -122,9 +124,10 @@ install:
122
124
  <p><strong>set line colors</strong></p>
123
125
 
124
126
 
125
- <pre syntax"ruby">
126
- Gchart.line(:data =&gt; [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :line_colors =&gt; "FF0000,00FF00")
127
- </pre>
127
+ <p><pre class='syntax'>
128
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">0</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">70</span><span class="punct">,</span> <span class="number">20</span><span class="punct">],[</span><span class="number">41</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">80</span><span class="punct">,</span> <span class="number">50</span><span class="punct">]],</span> <span class="symbol">:line_colors</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">FF0000,00FF00</span><span class="punct">&quot;)</span>
129
+ </pre></p>
130
+
128
131
 
129
132
  <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:AeH1P,fH9m&#38;chco=FF0000,00FF00" title="line colors" alt="line colors" /></p>
130
133
 
@@ -135,26 +138,73 @@ install:
135
138
  <p><strong>bar chart</strong></p>
136
139
 
137
140
 
138
- <pre syntax"ruby">
139
- Gchart.bar(:data =&gt; [300, 100, 30, 200])
141
+ <p><pre class='syntax'>
142
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">])</span>
140
143
  </pre>
141
- <img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:9UGo" title="bars" alt="bars" />
144
+ <img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:9UGo" title="bars" alt="bars" /></p>
145
+
142
146
 
143
- <p><strong>Set the bar chart orientation</strong></p>
147
+ <p><strong>set the bar chart orientation</strong></p>
144
148
 
145
149
 
146
- <pre syntax"ruby">
147
- Gchart.bar(:data =&gt; [300, 100, 30, 200], :orientation =&gt; 'horizontal')
150
+ <p><pre class='syntax'>
151
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="symbol">:orientation</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">horizontal</span><span class="punct">')</span>
148
152
  </pre>
149
- <img src="http://chart.apis.google.com/chart?cht=bhs&#38;chs=300x200&#38;chd=s:9UGo" title="bars" alt="bars" />
153
+ <img src="http://chart.apis.google.com/chart?cht=bhs&#38;chs=300x200&#38;chd=s:9UGo" title="bars" alt="bars" /></p>
154
+
155
+
156
+ <p><strong>multiple bars chart</strong></p>
157
+
158
+
159
+ <p><pre class='syntax'>
160
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]])</span>
161
+ </pre></p>
162
+
163
+
164
+ <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:9UGo,Uo9C" title="stacked multiple bars" alt="stacked multiple bars" /></p>
165
+
166
+
167
+ <p>The problem is that by default the bars are stacked, so we need to set the colors:</p>
168
+
169
+
170
+ <p><pre class='syntax'>
171
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span> <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">')</span>
172
+ </pre></p>
173
+
174
+
175
+ <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00" title="colors" alt="colors" /></p>
176
+
177
+
178
+ <p>The problem now, is that we can&#8217;t see the first value of the second dataset since it&#8217;s lower than the first value of the first dataset. Let&#8217;s unstack the bars:</p>
179
+
180
+
181
+ <p><pre class='syntax'>
182
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span>
183
+ <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">',</span>
184
+ <span class="symbol">:stacked</span> <span class="punct">=&gt;</span> <span class="constant">false</span> <span class="punct">)</span>
185
+ </pre></p>
186
+
187
+
188
+ <p><img src="http://chart.apis.google.com/chart?cht=bvg&#38;chs=300x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00" title="grouped bars" alt="grouped bars" /></p>
189
+
150
190
 
151
191
  <p><strong>pie chart</strong></p>
152
192
 
153
193
 
154
- <pre syntax"ruby">
155
- Gchart.pie(:data =&gt; [20, 35, 45])
194
+ <p><pre class='syntax'>
195
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">pie</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">20</span><span class="punct">,</span> <span class="number">35</span><span class="punct">,</span> <span class="number">45</span><span class="punct">])</span>
156
196
  </pre>
157
- <img src="http://chart.apis.google.com/chart?cht=p&#38;chs=300x200&#38;chd=s:bv9" title="Pie Chart" alt="Pie Chart" />
197
+ <img src="http://chart.apis.google.com/chart?cht=p&#38;chs=300x200&#38;chd=s:bv9" title="Pie Chart" alt="Pie Chart" /></p>
198
+
199
+
200
+ <p><strong>3D pie chart</strong></p>
201
+
202
+
203
+ <p><pre class='syntax'>
204
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">pie_3d</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">20</span><span class="punct">,</span> <span class="number">35</span><span class="punct">,</span> <span class="number">45</span><span class="punct">])</span>
205
+ </pre>
206
+ <img src="http://chart.apis.google.com/chart?cht=p3&#38;chs=300x200&#38;chd=s:bv9" title="Pie Chart" alt="Pie Chart" /></p>
207
+
158
208
 
159
209
  <p><strong>venn diagram</strong></p>
160
210
 
@@ -172,10 +222,11 @@ Data set:
172
222
  </ul>
173
223
 
174
224
 
175
- <pre syntax"ruby">
176
- Gchart.venn(:data =&gt; [100, 80, 60, 30, 30, 30, 10])
225
+ <p><pre class='syntax'>
226
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">venn</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">,</span> <span class="number">60</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">])</span>
177
227
  </pre>
178
- <img src="http://chart.apis.google.com/chart?cht=v&#38;chs=300x200&#38;chd=s:9wkSSSG" title="Venn" alt="Venn" />
228
+ <img src="http://chart.apis.google.com/chart?cht=v&#38;chs=300x200&#38;chd=s:9wkSSSG" title="Venn" alt="Venn" /></p>
229
+
179
230
 
180
231
  <p><strong>scatter plot</strong></p>
181
232
 
@@ -186,21 +237,265 @@ Data set:
186
237
  <p>Supply two data sets, the first data set specifies x coordinates, the second set specifies y coordinates, the third set the data point size.</p>
187
238
 
188
239
 
189
- <pre syntax"ruby">
190
- Gchart.scatter(:data =&gt; [[1, 2, 3, 4, 5], [1, 2, 3, 4 ,5], [5, 4, 3, 2, 1]])
191
- </pre>
240
+ <p><pre class='syntax'>
241
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">scatter</span><span class="punct">(</span><span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">1</span><span class="punct">,</span> <span class="number">2</span><span class="punct">,</span> <span class="number">3</span><span class="punct">,</span> <span class="number">4</span><span class="punct">,</span> <span class="number">5</span><span class="punct">],</span> <span class="punct">[</span><span class="number">1</span><span class="punct">,</span> <span class="number">2</span><span class="punct">,</span> <span class="number">3</span><span class="punct">,</span> <span class="number">4</span> <span class="punct">,</span><span class="number">5</span><span class="punct">],</span> <span class="punct">[</span><span class="number">5</span><span class="punct">,</span> <span class="number">4</span><span class="punct">,</span> <span class="number">3</span><span class="punct">,</span> <span class="number">2</span><span class="punct">,</span> <span class="number">1</span><span class="punct">]])</span>
242
+ </pre></p>
243
+
192
244
 
193
245
  <p><img src="http://chart.apis.google.com/chart?cht=s&#38;chs=300x200&#38;chd=s:MYkw9,MYkw9,9wkYM" title="scatter" alt="scatter" /></p>
194
246
 
195
247
 
196
- <p><strong>set a title</strong></p>
248
+ <hr />
249
+
250
+
251
+ <p><strong>set a chart title</strong></p>
252
+
253
+
254
+ <p><pre class='syntax'>
255
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">])</span>
256
+ </pre></p>
257
+
258
+
259
+ <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness" title="chart title" alt="chart title" /></p>
260
+
261
+
262
+ <p><strong>set the title size</strong></p>
263
+
264
+
265
+ <p><pre class='syntax'>
266
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span> <span class="symbol">:title_size</span> <span class="punct">=&gt;</span> <span class="number">20</span><span class="punct">,</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">])</span>
267
+ </pre></p>
268
+
269
+
270
+ <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness&#38;chts=454545,20" title="title size" alt="title size" /></p>
271
+
272
+
273
+ <p><strong>set the title color</strong></p>
274
+
275
+
276
+ <p><pre class='syntax'>
277
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span><span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span> <span class="symbol">:title_color</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000</span><span class="punct">',</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">])</span>
278
+ </pre></p>
279
+
280
+
281
+ <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness&#38;chts=FF0000" title="Title color" alt="Title color" /></p>
282
+
283
+
284
+ <p><strong>set the chart&#8217;s size</strong></p>
285
+
286
+
287
+ <p><pre class='syntax'>
288
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Recent Chart Sexyness</span><span class="punct">&quot;,</span>
289
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">],</span>
290
+ <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">600x400</span><span class="punct">')</span>
291
+ </pre></p>
292
+
293
+
294
+ <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=600x400&#38;chd=s:JSGM9MY9&#38;chtt=Recent+Chart+Sexyness" title="size" alt="size" /></p>
295
+
296
+
297
+ <p><strong>set the image background color</strong></p>
298
+
299
+
300
+ <p><pre class='syntax'>
301
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
302
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
303
+ <span class="symbol">:background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF9994</span><span class="punct">')</span>
304
+ </pre></p>
305
+
306
+
307
+ <p><img src="http://chart.apis.google.com/chart?chf=bg,s,FF9994&#38;cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chtt=Matt's+Mojo" title="Background" alt="Background" /></p>
308
+
309
+
310
+ <p><strong>set the chart background color</strong></p>
311
+
312
+
313
+ <p><pre class='syntax'>
314
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
315
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
316
+ <span class="symbol">:background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF9994</span><span class="punct">',</span> <span class="symbol">:chart_background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">000000</span><span class="punct">')</span>
317
+ </pre></p>
318
+
319
+
320
+ <p><img src="http://chart.apis.google.com/chart?chf=c,s,000000|bg,s,FF9994&#38;cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chtt=Matt's+Mojo" title="chart background" alt="chart background" /></p>
321
+
322
+
323
+ <p><strong>Set bar/line colors</strong></p>
324
+
325
+
326
+ <p><pre class='syntax'>
327
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
328
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
329
+ <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">76A4FB</span><span class="punct">',</span>
330
+ <span class="symbol">:background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">EEEEEE</span><span class="punct">',</span> <span class="symbol">:chart_background</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">CCCCCC</span><span class="punct">')</span>
331
+ </pre></p>
332
+
333
+
334
+ <p><img src="http://chart.apis.google.com/chart?chf=c,s,CCCCCC|bg,s,EEEEEE&#38;cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chco=76A4FB&#38;chtt=Matt's+Mojo" title="bar colors" alt="bar colors" /></p>
197
335
 
198
336
 
199
- <pre syntax"ruby">
200
- Gchart.bar(:title =&gt; "Chart Sexyness in the last 5 days", :data =&gt; [15, 30, 10, 20, 100])
337
+ <p><pre class='syntax'>
338
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span>
339
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">15</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">40</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">90</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">80</span><span class="punct">],</span>
340
+ <span class="symbol">:line_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">76A4FB</span><span class="punct">')</span>
341
+ </pre></p>
342
+
343
+
344
+ <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:JSGM9MY929w&#38;chco=76A4FB&#38;chtt=Matt's+Mojo" title="line colors" alt="line colors" /></p>
345
+
346
+
347
+ <p><strong>legend / labels</strong></p>
348
+
349
+
350
+ <p><pre class='syntax'>
351
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">bar</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt vs Rob</span><span class="punct">&quot;,</span>
352
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span>
353
+ <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">',</span>
354
+ <span class="symbol">:stacked</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
355
+ <span class="symbol">:legend</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Rob's Mojo</span><span class="punct">&quot;]</span> <span class="punct">)</span>
201
356
  </pre>
357
+ <img src="http://chart.apis.google.com/chart?cht=bvg&#38;chdl=Matt's+Mojo|Rob's+Mojo&#38;chs=400x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00&#38;chtt=Matt+vs+Rob" title="legend" alt="legend" /></p>
358
+
359
+
360
+ <p><pre class='syntax'>
361
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Matt vs Rob</span><span class="punct">&quot;,</span>
362
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">],</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]],</span>
363
+ <span class="symbol">:bar_colors</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">',</span>
364
+ <span class="symbol">:stacked</span> <span class="punct">=&gt;</span> <span class="constant">false</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
365
+ <span class="symbol">:legend</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">Matt's Mojo</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Rob's Mojo</span><span class="punct">&quot;]</span> <span class="punct">)</span>
366
+ </pre>
367
+ <img src="http://chart.apis.google.com/chart?cht=lc&#38;chdl=Matt's+Mojo|Rob's+Mojo&#38;chs=400x200&#38;chd=s:9UGo,Uo9C&#38;chco=FF0000,00FF00&#38;chtt=Matt+vs+Rob" title="line legend" alt="line legend" /></p>
368
+
369
+
370
+ <p><pre class='syntax'>
371
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">pie_3d</span><span class="punct">(</span> <span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">ruby_fu</span><span class="punct">',</span> <span class="symbol">:size</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
372
+ <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">10</span><span class="punct">,</span> <span class="number">45</span><span class="punct">,</span> <span class="number">45</span><span class="punct">],</span> <span class="symbol">:labels</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">DHH</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Rob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Matt</span><span class="punct">&quot;]</span> <span class="punct">)</span>
373
+ </pre></p>
374
+
375
+
376
+ <p><img src="http://chart.apis.google.com/chart?cht=p3&#38;chl=DHH|Rob|Matt&#38;chs=400x200&#38;chd=s:N99&#38;chtt=ruby_fu" title="labels" alt="labels" /></p>
377
+
378
+
379
+ <p><strong>Display axis labels</strong></p>
380
+
381
+
382
+ <p><pre class='syntax'>
383
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x,y,r</span><span class="punct">')</span>
384
+ </pre></p>
385
+
386
+
387
+ <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chxt=x,y,r&#38;chd=s:9UGoUo9C" title="axis with labels" alt="axis with labels" /></p>
388
+
389
+
390
+ <p><pre class='syntax'>
391
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x</span><span class="punct">',</span>
392
+ <span class="symbol">:axis_labels</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">Jan|July|Jan|July|Jan</span><span class="punct">'])</span>
393
+ </pre></p>
394
+
395
+
396
+ <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chxl=0:|Jan|July|Jan|July|Jan&#38;chs=300x200&#38;chxt=x&#38;chd=s:9UGoUo9C" title="x labels" alt="x labels" /></p>
397
+
398
+
399
+ <p><strong>multiple axis labels</strong></p>
400
+
401
+
402
+ <p><pre class='syntax'>
403
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:axis_with_labels</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">x,r</span><span class="punct">',</span>
404
+ <span class="symbol">:axis_labels</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">Jan|July|Jan|July|Jan</span><span class="punct">',</span> <span class="punct">'</span><span class="string">2005|2006|2007</span><span class="punct">'])</span>
405
+ </pre></p>
406
+
407
+
408
+ <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chxl=0:|Jan|July|Jan|July|Jan|1:|2005|2006|2007&#38;chs=300x200&#38;chxt=x,r&#38;chd=s:9UGoUo9C" title="multiple axis labels" alt="multiple axis labels" /></p>
409
+
410
+
411
+ <p>(This syntax will probably be improved in the future)</p>
412
+
413
+
414
+ <p><strong>custom params</strong></p>
415
+
416
+
417
+ <p>I certainly didn&#8217;t cover the entire <span class="caps">API</span>, if you want to add your own params:</p>
418
+
419
+
420
+ <p><pre class='syntax'>
421
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="ident">custom</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&amp;chls=3,6,3|1,1,0</span><span class="punct">')</span>
422
+ </pre></p>
423
+
424
+
425
+ <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&#38;chls=3,6,3|1,1,0" title="Custom" alt="Custom" /></p>
426
+
427
+
428
+ <hr />
429
+
430
+
431
+ <p><strong>Encoding</strong></p>
432
+
433
+
434
+ <p>Google Chart <span class="caps">API</span> offers <a href="http://code.google.com/apis/chart/#chart_data">3 types of data encoding</a></p>
435
+
436
+
437
+ <ul>
438
+ <li>simple</li>
439
+ <li>text</li>
440
+ <li>extended</li>
441
+ </ul>
442
+
443
+
444
+ <p>By default this library uses the simple encoding, if you need a different type of encoding, you can change it really easily:</p>
445
+
446
+
447
+ <p>default / simple: chd=s:9UGoUo9C
448
+ <pre class='syntax'>
449
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]</span> <span class="punct">)</span>
450
+ </pre></p>
451
+
452
+
453
+ <p>extended: chd=e:..VVGZqqVVqq..CI
454
+ <pre class='syntax'>
455
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:encoding</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">extended</span><span class="punct">'</span> <span class="punct">)</span>
456
+ </pre></p>
457
+
458
+
459
+ <p>text: chd=t:300,100,30,200,100,200,300,10
460
+ <pre class='syntax'>
461
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:encoding</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">text</span><span class="punct">'</span> <span class="punct">)</span>
462
+ </pre></p>
463
+
464
+
465
+ <p>(note that the text encoding doesn&#8217;t use a max value and therefore should be under 100)</p>
466
+
467
+
468
+ <p><strong>Max value</strong></p>
469
+
470
+
471
+ <p>Simple and extended encoding support the max value option.</p>
472
+
473
+
474
+ <p>The max value option is a simple way of scaling your graph. The data is converted in chart value with the highest chart value being the highest point on the graph. By default, the calculation is done for you. However you can specify your own maximum or not use a maximum at all.</p>
475
+
476
+
477
+ <p><pre class='syntax'>
478
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">]</span> <span class="punct">)</span>
479
+ </pre></p>
480
+
481
+
482
+ <p>!http://chart.apis.google.com/chart?cht=lc&#38;chs=300&#215;200&#38;chd=s:9UGoUo9C(Title)</p>
483
+
484
+
485
+ <p><pre class='syntax'>
486
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">300</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">100</span><span class="punct">,</span> <span class="number">200</span><span class="punct">,</span> <span class="number">300</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:max_value</span> <span class="punct">=&gt;</span> <span class="number">500</span> <span class="punct">)</span>
487
+ </pre></p>
488
+
489
+
490
+ <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:kMDYMYkB" title="max 500" alt="max 500" /></p>
491
+
492
+
493
+ <p><pre class='syntax'>
494
+ <span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:data</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="number">100</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">20</span><span class="punct">,</span> <span class="number">10</span><span class="punct">,</span> <span class="number">14</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">10</span><span class="punct">],</span> <span class="symbol">:max_value</span> <span class="punct">=&gt;</span> <span class="constant">false</span> <span class="punct">)</span>
495
+ </pre></p>
496
+
202
497
 
203
- <p><img src="http://chart.apis.google.com/chart?cht=bvs&#38;chs=300x200&#38;chd=s:JSGM9&#38;chtt=Chart+Sexyness+in+the+last+5+days" title="chart title" alt="chart title" /></p>
498
+ <p><img src="http://chart.apis.google.com/chart?cht=lc&#38;chs=300x200&#38;chd=s:_UeUKOeK" title="real size" alt="real size" /></p>
204
499
 
205
500
 
206
501
  <h2>Repository</h2>
data/website/index.txt CHANGED
@@ -47,7 +47,7 @@ require:
47
47
  ---
48
48
 
49
49
  *simple line chart*
50
- <pre syntax"ruby">
50
+ <pre syntax="ruby">
51
51
  Gchart.line(:data => [0, 40, 10, 70, 20])
52
52
  </pre>
53
53
 
@@ -58,7 +58,7 @@ Inserted in an image tag, it will look like that:
58
58
  !http://chart.apis.google.com/chart?chs=300x200&chd=s:AiI9R&cht=lc(simple line chart)!
59
59
 
60
60
  *multiple line charts*
61
- <pre syntax"ruby">
61
+ <pre syntax="ruby">
62
62
  Gchart.line(:data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]])
63
63
  </pre>
64
64
 
@@ -66,7 +66,7 @@ Inserted in an image tag, it will look like that:
66
66
 
67
67
  *set line colors*
68
68
 
69
- <pre syntax"ruby">
69
+ <pre syntax="ruby">
70
70
  Gchart.line(:data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :line_colors => "FF0000,00FF00")
71
71
  </pre>
72
72
 
@@ -76,26 +76,59 @@ Inserted in an image tag, it will look like that:
76
76
 
77
77
  *bar chart*
78
78
 
79
- <pre syntax"ruby">
79
+ <pre syntax="ruby">
80
80
  Gchart.bar(:data => [300, 100, 30, 200])
81
81
  </pre>
82
82
  !http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo(bars)!
83
83
 
84
- *Set the bar chart orientation*
84
+ *set the bar chart orientation*
85
85
 
86
- <pre syntax"ruby">
86
+ <pre syntax="ruby">
87
87
  Gchart.bar(:data => [300, 100, 30, 200], :orientation => 'horizontal')
88
88
  </pre>
89
89
  !http://chart.apis.google.com/chart?cht=bhs&chs=300x200&chd=s:9UGo(bars)!
90
90
 
91
+ *multiple bars chart*
92
+
93
+ <pre syntax="ruby">
94
+ Gchart.bar(:data => [[300, 100, 30, 200], [100, 200, 300, 10]])
95
+ </pre>
96
+
97
+ !http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo,Uo9C(stacked multiple bars)!
98
+
99
+ The problem is that by default the bars are stacked, so we need to set the colors:
100
+
101
+ <pre syntax="ruby">
102
+ Gchart.bar(:data => [[300, 100, 30, 200], [100, 200, 300, 10]], :bar_colors => 'FF0000,00FF00')
103
+ </pre>
104
+
105
+ !http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00(colors)!
106
+
107
+ The problem now, is that we can't see the first value of the second dataset since it's lower than the first value of the first dataset. Let's unstack the bars:
108
+
109
+ <pre syntax="ruby">
110
+ Gchart.bar( :data => [[300, 100, 30, 200], [100, 200, 300, 10]],
111
+ :bar_colors => 'FF0000,00FF00',
112
+ :stacked => false )
113
+ </pre>
114
+
115
+ !http://chart.apis.google.com/chart?cht=bvg&chs=300x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00(grouped bars)!
116
+
91
117
 
92
118
  *pie chart*
93
119
 
94
- <pre syntax"ruby">
120
+ <pre syntax="ruby">
95
121
  Gchart.pie(:data => [20, 35, 45])
96
122
  </pre>
97
123
  !http://chart.apis.google.com/chart?cht=p&chs=300x200&chd=s:bv9(Pie Chart)!
98
124
 
125
+ *3D pie chart*
126
+
127
+ <pre syntax="ruby">
128
+ Gchart.pie_3d(:data => [20, 35, 45])
129
+ </pre>
130
+ !http://chart.apis.google.com/chart?cht=p3&chs=300x200&chd=s:bv9(Pie Chart)!
131
+
99
132
  *venn diagram*
100
133
 
101
134
  "Google documentation":http://code.google.com/apis/chart/#venn
@@ -107,7 +140,7 @@ Data set:
107
140
  * the sixth value specifies the area of C intersecting A
108
141
  * the seventh value specifies the area of A intersecting B intersecting C
109
142
 
110
- <pre syntax"ruby">
143
+ <pre syntax="ruby">
111
144
  Gchart.venn(:data => [100, 80, 60, 30, 30, 30, 10])
112
145
  </pre>
113
146
  !http://chart.apis.google.com/chart?cht=v&chs=300x200&chd=s:9wkSSSG(Venn)!
@@ -118,7 +151,7 @@ Data set:
118
151
 
119
152
  Supply two data sets, the first data set specifies x coordinates, the second set specifies y coordinates, the third set the data point size.
120
153
 
121
- <pre syntax"ruby">
154
+ <pre syntax="ruby">
122
155
  Gchart.scatter(:data => [[1, 2, 3, 4, 5], [1, 2, 3, 4 ,5], [5, 4, 3, 2, 1]])
123
156
  </pre>
124
157
 
@@ -128,31 +161,194 @@ Supply two data sets, the first data set specifies x coordinates, the second set
128
161
 
129
162
  *set a chart title*
130
163
 
131
- <pre syntax"ruby">
164
+ <pre syntax="ruby">
132
165
  Gchart.bar(:title => "Recent Chart Sexyness", :data => [15, 30, 10, 20, 100, 20, 40, 100])
133
166
  </pre>
134
167
 
135
168
  !http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness(chart title)!
136
169
 
170
+ *set the title size*
171
+
172
+ <pre syntax="ruby">
173
+ Gchart.bar(:title => "Recent Chart Sexyness", :title_size => 20, :data => [15, 30, 10, 20, 100, 20, 40, 100])
174
+ </pre>
175
+
176
+ !http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness&chts=454545,20(title size)!
177
+
178
+ *set the title color*
179
+
180
+ <pre syntax="ruby">
181
+ Gchart.bar(:title => "Recent Chart Sexyness", :title_color => 'FF0000', :data => [15, 30, 10, 20, 100, 20, 40, 100])
182
+ </pre>
183
+
184
+ !http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness&chts=FF0000(Title color)!
185
+
186
+ *set the chart's size*
187
+
188
+ <pre syntax="ruby">
189
+ Gchart.bar( :title => "Recent Chart Sexyness",
190
+ :data => [15, 30, 10, 20, 100, 20, 40, 100],
191
+ :size => '600x400')
192
+ </pre>
193
+
194
+ !http://chart.apis.google.com/chart?cht=bvs&chs=600x400&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness(size)!
195
+
137
196
  *set the image background color*
138
197
 
139
- <pre syntax"ruby">
198
+ <pre syntax="ruby">
140
199
  Gchart.bar( :title => "Matt's Mojo",
141
200
  :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
142
- :background => 'EEEEEE')
201
+ :background => 'FF9994')
143
202
  </pre>
144
203
 
145
- !http://chart.apis.google.com/chart?chf=bg,s,EEEEEE&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo(Background)!
204
+ !http://chart.apis.google.com/chart?chf=bg,s,FF9994&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo(Background)!
146
205
 
147
206
  *set the chart background color*
148
207
 
149
- <pre syntax"ruby">
208
+ <pre syntax="ruby">
209
+ Gchart.bar( :title => "Matt's Mojo",
210
+ :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
211
+ :background => 'FF9994', :chart_background => '000000')
212
+ </pre>
213
+
214
+ !http://chart.apis.google.com/chart?chf=c,s,000000|bg,s,FF9994&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo(chart background)!
215
+
216
+ *Set bar/line colors*
217
+
218
+ <pre syntax="ruby">
150
219
  Gchart.bar( :title => "Matt's Mojo",
151
220
  :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
152
- :background => 'EEEEEE', :chart_background => '000000')
221
+ :bar_colors => '76A4FB',
222
+ :background => 'EEEEEE', :chart_background => 'CCCCCC')
153
223
  </pre>
154
224
 
155
- !http://chart.apis.google.com/chart?chf=c,s,000000|bg,s,EEEEEE&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo(chart background)!
225
+ !http://chart.apis.google.com/chart?chf=c,s,CCCCCC|bg,s,EEEEEE&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chco=76A4FB&chtt=Matt's+Mojo(bar colors)!
226
+
227
+ <pre syntax="ruby">
228
+ Gchart.line( :title => "Matt's Mojo",
229
+ :data => [15, 30, 10, 20, 100, 20, 40, 100, 90, 100, 80],
230
+ :line_colors => '76A4FB')
231
+ </pre>
232
+
233
+ !http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:JSGM9MY929w&chco=76A4FB&chtt=Matt's+Mojo(line colors)!
234
+
235
+ *legend / labels*
236
+
237
+ <pre syntax="ruby">
238
+ Gchart.bar( :title => "Matt vs Rob",
239
+ :data => [[300, 100, 30, 200], [100, 200, 300, 10]],
240
+ :bar_colors => 'FF0000,00FF00',
241
+ :stacked => false, :size => '400x200',
242
+ :legend => ["Matt's Mojo", "Rob's Mojo"] )
243
+ </pre>
244
+ !http://chart.apis.google.com/chart?cht=bvg&chdl=Matt's+Mojo|Rob's+Mojo&chs=400x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00&chtt=Matt+vs+Rob(legend)!
245
+
246
+ <pre syntax="ruby">
247
+ Gchart.line( :title => "Matt vs Rob",
248
+ :data => [[300, 100, 30, 200], [100, 200, 300, 10]],
249
+ :bar_colors => 'FF0000,00FF00',
250
+ :stacked => false, :size => '400x200',
251
+ :legend => ["Matt's Mojo", "Rob's Mojo"] )
252
+ </pre>
253
+ !http://chart.apis.google.com/chart?cht=lc&chdl=Matt's+Mojo|Rob's+Mojo&chs=400x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00&chtt=Matt+vs+Rob(line legend)!
254
+
255
+
256
+ <pre syntax="ruby">
257
+ Gchart.pie_3d( :title => 'ruby_fu', :size => '400x200',
258
+ :data => [10, 45, 45], :labels => ["DHH", "Rob", "Matt"] )
259
+ </pre>
260
+
261
+ !http://chart.apis.google.com/chart?cht=p3&chl=DHH|Rob|Matt&chs=400x200&chd=s:N99&chtt=ruby_fu(labels)!
262
+
263
+ *Display axis labels*
264
+
265
+ <pre syntax="ruby">
266
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x,y,r')
267
+ </pre>
268
+
269
+ !http://chart.apis.google.com/chart?cht=lc&chs=300x200&chxt=x,y,r&chd=s:9UGoUo9C(axis with labels)!
270
+
271
+ <pre syntax="ruby">
272
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x',
273
+ :axis_labels => ['Jan|July|Jan|July|Jan'])
274
+ </pre>
275
+
276
+ !http://chart.apis.google.com/chart?cht=lc&chxl=0:|Jan|July|Jan|July|Jan&chs=300x200&chxt=x&chd=s:9UGoUo9C(x labels)!
277
+
278
+ *multiple axis labels*
279
+
280
+ <pre syntax="ruby">
281
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :axis_with_labels => 'x,r',
282
+ :axis_labels => ['Jan|July|Jan|July|Jan', '2005|2006|2007'])
283
+ </pre>
284
+
285
+ !http://chart.apis.google.com/chart?cht=lc&chxl=0:|Jan|July|Jan|July|Jan|1:|2005|2006|2007&chs=300x200&chxt=x,r&chd=s:9UGoUo9C(multiple axis labels)!
286
+
287
+ (This syntax will probably be improved in the future)
288
+
289
+ *custom params*
290
+
291
+ I certainly didn't cover the entire API, if you want to add your own params:
292
+
293
+ <pre syntax="ruby">
294
+ Gchart.line( custom => 'chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&chls=3,6,3|1,1,0')
295
+ </pre>
296
+
297
+ !http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&chls=3,6,3|1,1,0(Custom)!
298
+
299
+ ---
300
+
301
+ *Encoding*
302
+
303
+ Google Chart API offers "3 types of data encoding":http://code.google.com/apis/chart/#chart_data
304
+
305
+ * simple
306
+ * text
307
+ * extended
308
+
309
+ By default this library uses the simple encoding, if you need a different type of encoding, you can change it really easily:
310
+
311
+ default / simple: chd=s:9UGoUo9C
312
+ <pre syntax="ruby">
313
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10] )
314
+ </pre>
315
+
316
+ extended: chd=e:..VVGZqqVVqq..CI
317
+ <pre syntax="ruby">
318
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :encoding => 'extended' )
319
+ </pre>
320
+
321
+ text: chd=t:300,100,30,200,100,200,300,10
322
+ <pre syntax="ruby">
323
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :encoding => 'text' )
324
+ </pre>
325
+
326
+ (note that the text encoding doesn't use a max value and therefore should be under 100)
327
+
328
+ *Max value*
329
+
330
+ Simple and extended encoding support the max value option.
331
+
332
+ The max value option is a simple way of scaling your graph. The data is converted in chart value with the highest chart value being the highest point on the graph. By default, the calculation is done for you. However you can specify your own maximum or not use a maximum at all.
333
+
334
+ <pre syntax="ruby">
335
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10] )
336
+ </pre>
337
+
338
+ !http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:9UGoUo9C(Title)
339
+
340
+ <pre syntax="ruby">
341
+ Gchart.line( :data => [300, 100, 30, 200, 100, 200, 300, 10], :max_value => 500 )
342
+ </pre>
343
+
344
+ !http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:kMDYMYkB(max 500)!
345
+
346
+ <pre syntax="ruby">
347
+ Gchart.line( :data => [100, 20, 30, 20, 10, 14, 30, 10], :max_value => false )
348
+ </pre>
349
+
350
+ !http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:_UeUKOeK(real size)!
351
+
156
352
 
157
353
 
158
354
  h2. Repository
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: googlecharts
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.3
6
+ version: 0.1.0
7
7
  date: 2007-12-11 00:00:00 -08:00
8
8
  summary: description of gem
9
9
  require_paths:
metadata.gz.sig CHANGED
Binary file