I was fiddling around with creating a "portfolio" grapher using gruff, and discovered that gruff will sometimes
(depending on values- is consistent from execution to execution) give inaccurate stacked bars:
for instance, I gave it a series of sums which add up to 4480.83, but the bar comes up just short of the "4400"
line. This is sort of hard to describe, so I'll just give you example source code and what I saw:
Example code:
---
#!/usr/bin/ruby
require 'rubygems'
require 'gruff'
g = Gruff::StackedBar.new
g.title = "My Graph"
#Sum of below values is 4480.83
g.data("Stock 1", [688.85])
g.data("Stock 2", [790.2])
g.data("Stock 3", [747.60])
g.data("Stock 4", [735])
g.data("Stock 5", [767.91])
g.data("Stock 6", [751.27])
g.labels = {0 => 'Today'}
g.write('testgraph.png')
---
and what I get can be seen at: http://www.callingshotgun.net/testgraph.png
Also note that if instead of 6 stacked values, I only use one that represents the sum, e.g
g.data("All", [4480.83])
it seems to work just fine. |