diff -ur vendor/plugins/gruff/lib/gruff/base.rb vendor/plugins/gruff-modified/lib/gruff/base.rb
--- vendor/plugins/gruff/lib/gruff/base.rb	2007-03-12 15:49:42.000000000 +0100
+++ vendor/plugins/gruff-modified/lib/gruff/base.rb	2007-03-11 20:41:23.000000000 +0100
@@ -136,6 +136,7 @@
     # Will be scaled down if graph is smaller than 800px wide.
     attr_accessor :legend_box_size
 
+    attr_accessor :side_legend
 
     # If one numerical argument is given, the graph is drawn at 4/3 ratio according to the given width (800 results in 800x600, 400 gives 400x300, etc.).
     #
@@ -192,6 +193,8 @@
       
       @legend_box_size = 20.0
 
+      @side_legend = false
+
       @no_data_message = "No Data"
 
       @hide_line_markers = @hide_legend = @hide_title = @hide_line_numbers = false
@@ -411,8 +444,11 @@
         next if data_point.nil?
         
         # Setup max/min so spread starts at the low end of the data points
-        if @maximum_value.nil? && @minimum_value.nil?
-          @maximum_value = @minimum_value = data_point
+        if @maximum_value.nil? 
+          @maximum_value  = data_point
+        end
+        if @minimum_value.nil? 
+          @minimum_value.nil?
         end
 
         # TODO Doesn't work with stacked bar graphs
@@ -519,9 +555,18 @@
       @legend_caps_height = calculate_caps_height(@legend_font_size)
       
       if @hide_line_markers
-        (@graph_left, 
-         @graph_right_margin, 
-         @graph_bottom_margin) = [LEFT_MARGIN, RIGHT_MARGIN, BOTTOM_MARGIN]
+        #(@graph_left, 
+        # @graph_right_margin, 
+        # @graph_bottom_margin) = [LEFT_MARGIN, RIGHT_MARGIN, BOTTOM_MARGIN]
+        @graph_left = LEFT_MARGIN
+        @graph_bottom_margin = BOTTOM_MARGIN
+        if @side_legend
+          long_legend = @data.collect {|item| item[DATA_LABEL_INDEX] }.sort{|a,b| a.length <=> b.length}[-1]
+          extra_room_for_long_label = calculate_width(@legend_font_size, long_legend )
+          @graph_right_margin =   RIGHT_MARGIN + extra_room_for_long_label + 2.7 * @legend_box_size +  LEGEND_MARGIN * 2
+        else
+          @graph_right_margin = RIGHT_MARGIN
+        end
       else
         longest_left_label_width = 0
         if @has_left_labels
@@ -543,9 +588,14 @@
         # Make space for half the width of the rightmost column label.
         # Might be greater than the number of columns if between-style bar markers are used.
         last_label = @labels.keys.sort.last.to_i
-        extra_room_for_long_label = (last_label >= (@column_count-1) && @center_labels_over_point) ?
-          calculate_width(@marker_font_size, @labels[last_label])/2.0 :
-          0
+        if @side_legend
+          long_legend = @data.collect {|item| item[DATA_LABEL_INDEX] }.sort{|a,b| a.length <=> b.length}[-1]
+          extra_room_for_long_label = calculate_width(@legend_font_size, long_legend ) + 2.7 * @legend_box_size + LEGEND_MARGIN 
+        else
+          extra_room_for_long_label = (last_label >= (@column_count-1) && @center_labels_over_point) ?
+            calculate_width(@marker_font_size, @labels[last_label])/2.0 :
+            0
+        end
         @graph_right_margin =   RIGHT_MARGIN + extra_room_for_long_label
                                 
         @graph_bottom_margin =  BOTTOM_MARGIN + 
@@ -559,7 +609,7 @@
       # Same with @hide_legend
       @graph_top = TOP_MARGIN + 
                     (@hide_title ? TITLE_MARGIN : @title_caps_height + TITLE_MARGIN * 2) +
-                    (@hide_legend ? LEGEND_MARGIN : @legend_caps_height + LEGEND_MARGIN * 2)
+                    ((@hide_legend or @side_legend) ? LEGEND_MARGIN : @legend_caps_height + LEGEND_MARGIN )
 
       @graph_bottom = @raw_rows - @graph_bottom_margin -
                       (@x_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN)
@@ -703,12 +753,15 @@
       legend_left = (@raw_columns - legend_width) / 2
       legend_increment = legend_width / @legend_labels.length.to_f
 
-      current_x_offset = legend_left
-      current_y_offset =  @hide_title ? 
-                          TOP_MARGIN + LEGEND_MARGIN : 
-                          TOP_MARGIN + 
-                          TITLE_MARGIN + @title_caps_height +
-                          LEGEND_MARGIN
+      current_x_offset = (@side_legend ? @raw_columns -  @graph_right_margin + LEGEND_MARGIN : legend_left) 
+      #current_y_offset =  TOP_MARGIN + (@side_legend ? LEGEND_MARGIN : 0) + (@hide_title ?  LEGEND_MARGIN :  TITLE_MARGIN + @title_caps_height + LEGEND_MARGIN) 
+      if @side_legend
+        legend_height = @legend_labels.size *  calculate_caps_height(@legend_font_size) * 1.7
+        current_y_offset =  ((@raw_rows - (TOP_MARGIN + BOTTOM_MARGIN + (@hide_title ?  0 :  TITLE_MARGIN + @title_caps_height))) - legend_height)/2.0 + (TOP_MARGIN + (@hide_title ?  0 :  TITLE_MARGIN + @title_caps_height))
+        current_y_offset =  [TOP_MARGIN + LEGEND_MARGIN + (@hide_title ? 0 :  TITLE_MARGIN + @title_caps_height), current_y_offset].max 
+      else
+        current_y_offset =  TOP_MARGIN + LEGEND_MARGIN + (@hide_title ? 0 :  TITLE_MARGIN + @title_caps_height) 
+      end
 
       debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset }
                                                     
@@ -736,8 +789,12 @@
 
         @d.pointsize = @legend_font_size
         metrics = @d.get_type_metrics(@base_image, legend_label.to_s)
-        current_string_offset = metrics.width + (legend_square_width * 2.7)
-        current_x_offset += current_string_offset
+        if @side_legend
+          current_y_offset += calculate_caps_height(@legend_font_size) * 1.7
+        else
+          current_string_offset = metrics.width + (legend_square_width * 2.7)
+          current_x_offset += current_string_offset
+        end
       end
       @color_index = 0
     end
diff -ur vendor/plugins/gruff/lib/gruff/pie.rb vendor/plugins/gruff-modified/lib/gruff/pie.rb
--- vendor/plugins/gruff/lib/gruff/pie.rb	2007-03-12 15:49:47.000000000 +0100
+++ vendor/plugins/gruff-modified/lib/gruff/pie.rb	2007-03-11 20:41:23.000000000 +0100
@@ -3,7 +3,7 @@
 
 class Gruff::Pie < Gruff::Base
 
-  TEXT_OFFSET_PERCENTAGE = 0.15
+  TEXT_OFFSET_PERCENTAGE = 0.05
 
   # Can be used to make the pie start cutting slices at the top (-90.0)
   # or at another angle. Default is 0.0, which starts at 3 o'clock.
@@ -22,7 +22,7 @@
     return unless @has_data
 
     diameter = @graph_height
-    radius = ([@graph_width, @graph_height].min / 2.0) * 0.8
+    radius = ([@graph_width, @graph_height].min / 2.0) * 0.75
     top_x = @graph_left + (@graph_width - diameter) / 2.0
     center_x = @graph_left + (@graph_width / 2.0)
     center_y = @graph_top + (@graph_height / 2.0) - 10 # Move graph up a bit
@@ -30,7 +30,7 @@
     prev_degrees = @zero_degree
 
     # Use full data since we can easily calculate percentages
-    @data.sort{ |a, b| a[DATA_VALUES_INDEX][0] <=> b[DATA_VALUES_INDEX][0] }.each do |data_row|
+    (@sort ? @data.sort{ |a, b| a[DATA_VALUES_INDEX][0] <=> b[DATA_VALUES_INDEX][0] } : @data ).each do |data_row|
       if data_row[DATA_VALUES_INDEX][0] > 0
         @d = @d.stroke data_row[DATA_COLOR_INDEX]
         @d = @d.fill 'transparent'
@@ -49,7 +49,7 @@
 
         # End the string with %% to escape the single %.
         # RMagick must use sprintf with the string and % has special significance.
-        label_string = ((data_row[DATA_VALUES_INDEX][0] / total_sum) * 100.0).round.to_s + '%%'
+        label_string = ((data_row[DATA_VALUES_INDEX][0] / total_sum) * 100.0).round.to_s + '%'
         @d = draw_label(center_x,center_y, 
                     half_angle, radius + (radius * TEXT_OFFSET_PERCENTAGE), 
                     label_string)
