--- base.rb.old	2007-04-09 14:11:56.000000000 -0400
+++ base.rb	2007-04-10 11:52:22.000000000 -0400
@@ -62,6 +62,12 @@
     # A label for the left side of the graph
     attr_accessor :y_axis_label
 
+    # Make x labels vertical for long labels.
+    attr_accessor :x_vertical_labels
+
+    # If true, will round values on the Y axis to an appropriate number.
+    attr_accessor :round_y_values
+
     # attr_accessor :x_axis_increment
     
     # Manually set increment of the horizontal marking lines
@@ -514,8 +520,13 @@
                     (@hide_title ? TITLE_MARGIN : @title_caps_height + TITLE_MARGIN * 2) +
                     (@hide_legend ? LEGEND_MARGIN : @legend_caps_height + LEGEND_MARGIN * 2)
 
-      @graph_bottom = @raw_rows - @graph_bottom_margin -
-                      (@x_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN)
+      if @x_vertical_labels
+        @graph_bottom = @raw_rows - @graph_bottom_margin -
+                        (@x_axis_label.nil? ? @labels.max.size*@marker_caps_height : @labels.max.size*@marker_caps_height + LABEL_MARGIN)
+      else
+        @graph_bottom = @raw_rows - @graph_bottom_margin -
+                        (@x_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN)
+      end
       
       @graph_height = @graph_bottom - @graph_top
     end
@@ -543,13 +554,13 @@
 
       unless @y_axis_label.nil?
         # Y Axis, rotated vertically
-        @d.rotation = 90.0
+        @d.rotation = -90.0
         @d.gravity = CenterGravity
         @d = @d.annotate_scaled( @base_image, 
                           1.0, @raw_rows,
                           LEFT_MARGIN + @marker_caps_height / 2.0, 0.0, 
                           @y_axis_label, @scale)
-        @d.rotation = -90.0
+        @d.rotation = 90.0
       end
     end
 
@@ -602,11 +613,21 @@
           @d.pointsize = scale_fontsize(@marker_font_size)
           @d.gravity = EastGravity
         
+          y_label = label(marker_label).to_i
+          if @round_y_values
+            if y_label >= 1000000
+              y_label /= 100000
+              y_label = "#{y_label}m"
+            elsif y_label >= 1000
+              y_label /= 1000
+              y_label = "#{y_label}k"
+            end
+          end
           # Vertically center with 1.0 for the height
           @d = @d.annotate_scaled( @base_image, 
                             @graph_left - LABEL_MARGIN, 1.0,
                             0.0, y,
-                            label(marker_label), @scale)
+                            y_label.to_s, @scale)
         end
       end
       
@@ -727,10 +748,20 @@
         @d.font_weight = NormalWeight
         @d.pointsize = scale_fontsize(@marker_font_size)
         @d.gravity = NorthGravity
-        @d = @d.annotate_scaled(@base_image,
-                                1.0, 1.0,
-                                x_offset, y_offset,
-                                @labels[index], @scale)
+        if @x_vertical_labels
+          y_offset = @graph_bottom + LABEL_MARGIN + @labels.max.size*@marker_caps_height - 25 # FIXME: this calculation needs to be more accurate.
+          @d.rotation = -90.0 
+          @d = @d.annotate_scaled(@base_image,
+                                  1.0, 1.0,
+                                  x_offset, y_offset,
+                                  @labels[index], @scale)
+          @d.rotation = 90.0
+        else
+          @d = @d.annotate_scaled(@base_image,
+                                  1.0, 1.0,
+                                  x_offset, y_offset,
+                                  @labels[index], @scale)
+        end
         @labels_seen[index] = 1
         debug { @d.line 0.0, y_offset, @raw_columns, y_offset }
       end
