This was a previous class assignment, and I decided I wanted to make the graph look slightly better so I decided to place a min/max value and set the increment for the graph up as well. Here is the function that creates the graph:
def update_graph
$g = Gruff::Line.new(600)
$g.title = "Name Popularity In Census Years"
#add data to graph
$list.each do
|name|
$g.data(name.upcase,$hash[name.upcase])
end
#***WHY DOESNT THIS WORK?!?!?!?***
$g.y_axis_increment= 100
$g.write('graph.gif') #create graph file
#update the output to show the graph
$output_label.configure(:image => TkPhotoImage.new(:file => "graph.gif"))
$entry_field.value = nil #clear entry field
`rm graph.gif` #remove the graph file
end
My problem is, when I use g.y_axis_increment= 100, the graph will not draw and gives the error "ArgumentError, wrong number of arguments (1 for 0)" and it points to this line:
$g.write('graph.gif') #create graph file
This would normally suggest that the write function shouldnt take an argument, however, when I comment the g.y_axis_increment= 100, the program runs flawlessly. Anyone have a clue why this line would break the write function?
g.write ----- g cant be used because .write isnt a method that pretains to the object of g....write is used to write the given string to [I]IO[I]
an example of write would be this :
number = STDOUT.write( "whatever text\n")
puts "Just wrote #{number} bytes to the screen"