Please help me to figure why ruby is throwing following error…
following is my code.
#!/usr/bin/ruby
require ‘procStartupTimes’
require ‘rubygems’
require ‘gruff’
g = Gruff::Line.new
g.title = “My Graph”
a = [1, 2, 3, 4, 4, 3,2, 3, 1, 5]
g.data(“Apples”, a)
puts a.size
inc = 2
x = Hash.new(a.size/inc)
x[0] = a.first.to_s
x[a.size/inc] = a.last.to_s
for i in 1…((a.size/inc)-1) do
x[inci] = a[inci].to_s
end
puts x.inspect
g.labels = x
g.write(‘my_fruity_graph.png’)
it throws below error…could someone pls tell me what causes this?
10
{5=>“5”, 0=>“1”, 6=>“2”, 2=>“3”, 8=>“1”, 4=>“4”}
/usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/base.rb:1115:in
annotate': can't convert Fixnum into String (TypeError) from /usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/base.rb:1115:in
annotate_scaled’
from ./gruff_fix.rb:12:in draw_label' from /usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/line.rb:80:in
draw’
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
each_with_index' from /usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/line.rb:76:in
each’
from
/usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/line.rb:76:in
each_with_index' from /usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/line.rb:76:in
draw’
from
/usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/line.rb:71:in each' from /usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/line.rb:71:in
draw’
from
/usr/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/base.rb:487:in `write’
from ./test3.rb:28