Created
March 31, 2012 05:56
-
-
Save smokeymonkey/2259808 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby -Ku | |
require 'rubygems' | |
require 'gruff' | |
require 'csv' | |
day = Hash.new | |
weight = Array.new | |
fat = Array.new | |
i=0 | |
# CSV Format ... Date,Weight,Body Fat | |
# Example = "2001/01/01, 65.5, 15,5" | |
CSV.foreach('weight.csv') do |line| | |
if line[1] != nil and line[2] != nil then | |
if i % 30 == 0 then | |
day[i] = line[0] | |
else | |
day[i] = " " | |
end | |
weight << line[1].to_f | |
fat << line[2].to_f | |
i = i + 1 | |
end | |
end | |
wg = Gruff::Line.new(1024) | |
wg.title = "@smokeymonkey Weight" | |
wg.theme_odeo | |
wg.marker_font_size = 8 | |
wg.x_axis_label='Date' | |
wg.y_axis_label='Weight(kg)' | |
wg.data("Weight",weight) | |
wg.labels = day | |
fg = Gruff::Line.new(1024) | |
fg.title = "@smokeymonkey Body Fat" | |
fg.theme_odeo | |
fg.marker_font_size = 8 | |
fg.x_axis_label='Date' | |
fg.y_axis_label='Body Fat(%)' | |
fg.data("Fat", fat) | |
fg.labels = day | |
wg.write('weight.png') | |
fg.write('fat.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment