Skip to content

Commit 8ef0c93

Browse files
committed
google charts api using gchartrb
1 parent 73e1780 commit 8ef0c93

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

google/demo.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'rubygems'
2+
require 'google_chart'
3+
require File.join(File.dirname(__FILE__),'..','stock_data.rb')
4+
5+
x = []; y = []
6+
data = StockData.for('RBS.L', 365)
7+
data.each {|d| x << d[0]; y << d[1]}
8+
y.reverse!
9+
10+
# Line Chart
11+
GoogleChart::LineChart.new('400x300', "RBS.L", false) do |lc|
12+
lc.data "RBS.L", y, '0000ff'
13+
lc.grid(:x_step => 100.0/12.0,
14+
:y_step => 100.0/6.0,
15+
:length_segment => 1,
16+
:length_blank => 0)
17+
lc.axis(:x,
18+
:range => [0,12],
19+
:labels => %w(d j f m a m j j a s o n d)
20+
)
21+
puts lc.to_url
22+
end

0 commit comments

Comments
 (0)