googlecharts 1.3.1 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +4 -4
- data/History.txt +7 -0
- data/Manifest.txt +0 -11
- data/README.txt +5 -176
- data/Rakefile +29 -1
- data/lib/gchart.rb +35 -22
- data/lib/gchart/version.rb +1 -1
- data/spec/gchart_spec.rb +26 -2
- metadata +3 -15
- metadata.gz.sig +0 -0
- data/log/debug.log +0 -0
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/tasks/deployment.rake +0 -34
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -684
- data/website/index.txt +0 -476
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -53
metadata.gz.sig
CHANGED
Binary file
|
data/log/debug.log
DELETED
File without changes
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
begin
|
5
|
-
require 'newgem'
|
6
|
-
rescue LoadError
|
7
|
-
puts "\n\nGenerating the website requires the newgem RubyGem"
|
8
|
-
puts "Install: gem install newgem\n\n"
|
9
|
-
exit(1)
|
10
|
-
end
|
11
|
-
require 'redcloth'
|
12
|
-
require 'syntax/convertors/html'
|
13
|
-
require 'erb'
|
14
|
-
require File.dirname(__FILE__) + '/../lib/gchart'
|
15
|
-
|
16
|
-
version = Gchart.version
|
17
|
-
download = 'http://rubyforge.org/projects/googlecharts'
|
18
|
-
|
19
|
-
class Fixnum
|
20
|
-
def ordinal
|
21
|
-
# teens
|
22
|
-
return 'th' if (10..19).include?(self % 100)
|
23
|
-
# others
|
24
|
-
case self % 10
|
25
|
-
when 1: return 'st'
|
26
|
-
when 2: return 'nd'
|
27
|
-
when 3: return 'rd'
|
28
|
-
else return 'th'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class Time
|
34
|
-
def pretty
|
35
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def convert_syntax(syntax, source)
|
40
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
-
end
|
42
|
-
|
43
|
-
if ARGV.length >= 1
|
44
|
-
src, template = ARGV
|
45
|
-
template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
|
46
|
-
|
47
|
-
else
|
48
|
-
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
49
|
-
exit!
|
50
|
-
end
|
51
|
-
|
52
|
-
template = ERB.new(File.open(template).read)
|
53
|
-
|
54
|
-
title = nil
|
55
|
-
body = nil
|
56
|
-
File.open(src) do |fsrc|
|
57
|
-
title_text = fsrc.readline
|
58
|
-
body_text = fsrc.read
|
59
|
-
syntax_items = []
|
60
|
-
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
61
|
-
ident = syntax_items.length
|
62
|
-
element, syntax, source = $1, $2, $3
|
63
|
-
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
64
|
-
"syntax-temp-#{ident}"
|
65
|
-
}
|
66
|
-
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
67
|
-
body = RedCloth.new(body_text).to_html
|
68
|
-
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
69
|
-
end
|
70
|
-
stat = File.stat(src)
|
71
|
-
created = stat.ctime
|
72
|
-
modified = stat.mtime
|
73
|
-
|
74
|
-
$stdout << template.result(binding)
|
data/tasks/deployment.rake
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
desc 'Release the website and new gem version'
|
2
|
-
task :deploy => [:check_version, :website, :release] do
|
3
|
-
puts "Remember to create SVN tag:"
|
4
|
-
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
-
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
-
puts "Suggested comment:"
|
7
|
-
puts "Tagging release #{CHANGES}"
|
8
|
-
end
|
9
|
-
|
10
|
-
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
-
task :local_deploy => [:website_generate, :install_gem]
|
12
|
-
|
13
|
-
task :check_version do
|
14
|
-
unless ENV['VERSION']
|
15
|
-
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
-
exit
|
17
|
-
end
|
18
|
-
unless ENV['VERSION'] == VERS
|
19
|
-
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
-
exit
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
-
task :install_gem_no_doc => [:clean, :package] do
|
26
|
-
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
-
end
|
28
|
-
|
29
|
-
namespace :manifest do
|
30
|
-
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
-
task :refresh do
|
32
|
-
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
-
end
|
34
|
-
end
|
data/tasks/website.rake
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
desc 'Generate website files'
|
2
|
-
task :website_generate => :ruby_env do
|
3
|
-
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
-
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
desc 'Upload website files to rubyforge'
|
9
|
-
task :website_upload do
|
10
|
-
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
-
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
-
local_dir = 'website'
|
13
|
-
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'Generate and upload website files'
|
17
|
-
task :website => [:website_generate, :website_upload, :publish_docs]
|
data/website/index.html
DELETED
@@ -1,684 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
-
<title>
|
8
|
-
Googlecharts
|
9
|
-
</title>
|
10
|
-
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
-
<style>
|
12
|
-
|
13
|
-
</style>
|
14
|
-
<script type="text/javascript">
|
15
|
-
window.onload = function() {
|
16
|
-
settings = {
|
17
|
-
tl: { radius: 10 },
|
18
|
-
tr: { radius: 10 },
|
19
|
-
bl: { radius: 10 },
|
20
|
-
br: { radius: 10 },
|
21
|
-
antiAlias: true,
|
22
|
-
autoPad: true,
|
23
|
-
validTags: ["div"]
|
24
|
-
}
|
25
|
-
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
-
versionBox.applyCornersToAll();
|
27
|
-
}
|
28
|
-
</script>
|
29
|
-
</head>
|
30
|
-
<body>
|
31
|
-
<div id="main">
|
32
|
-
|
33
|
-
<h1>Googlecharts</h1>
|
34
|
-
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/googlecharts"; return false'>
|
35
|
-
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/googlecharts" class="numbers">1.3.1</a>
|
37
|
-
</div>
|
38
|
-
<h2>→ ‘Sexy Charts using Google <span class="caps">API</span> & Ruby’</h2>
|
39
|
-
|
40
|
-
|
41
|
-
<h2>What</h2>
|
42
|
-
|
43
|
-
|
44
|
-
<pre><code>A nice and simple wrapper for <a href="http://code.google.com/apis/chart/">Google Chart API</a></code></pre>
|
45
|
-
|
46
|
-
|
47
|
-
<h2>Installing</h2>
|
48
|
-
|
49
|
-
|
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>
|
59
|
-
|
60
|
-
|
61
|
-
<h2>The basics</h2>
|
62
|
-
|
63
|
-
|
64
|
-
<p>This gem supports the following types of charts:</p>
|
65
|
-
|
66
|
-
|
67
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld&chxt=x,y&chxl=0:|Mar|Apr|May|June|July|1:||50+Kb" title="Line" alt="Line" /> Gchart.line()</p>
|
68
|
-
|
69
|
-
|
70
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lxy&chs=200x125&chd=t:0,30,60,70,90,95,100|20,30,40,50,60,70,80|10,30,40,45,52|100,90,40,20,10|-1|5,33,50,55,7&chco=3072F3,ff0000,00aaaa&chls=2,4,1&chm=s,FF0000,0,-1,5|s,0000ff,1,-1,5|s,00aa00,2,-1,5" title="line_xy" alt="line_xy" /> Gchart.line_xy()</p>
|
71
|
-
|
72
|
-
|
73
|
-
<p><img src="http://chart.apis.google.com/chart?cht=s&chd=s:984sttvuvkQIBLKNCAIi,DEJPgq0uov17zwopQODS,AFLPTXaflptx159gsDrn&chxt=x,y&chxl=0:|0|2|3|4|5|6|7|8|9|10|1:|0|25|50|75|100&chs=200x125" title="scatter" alt="scatter" /> Gchart.scatter()</p>
|
74
|
-
|
75
|
-
|
76
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvg&chs=200x125&chd=s:hello,world&chco=cc0000,00aa00" title="bar" alt="bar" /> Gchart.bar()</p>
|
77
|
-
|
78
|
-
|
79
|
-
<p><img src="http://chart.apis.google.com/chart?cht=v&chs=200x100&chd=t:100,80,60,30,30,30,10" title="venn" alt="venn" /> Gchart.venn()</p>
|
80
|
-
|
81
|
-
|
82
|
-
<p><img src="http://chart.apis.google.com/chart?cht=p&chd=s:world5&chs=200x125&chl=A|B|C|D|E|Fe" title="pie" alt="pie" /> Gchart.pie()</p>
|
83
|
-
|
84
|
-
|
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>
|
86
|
-
|
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
|
-
|
94
|
-
<h2>Demonstration of usage</h2>
|
95
|
-
|
96
|
-
|
97
|
-
<p>install:</p>
|
98
|
-
|
99
|
-
|
100
|
-
<code>sudo gem install matta-googlecharts</code>
|
101
|
-
|
102
|
-
<p>or use rubyforge:</p>
|
103
|
-
|
104
|
-
|
105
|
-
<code>sudo gem install googlecharts</code>
|
106
|
-
|
107
|
-
<p>require:
|
108
|
-
<pre class='syntax'><span class="ident">require</span> <span class="punct">'</span><span class="string">gchart</span><span class="punct">'</span></pre></p>
|
109
|
-
|
110
|
-
|
111
|
-
<p><pre class='syntax'><span class="constant">Gchart</span><span class="punct">.</span><span class="ident">line</span><span class="punct">(</span> <span class="symbol">:size</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">200x300</span><span class="punct">',</span>
|
112
|
-
<span class="symbol">:title</span> <span class="punct">=></span> <span class="punct">"</span><span class="string">example title</span><span class="punct">",</span>
|
113
|
-
<span class="symbol">:bg</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">efefef</span><span class="punct">',</span>
|
114
|
-
<span class="symbol">:legend</span> <span class="punct">=></span> <span class="punct">['</span><span class="string">first data set label</span><span class="punct">',</span> <span class="punct">'</span><span class="string">second data set label</span><span class="punct">'],</span>
|
115
|
-
<span class="symbol">:data</span> <span class="punct">=></span> <span class="punct">[</span><span class="number">10</span><span class="punct">,</span> <span class="number">30</span><span class="punct">,</span> <span class="number">120</span><span class="punct">,</span> <span class="number">45</span><span class="punct">,</span> <span class="number">72</span><span class="punct">])</span></pre></p>
|
116
|
-
|
117
|
-
|
118
|
-
<hr />
|
119
|
-
|
120
|
-
|
121
|
-
<p><strong>simple line chart</strong>
|
122
|
-
<pre class='syntax'>
|
123
|
-
<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">=></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>
|
124
|
-
</pre></p>
|
125
|
-
|
126
|
-
|
127
|
-
<p>Generate the following url: http://chart.apis.google.com/chart?chs=300×200&chd=s:AiI9R&cht=lc</p>
|
128
|
-
|
129
|
-
|
130
|
-
<p>Inserted in an image tag, it will look like that:</p>
|
131
|
-
|
132
|
-
|
133
|
-
<p><img src="http://chart.apis.google.com/chart?chs=300x200&chd=s:AiI9R&cht=lc" title="simple line chart" alt="simple line chart" /></p>
|
134
|
-
|
135
|
-
|
136
|
-
<p><strong>multiple line charts</strong>
|
137
|
-
<pre class='syntax'>
|
138
|
-
<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">=></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>
|
139
|
-
</pre></p>
|
140
|
-
|
141
|
-
|
142
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:AeH1P,fH9m" title="multiple lines chart" alt="multiple lines chart" /></p>
|
143
|
-
|
144
|
-
|
145
|
-
<p><strong>set line colors</strong></p>
|
146
|
-
|
147
|
-
|
148
|
-
<p><pre class='syntax'>
|
149
|
-
<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">=></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">=></span> <span class="punct">"</span><span class="string">FF0000,00FF00</span><span class="punct">")</span>
|
150
|
-
</pre></p>
|
151
|
-
|
152
|
-
|
153
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:AeH1P,fH9m&chco=FF0000,00FF00" title="line colors" alt="line colors" /></p>
|
154
|
-
|
155
|
-
|
156
|
-
<p><a href="http://code.google.com/apis/chart/#chart_colors">more info about color settings</a></p>
|
157
|
-
|
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
|
-
|
174
|
-
<p><strong>bar chart</strong></p>
|
175
|
-
|
176
|
-
|
177
|
-
<p><pre class='syntax'>
|
178
|
-
<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">=></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>
|
179
|
-
</pre>
|
180
|
-
<img src="http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo" title="bars" alt="bars" /></p>
|
181
|
-
|
182
|
-
|
183
|
-
<p><strong>set the bar chart orientation</strong></p>
|
184
|
-
|
185
|
-
|
186
|
-
<p><pre class='syntax'>
|
187
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">horizontal</span><span class="punct">')</span>
|
188
|
-
</pre>
|
189
|
-
<img src="http://chart.apis.google.com/chart?cht=bhs&chs=300x200&chd=s:9UGo" title="bars" alt="bars" /></p>
|
190
|
-
|
191
|
-
|
192
|
-
<p><strong>multiple bars chart</strong></p>
|
193
|
-
|
194
|
-
|
195
|
-
<p><pre class='syntax'>
|
196
|
-
<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">=></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>
|
197
|
-
</pre></p>
|
198
|
-
|
199
|
-
|
200
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo,Uo9C" title="stacked multiple bars" alt="stacked multiple bars" /></p>
|
201
|
-
|
202
|
-
|
203
|
-
<p>The problem is that by default the bars are stacked, so we need to set the colors:</p>
|
204
|
-
|
205
|
-
|
206
|
-
<p><pre class='syntax'>
|
207
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">')</span>
|
208
|
-
</pre></p>
|
209
|
-
|
210
|
-
|
211
|
-
<p>If you prefer you can use this other syntax:</p>
|
212
|
-
|
213
|
-
|
214
|
-
<p><pre class='syntax'>
|
215
|
-
<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">=></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">=></span> <span class="punct">['</span><span class="string">FF0000</span><span class="punct">',</span> <span class="punct">'</span><span class="string">00FF00</span><span class="punct">'])</span>
|
216
|
-
</pre></p>
|
217
|
-
|
218
|
-
|
219
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00" title="colors" alt="colors" /></p>
|
220
|
-
|
221
|
-
|
222
|
-
<p>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:</p>
|
223
|
-
|
224
|
-
|
225
|
-
<p><pre class='syntax'>
|
226
|
-
<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">=></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>
|
227
|
-
<span class="symbol">:bar_colors</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">',</span>
|
228
|
-
<span class="symbol">:stacked</span> <span class="punct">=></span> <span class="constant">false</span> <span class="punct">)</span>
|
229
|
-
</pre></p>
|
230
|
-
|
231
|
-
|
232
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvg&chs=300x200&chd=s:9UGo,Uo9C&chco=FF0000,00FF00" title="grouped bars" alt="grouped bars" /></p>
|
233
|
-
|
234
|
-
|
235
|
-
<p><strong>bar chart width and spacing</strong></p>
|
236
|
-
|
237
|
-
|
238
|
-
<p>A bar chart can accept options to set the width of the bars, spacing between bars and spacing between bar groups. To set these, you can either provide a string, array or hash.</p>
|
239
|
-
|
240
|
-
|
241
|
-
<p>The Google <span class="caps">API</span> sets these options in the order of width, spacing, and group spacing, with both spacing values being optional. So, if you provide a string or array, provide them in that order:</p>
|
242
|
-
|
243
|
-
|
244
|
-
<p><pre class='syntax'>
|
245
|
-
<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">=></span> <span class="attribute">@data</span><span class="punct">,</span> <span class="symbol">:bar_width_and_spacing</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">25,6</span><span class="punct">')</span> <span class="comment"># width of 25, spacing of 6</span>
|
246
|
-
<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">=></span> <span class="attribute">@data</span><span class="punct">,</span> <span class="symbol">:bar_width_and_spacing</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">25,6,12</span><span class="punct">')</span> <span class="comment"># width of 25, spacing of 6, group spacing of 12</span>
|
247
|
-
<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">=></span> <span class="attribute">@data</span><span class="punct">,</span> <span class="symbol">:bar_width_and_spacing</span> <span class="punct">=></span> <span class="punct">[</span><span class="number">25</span><span class="punct">,</span><span class="number">6</span><span class="punct">])</span> <span class="comment"># width of 25, spacing of 6</span>
|
248
|
-
<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">=></span> <span class="attribute">@data</span><span class="punct">,</span> <span class="symbol">:bar_width_and_spacing</span> <span class="punct">=></span> <span class="number">25</span><span class="punct">)</span> <span class="comment"># width of 25</span>
|
249
|
-
</pre></p>
|
250
|
-
|
251
|
-
|
252
|
-
<p>The hash lets you set these values directly, with the Google default values set for any options you don’t include:</p>
|
253
|
-
|
254
|
-
|
255
|
-
<p><pre class='syntax'>
|
256
|
-
<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">=></span> <span class="attribute">@data</span><span class="punct">,</span> <span class="symbol">:bar_width_and_spacing</span> <span class="punct">=></span> <span class="punct">{</span><span class="symbol">:width</span> <span class="punct">=></span> <span class="number">19</span><span class="punct">})</span>
|
257
|
-
<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">=></span> <span class="attribute">@data</span><span class="punct">,</span> <span class="symbol">:bar_width_and_spacing</span> <span class="punct">=></span> <span class="punct">{</span><span class="symbol">:spacing</span> <span class="punct">=></span> <span class="number">10</span><span class="punct">,</span> <span class="symbol">:group_spacing</span> <span class="punct">=></span> <span class="number">12</span><span class="punct">})</span>
|
258
|
-
</pre></p>
|
259
|
-
|
260
|
-
|
261
|
-
<p><strong>pie chart</strong></p>
|
262
|
-
|
263
|
-
|
264
|
-
<p><pre class='syntax'>
|
265
|
-
<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">=></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>
|
266
|
-
</pre>
|
267
|
-
<img src="http://chart.apis.google.com/chart?cht=p&chs=300x200&chd=s:bv9" title="Pie Chart" alt="Pie Chart" /></p>
|
268
|
-
|
269
|
-
|
270
|
-
<p><strong>3D pie chart</strong></p>
|
271
|
-
|
272
|
-
|
273
|
-
<p><pre class='syntax'>
|
274
|
-
<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">=></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>
|
275
|
-
</pre>
|
276
|
-
<img src="http://chart.apis.google.com/chart?cht=p3&chs=300x200&chd=s:bv9" title="Pie Chart" alt="Pie Chart" /></p>
|
277
|
-
|
278
|
-
|
279
|
-
<p><strong>venn diagram</strong></p>
|
280
|
-
|
281
|
-
|
282
|
-
<p><a href="http://code.google.com/apis/chart/#venn">Google documentation</a></p>
|
283
|
-
|
284
|
-
|
285
|
-
Data set:
|
286
|
-
<ul>
|
287
|
-
<li>the first three values specify the relative sizes of three circles, A, B, and C</li>
|
288
|
-
<li>the fourth value specifies the area of A intersecting B</li>
|
289
|
-
<li>the fifth value specifies the area of B intersecting C</li>
|
290
|
-
<li>the sixth value specifies the area of C intersecting A</li>
|
291
|
-
<li>the seventh value specifies the area of A intersecting B intersecting C</li>
|
292
|
-
</ul>
|
293
|
-
|
294
|
-
|
295
|
-
<p><pre class='syntax'>
|
296
|
-
<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">=></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>
|
297
|
-
</pre>
|
298
|
-
<img src="http://chart.apis.google.com/chart?cht=v&chs=300x200&chd=s:9wkSSSG" title="Venn" alt="Venn" /></p>
|
299
|
-
|
300
|
-
|
301
|
-
<p><strong>scatter plot</strong></p>
|
302
|
-
|
303
|
-
|
304
|
-
<p><a href="http://code.google.com/apis/chart/#scatter_plot">Google Documentation</a></p>
|
305
|
-
|
306
|
-
|
307
|
-
<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>
|
308
|
-
|
309
|
-
|
310
|
-
<p><pre class='syntax'>
|
311
|
-
<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">=></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>
|
312
|
-
</pre></p>
|
313
|
-
|
314
|
-
|
315
|
-
<p><img src="http://chart.apis.google.com/chart?cht=s&chs=300x200&chd=s:MYkw9,MYkw9,9wkYM" title="scatter" alt="scatter" /></p>
|
316
|
-
|
317
|
-
|
318
|
-
<p><strong>google-o-meter</strong></p>
|
319
|
-
|
320
|
-
|
321
|
-
<p><a href="http://code.google.com/apis/chart/#gom">Google Documentation</a></p>
|
322
|
-
|
323
|
-
|
324
|
-
<p>Supply a single label that will be what the arrow points to. It only supports a solid fill for the background.</p>
|
325
|
-
|
326
|
-
|
327
|
-
<p><pre class='syntax'>
|
328
|
-
<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>
|
329
|
-
</pre></p>
|
330
|
-
|
331
|
-
|
332
|
-
<hr />
|
333
|
-
|
334
|
-
|
335
|
-
<p><strong>set a chart title</strong></p>
|
336
|
-
|
337
|
-
|
338
|
-
<p><pre class='syntax'>
|
339
|
-
<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">=></span> <span class="punct">"</span><span class="string">Recent Chart Sexyness</span><span class="punct">",</span> <span class="symbol">:data</span> <span class="punct">=></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>
|
340
|
-
</pre></p>
|
341
|
-
|
342
|
-
|
343
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness" title="chart title" alt="chart title" /></p>
|
344
|
-
|
345
|
-
|
346
|
-
<p><strong>set the title size</strong></p>
|
347
|
-
|
348
|
-
|
349
|
-
<p><pre class='syntax'>
|
350
|
-
<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">=></span> <span class="punct">"</span><span class="string">Recent Chart Sexyness</span><span class="punct">",</span> <span class="symbol">:title_size</span> <span class="punct">=></span> <span class="number">20</span><span class="punct">,</span> <span class="symbol">:data</span> <span class="punct">=></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>
|
351
|
-
</pre></p>
|
352
|
-
|
353
|
-
|
354
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness&chts=454545,20" title="title size" alt="title size" /></p>
|
355
|
-
|
356
|
-
|
357
|
-
<p><strong>set the title color</strong></p>
|
358
|
-
|
359
|
-
|
360
|
-
<p><pre class='syntax'>
|
361
|
-
<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">=></span> <span class="punct">"</span><span class="string">Recent Chart Sexyness</span><span class="punct">",</span> <span class="symbol">:title_color</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">FF0000</span><span class="punct">',</span> <span class="symbol">:data</span> <span class="punct">=></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>
|
362
|
-
</pre></p>
|
363
|
-
|
364
|
-
|
365
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvs&chs=300x200&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness&chts=FF0000" title="Title color" alt="Title color" /></p>
|
366
|
-
|
367
|
-
|
368
|
-
<p><strong>set the chart’s size</strong></p>
|
369
|
-
|
370
|
-
|
371
|
-
<p><pre class='syntax'>
|
372
|
-
<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">=></span> <span class="punct">"</span><span class="string">Recent Chart Sexyness</span><span class="punct">",</span>
|
373
|
-
<span class="symbol">:data</span> <span class="punct">=></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>
|
374
|
-
<span class="symbol">:size</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">600x400</span><span class="punct">')</span>
|
375
|
-
</pre></p>
|
376
|
-
|
377
|
-
|
378
|
-
<p><img src="http://chart.apis.google.com/chart?cht=bvs&chs=600x400&chd=s:JSGM9MY9&chtt=Recent+Chart+Sexyness" title="size" alt="size" /></p>
|
379
|
-
|
380
|
-
|
381
|
-
<p><strong>set the image background color</strong></p>
|
382
|
-
|
383
|
-
|
384
|
-
<p><pre class='syntax'>
|
385
|
-
<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">=></span> <span class="punct">"</span><span class="string">Matt's Mojo</span><span class="punct">",</span>
|
386
|
-
<span class="symbol">:data</span> <span class="punct">=></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>
|
387
|
-
<span class="symbol">:background</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">FF9994</span><span class="punct">')</span>
|
388
|
-
</pre></p>
|
389
|
-
|
390
|
-
|
391
|
-
<p><img src="http://chart.apis.google.com/chart?chf=bg,s,FF9994&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo" title="Background" alt="Background" /></p>
|
392
|
-
|
393
|
-
|
394
|
-
<p><strong>set the chart background color</strong></p>
|
395
|
-
|
396
|
-
|
397
|
-
<p><pre class='syntax'>
|
398
|
-
<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">=></span> <span class="punct">"</span><span class="string">Matt's Mojo</span><span class="punct">",</span>
|
399
|
-
<span class="symbol">:data</span> <span class="punct">=></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>
|
400
|
-
<span class="symbol">:background</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">FF9994</span><span class="punct">',</span> <span class="symbol">:chart_background</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">000000</span><span class="punct">')</span>
|
401
|
-
</pre></p>
|
402
|
-
|
403
|
-
|
404
|
-
<p><img src="http://chart.apis.google.com/chart?chf=c,s,000000|bg,s,FF9994&cht=bvs&chs=300x200&chd=s:JSGM9MY929w&chtt=Matt's+Mojo" title="chart background" alt="chart background" /></p>
|
405
|
-
|
406
|
-
|
407
|
-
<p><strong>Set bar/line colors</strong></p>
|
408
|
-
|
409
|
-
|
410
|
-
<p><pre class='syntax'>
|
411
|
-
<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">=></span> <span class="punct">"</span><span class="string">Matt's Mojo</span><span class="punct">",</span>
|
412
|
-
<span class="symbol">:data</span> <span class="punct">=></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>
|
413
|
-
<span class="symbol">:bar_colors</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">76A4FB</span><span class="punct">',</span>
|
414
|
-
<span class="symbol">:background</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">EEEEEE</span><span class="punct">',</span> <span class="symbol">:chart_background</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">CCCCCC</span><span class="punct">')</span>
|
415
|
-
</pre></p>
|
416
|
-
|
417
|
-
|
418
|
-
<p><img src="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" title="bar colors" alt="bar colors" /></p>
|
419
|
-
|
420
|
-
|
421
|
-
<p><pre class='syntax'>
|
422
|
-
<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">=></span> <span class="punct">"</span><span class="string">Matt's Mojo</span><span class="punct">",</span>
|
423
|
-
<span class="symbol">:data</span> <span class="punct">=></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>
|
424
|
-
<span class="symbol">:line_colors</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">76A4FB</span><span class="punct">')</span>
|
425
|
-
</pre></p>
|
426
|
-
|
427
|
-
|
428
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:JSGM9MY929w&chco=76A4FB&chtt=Matt's+Mojo" title="line colors" alt="line colors" /></p>
|
429
|
-
|
430
|
-
|
431
|
-
<p><strong>legend / labels</strong></p>
|
432
|
-
|
433
|
-
|
434
|
-
<p><pre class='syntax'>
|
435
|
-
<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">=></span> <span class="punct">"</span><span class="string">Matt vs Rob</span><span class="punct">",</span>
|
436
|
-
<span class="symbol">:data</span> <span class="punct">=></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>
|
437
|
-
<span class="symbol">:bar_colors</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">FF0000,00FF00</span><span class="punct">',</span>
|
438
|
-
<span class="symbol">:stacked</span> <span class="punct">=></span> <span class="constant">false</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
|
439
|
-
<span class="symbol">:legend</span> <span class="punct">=></span> <span class="punct">["</span><span class="string">Matt's Mojo</span><span class="punct">",</span> <span class="punct">"</span><span class="string">Rob's Mojo</span><span class="punct">"]</span> <span class="punct">)</span>
|
440
|
-
</pre>
|
441
|
-
<img src="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" title="legend" alt="legend" /></p>
|
442
|
-
|
443
|
-
|
444
|
-
<p><pre class='syntax'>
|
445
|
-
<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">=></span> <span class="punct">"</span><span class="string">Matt vs Rob</span><span class="punct">",</span>
|
446
|
-
<span class="symbol">:data</span> <span class="punct">=></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>
|
447
|
-
<span class="symbol">:bar_colors</span> <span class="punct">=></span> <span class="punct">['</span><span class="string">FF0000</span><span class="punct">','</span><span class="string">00FF00</span><span class="punct">'],</span>
|
448
|
-
<span class="symbol">:stacked</span> <span class="punct">=></span> <span class="constant">false</span><span class="punct">,</span> <span class="symbol">:size</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
|
449
|
-
<span class="symbol">:legend</span> <span class="punct">=></span> <span class="punct">["</span><span class="string">Matt's Mojo</span><span class="punct">",</span> <span class="punct">"</span><span class="string">Rob's Mojo</span><span class="punct">"]</span> <span class="punct">)</span>
|
450
|
-
</pre>
|
451
|
-
<img src="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" title="line legend" alt="line legend" /></p>
|
452
|
-
|
453
|
-
|
454
|
-
<p><pre class='syntax'>
|
455
|
-
<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">=></span> <span class="punct">'</span><span class="string">ruby_fu</span><span class="punct">',</span> <span class="symbol">:size</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">400x200</span><span class="punct">',</span>
|
456
|
-
<span class="symbol">:data</span> <span class="punct">=></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">=></span> <span class="punct">["</span><span class="string">DHH</span><span class="punct">",</span> <span class="punct">"</span><span class="string">Rob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">Matt</span><span class="punct">"]</span> <span class="punct">)</span>
|
457
|
-
</pre></p>
|
458
|
-
|
459
|
-
|
460
|
-
<p><img src="http://chart.apis.google.com/chart?cht=p3&chl=DHH|Rob|Matt&chs=400x200&chd=s:N99&chtt=ruby_fu" title="labels" alt="labels" /></p>
|
461
|
-
|
462
|
-
|
463
|
-
<p><strong>Display axis labels</strong></p>
|
464
|
-
|
465
|
-
|
466
|
-
<p><pre class='syntax'>
|
467
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">x,y,r</span><span class="punct">')</span>
|
468
|
-
</pre></p>
|
469
|
-
|
470
|
-
|
471
|
-
<p>or you can use the other syntax:</p>
|
472
|
-
|
473
|
-
|
474
|
-
<p><pre class='syntax'>
|
475
|
-
<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">=></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">=></span> <span class="punct">['</span><span class="string">x</span><span class="punct">','</span><span class="string">y</span><span class="punct">','</span><span class="string">r</span><span class="punct">'])</span>
|
476
|
-
</pre></p>
|
477
|
-
|
478
|
-
|
479
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chxt=x,y,r&chd=s:9UGoUo9C" title="axis with labels" alt="axis with labels" /></p>
|
480
|
-
|
481
|
-
|
482
|
-
<p><pre class='syntax'>
|
483
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">x</span><span class="punct">',</span>
|
484
|
-
<span class="symbol">:axis_labels</span> <span class="punct">=></span> <span class="punct">['</span><span class="string">Jan|July|Jan|July|Jan</span><span class="punct">'])</span>
|
485
|
-
</pre></p>
|
486
|
-
|
487
|
-
|
488
|
-
<p>or you can use the other syntax:</p>
|
489
|
-
|
490
|
-
|
491
|
-
<p><pre class='syntax'>
|
492
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">x</span><span class="punct">',</span>
|
493
|
-
<span class="symbol">:axis_labels</span> <span class="punct">=></span> <span class="punct">['</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">'])</span>
|
494
|
-
</pre></p>
|
495
|
-
|
496
|
-
|
497
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chxl=0:|Jan|July|Jan|July|Jan&chs=300x200&chxt=x&chd=s:9UGoUo9C" title="x labels" alt="x labels" /></p>
|
498
|
-
|
499
|
-
|
500
|
-
<p><strong>multiple axis labels</strong></p>
|
501
|
-
|
502
|
-
|
503
|
-
<p><pre class='syntax'>
|
504
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">x,r</span><span class="punct">',</span>
|
505
|
-
<span class="symbol">:axis_labels</span> <span class="punct">=></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>
|
506
|
-
</pre></p>
|
507
|
-
|
508
|
-
|
509
|
-
<p>or</p>
|
510
|
-
|
511
|
-
|
512
|
-
<p><pre class='syntax'>
|
513
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">x,r</span><span class="punct">',</span>
|
514
|
-
<span class="symbol">:axis_labels</span> <span class="punct">=></span> <span class="punct">[['</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">','</span><span class="string">July</span><span class="punct">','</span><span class="string">Jan</span><span class="punct">'],</span> <span class="punct">['</span><span class="string">2005</span><span class="punct">','</span><span class="string">2006</span><span class="punct">','</span><span class="string">2007</span><span class="punct">']])</span>
|
515
|
-
</pre></p>
|
516
|
-
|
517
|
-
|
518
|
-
<p><img src="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" title="multiple axis labels" alt="multiple axis labels" /></p>
|
519
|
-
|
520
|
-
|
521
|
-
<p>(This syntax will probably be improved in the future)</p>
|
522
|
-
|
523
|
-
|
524
|
-
<p><strong>custom params</strong></p>
|
525
|
-
|
526
|
-
|
527
|
-
<p>I certainly didn’t cover the entire <span class="caps">API</span>, if you want to add your own params:</p>
|
528
|
-
|
529
|
-
|
530
|
-
<p><pre class='syntax'>
|
531
|
-
<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">=></span> <span class="punct">'</span><span class="string">chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&chls=3,6,3|1,1,0</span><span class="punct">')</span>
|
532
|
-
</pre></p>
|
533
|
-
|
534
|
-
|
535
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:93zyvneTTOMJMLIJFHEAECFJGHDBFCFIERcgnpy45879,IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII&chls=3,6,3|1,1,0" title="Custom" alt="Custom" /></p>
|
536
|
-
|
537
|
-
|
538
|
-
<hr />
|
539
|
-
|
540
|
-
|
541
|
-
<p><strong>Save the chart as a file</strong></p>
|
542
|
-
|
543
|
-
|
544
|
-
<p>You might prefer to save the chart instead of using the url, not a problem:</p>
|
545
|
-
|
546
|
-
|
547
|
-
<p><pre class='syntax'>
|
548
|
-
<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">=></span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">26</span><span class="punct">],</span> <span class="symbol">:format</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">file</span><span class="punct">')</span>
|
549
|
-
</pre></p>
|
550
|
-
|
551
|
-
|
552
|
-
<p>You might want to specify the path and/or the filename used to save your chart:</p>
|
553
|
-
|
554
|
-
|
555
|
-
<p><pre class='syntax'>
|
556
|
-
<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">=></span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">26</span><span class="punct">],</span> <span class="symbol">:format</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">file</span><span class="punct">',</span> <span class="symbol">:filename</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">custom_filename.png</span><span class="punct">')</span>
|
557
|
-
</pre></p>
|
558
|
-
|
559
|
-
|
560
|
-
<p><strong>Insert as an image tag</strong></p>
|
561
|
-
|
562
|
-
|
563
|
-
<p>Because, I’m lazy, I also added a custom format:</p>
|
564
|
-
|
565
|
-
|
566
|
-
<p><pre class='syntax'>
|
567
|
-
<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">=></span> <span class="punct">[</span><span class="number">0</span><span class="punct">,</span> <span class="number">26</span><span class="punct">],</span> <span class="symbol">:format</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">img_tag</span><span class="punct">')</span>
|
568
|
-
</pre></p>
|
569
|
-
|
570
|
-
|
571
|
-
<p><img src=’http://chart.apis.google.com/chart?chs=300×200&chd=s:A9&cht=lc’/></p>
|
572
|
-
|
573
|
-
|
574
|
-
<hr />
|
575
|
-
|
576
|
-
|
577
|
-
<p><strong>Encoding</strong></p>
|
578
|
-
|
579
|
-
|
580
|
-
<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>
|
581
|
-
|
582
|
-
|
583
|
-
<ul>
|
584
|
-
<li>simple</li>
|
585
|
-
<li>text</li>
|
586
|
-
<li>extended</li>
|
587
|
-
</ul>
|
588
|
-
|
589
|
-
|
590
|
-
<p>By default this library uses the simple encoding, if you need a different type of encoding, you can change it really easily:</p>
|
591
|
-
|
592
|
-
|
593
|
-
<p>default / simple: chd=s:9UGoUo9C
|
594
|
-
<pre class='syntax'>
|
595
|
-
<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">=></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>
|
596
|
-
</pre></p>
|
597
|
-
|
598
|
-
|
599
|
-
<p>extended: chd=e:..VVGZqqVVqq..CI
|
600
|
-
<pre class='syntax'>
|
601
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">extended</span><span class="punct">'</span> <span class="punct">)</span>
|
602
|
-
</pre></p>
|
603
|
-
|
604
|
-
|
605
|
-
<p>text: chd=t:300,100,30,200,100,200,300,10
|
606
|
-
<pre class='syntax'>
|
607
|
-
<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">=></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">=></span> <span class="punct">'</span><span class="string">text</span><span class="punct">'</span> <span class="punct">)</span>
|
608
|
-
</pre></p>
|
609
|
-
|
610
|
-
|
611
|
-
<p>(note that the text encoding doesn’t use a max value and therefore should be under 100)</p>
|
612
|
-
|
613
|
-
|
614
|
-
<p><strong>Max value</strong></p>
|
615
|
-
|
616
|
-
|
617
|
-
<p>Simple and extended encoding support the max value option.</p>
|
618
|
-
|
619
|
-
|
620
|
-
<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>
|
621
|
-
|
622
|
-
|
623
|
-
<p><pre class='syntax'>
|
624
|
-
<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">=></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>
|
625
|
-
</pre></p>
|
626
|
-
|
627
|
-
|
628
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:9UGoUo9C" title="Title" alt="Title" /></p>
|
629
|
-
|
630
|
-
|
631
|
-
<p><pre class='syntax'>
|
632
|
-
<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">=></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">=></span> <span class="number">500</span> <span class="punct">)</span>
|
633
|
-
</pre></p>
|
634
|
-
|
635
|
-
|
636
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:kMDYMYkB" title="max 500" alt="max 500" /></p>
|
637
|
-
|
638
|
-
|
639
|
-
<p><pre class='syntax'>
|
640
|
-
<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">=></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">=></span> <span class="constant">false</span> <span class="punct">)</span>
|
641
|
-
</pre></p>
|
642
|
-
|
643
|
-
|
644
|
-
<p><img src="http://chart.apis.google.com/chart?cht=lc&chs=300x200&chd=s:_UeUKOeK" title="real size" alt="real size" /></p>
|
645
|
-
|
646
|
-
|
647
|
-
<h2>Repository</h2>
|
648
|
-
|
649
|
-
|
650
|
-
<p>The trunk repository is <code>http://github.com/matta/googlecharts/</code> for anonymous access.</p>
|
651
|
-
|
652
|
-
|
653
|
-
<h2>License</h2>
|
654
|
-
|
655
|
-
|
656
|
-
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
|
657
|
-
|
658
|
-
|
659
|
-
<h2>Contact</h2>
|
660
|
-
|
661
|
-
|
662
|
-
<p>Comments are welcome. Send an email to <a href="mailto:mattaimonetti@gmail.com">Matt Aimonetti</a></p>
|
663
|
-
|
664
|
-
|
665
|
-
<h3>Contributors</h3>
|
666
|
-
|
667
|
-
|
668
|
-
<p><a href="http://github.com/dbgrandi">David Grandinetti</a>
|
669
|
-
<a href="http://github.com/takeo">Toby Sterrett</a></p>
|
670
|
-
<p class="coda">
|
671
|
-
<a href="mattaimonetti@gmail.com">Matt Aimonetti</a>, 8th May 2008<br>
|
672
|
-
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
673
|
-
</p>
|
674
|
-
</div>
|
675
|
-
|
676
|
-
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
677
|
-
</script>
|
678
|
-
<script type="text/javascript">
|
679
|
-
_uacct = "UA-179809-11";
|
680
|
-
urchinTracker();
|
681
|
-
</script>
|
682
|
-
|
683
|
-
</body>
|
684
|
-
</html>
|