Skip to content

Instantly share code, notes, and snippets.

@winston
Created July 4, 2011 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winston/1063446 to your computer and use it in GitHub Desktop.
Save winston/1063446 to your computer and use it in GitHub Desktop.
GoogleVisualr Gem - Candlestick Chart Creation Example
# http://code.google.com/apis/chart/interactive/docs/gallery/candlestickchart.html
def candlestick_chart
data_table = GoogleVisualr::DataTable.new
data_table.new_column('string', 'day')
data_table.new_column('number', 'min')
data_table.new_column('number', 'opening')
data_table.new_column('number', 'closing')
data_table.new_column('number', 'max')
data_table.add_rows( [
['Mon',20,28,38,45],
['Tue',31,38,55,66],
['Wed',50,55,77,80],
['Thu',50,77,66,77],
['Fri',15,66,22,68]
] )
opts = { :width => 400, :height => 240, :legend => 'none' }
@chart = GoogleVisualr::Interactive::CandlestickChart.new(data_table, opts)
end
<div id='chart'></div>
<%= render_chart @chart, 'chart' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment