+
+ class GruffGraff
+
+ def initialize(options)
+ size = "700x400"
+ @graph = options[:graph_type].new(size)
+
+ @graph.theme = { :background_colors => ['#73BF26', '#ffffff'] }
+ @graph.font = File.expand_path('/usr/X11R6/lib/X11/fonts/TTF/Vera.ttf',
+ RAILS_ROOT)
+
+ # fill in the data with the optional data name
+ @graph.data( options.fetch(:data_name, nil), options[:data] )
+
+ # set the labels or create an empty hash
+ @graph.labels = options[:interval_labels] \
+ if options.has_key?(:labels) and options[:labels].class = Hash
+ @graph.x_axis_label = options[:x_axis_label] \
+ if options.has_key?(:x_axis_label)
+ @graph.y_axis_label = options[:y_axis_label] \
+ if options.has_key?(:y_axis_label)
+ @graph.title = options[:title] if options.has_key?(:title)
+
+ @graph.minimum_value = 0.0
+
+ end
+
+ def output
+ return([@graph.to_blob, {:disposition => 'inline', :type => 'image/png'}])
+ end
+
+ end
+