Last active
January 3, 2016 04:29
-
-
Save nolanamy/8409051 to your computer and use it in GitHub Desktop.
Graph time-based data in irb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#example data | |
data = [ | |
{ | |
:time => Time.now - 2.days, | |
:value => 2321.65 | |
}, | |
{ | |
:time => Time.now - 1.days, | |
:value => 1307.98 | |
}, | |
{ | |
:time => Time.now, | |
:value => 2576 | |
} | |
] | |
#graph it. the maximum gets 100 dots | |
max = data.max_by{|a| a[:value]}[:value] | |
data.each do |a| | |
puts (a[:time].to_formatted_s(:short) + ' ' + '%9.1f' % a[:value] + ' ' + '.'*(a[:value].to_f/max*100)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Grabbing data to graph: