[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

SVG::Graph::Plot

Raymond Law

3/22/2007 3:07:00 PM

I encountered a problem when using SVG::Graph. I have the following
code that generate a simple plot:

require 'SVG/Graph/Plot'

# This does not work.
data= [0.107,9, 0.128,1, 0.163,2, 0.188,4, 0.192,6, 0.5,5.5]

# This works fine.
#data= [0.107,9, 0.128,1, 0.163,2, 0.188,4, 0.192,6, 1.5,5.5]

graph = SVG::Graph::Plot.new({
:height => 500,
:width => 800,
:key => true,
:scale_x_integers => true,
:scale_y_integerrs => true,
})

graph.add_data({
:data => data,
:title => 'Projected'
})

f = File.new("plot.svg", "w+")
f.write(graph.burn())
f.close

The error is:

123 rlaw ~/svg_graph/test > ruby plot.rb
/usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Plot.rb:206:in `-': nil
can't be coerced into Float (TypeError)
from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Plot.rb:206:in
`field_width'
from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:522:in
`draw_x_labels'
from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:488:in
`draw_graph'
from /usr/local/lib/ruby/site_ruby/1.8/SVG/Graph/Graph.rb:203:in
`burn'
from plot.rb:19
124 rlaw ~/svg_graph/test >

Basically, when x's are very small (i.e. smaller than 1?), I get the
above error. Is this a known bug, or am I just not using it right?

Thank you.

Ray,

--
Posted via http://www.ruby-....