Skip to content

Instantly share code, notes, and snippets.

@manveru
Created March 24, 2011 01:43
Show Gist options
  • Save manveru/884409 to your computer and use it in GitHub Desktop.
Save manveru/884409 to your computer and use it in GitHub Desktop.
require 'json'
require 'time'
data = select_from_db.to_a
out = {
:item => data.map{|key, value| value.inspect },
:axisx => [
data.first.first,
data[data.size / 2].first,
data.last.first,
].map{|datetime| Time.parse(datetime.to_s).strftime('%a %H:%M') },
:axisy => [data.values.min, data.values.max],
:colour => 'ff9900',
}
puts out.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment