Bugs: Browse | Submit New | Admin

[#7217] Stacked Bar Graph can give inaccurate results.

Date:
2006-12-11 17:53
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Stacked Bar Graph can give inaccurate results.

Detailed description
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.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item