A modest beginning... class BDBarGraph def initialize(height,width,xmin,xmax) @height = height * 1.0 @width = width * 1.0 @xmin = xmin * 1.0 @xmax = xmax * 1.0 @dataPoints = [] # the y values to plot @htmlString = "" @barString = "<img src=\"blublock.jpg\" width=\"replace_with_width\" height=\"replace_with_height\">\n" end attr_reader :xmin, :xmax, :dataPoints def points @dataPoints.length end def add_point(value) @dataPoints << value * 1.0 end def draw @dataPoints.each do |thisPoint| tempString = "" tempString << @barString tempString.gsub!(/replace_with_width/,(@width/points).to_i.to_s) barHeight = ((thisPoint - @xmin)/(@xmax - @xmin)) * @height tempString.gsub!(/replace_with_height/,barHeight.to_i.to_s) @htmlString << tempString end puts @htmlString end end bar = BDBarGraph.new(200,200,0,100) bar.add_point(50) bar.add_point(75) bar.add_point(100) bar.add_point(25) bar.draw [cpe-66-75-140-208:~] jeff% ruby BDBarGraph.rb <img src="blublock.jpg" width="50" height="100"> <img src="blublock.jpg" width="50" height="150"> <img src="blublock.jpg" width="50" height="200"> <img src="blublock.jpg" width="50" height="50"> [cpe-66-75-140-208:~] jeff% Still needs stuff to do x and y labels (probably using a table) Still needs error checking Maybe some refactoring to make it easier to use from erb Question, something like this that is intended to be used from erb, how is error checking usually handled? Just fail quietly? Seems like assertions might not be handled gracefully in erb. Any coding comments welcome. thanks, jp -- Posted via http://www.ruby-forum.com/.