lib/SVG/Graph/Graph.rb in svg-graph-1.0.1 vs lib/SVG/Graph/Graph.rb in svg-graph-1.0.3

- old
+ new

@@ -138,10 +138,11 @@ :font_size =>12, :title_font_size =>16, :subtitle_font_size =>14, :x_label_font_size =>12, + :y_label_font_size =>12, :x_title_font_size =>14, :y_label_font_size =>12, :y_title_font_size =>14, :key_font_size =>10, @@ -363,18 +364,18 @@ # Override this (and call super) to change the margin to the left # of the plot area. Results in @border_left being set. def calculate_left_margin @border_left = 7 # Check for Y labels - max_y_label_height_px = rotate_y_labels ? - y_label_font_size : + max_y_label_height_px = @rotate_y_labels ? + @y_label_font_size : get_y_labels.max{|a,b| a.to_s.length<=>b.to_s.length - }.to_s.length * y_label_font_size * 0.6 - @border_left += max_y_label_height_px if show_y_labels - @border_left += max_y_label_height_px + 10 if stagger_y_labels - @border_left += y_title_font_size + 5 if show_y_title + }.to_s.length * @y_label_font_size * 0.6 + @border_left += max_y_label_height_px if @show_y_labels + @border_left += max_y_label_height_px + 10 if @stagger_y_labels + @border_left += y_title_font_size + 5 if @show_y_title end # Calculates the width of the widest Y label. This will be the # character height if the Y labels are rotated @@ -531,11 +532,11 @@ text.attributes["class"] = "xAxisLabels" text.text = label.to_s x = count * label_width + x_label_offset( label_width ) y = @graph_height + x_label_font_size + 3 - t = 0 - (font_size / 2) + #t = 0 - (font_size / 2) if stagger_x_labels and count % 2 == 1 y += stagger @graph.add_element( "path", { "d" => "M#{x} #@graph_height v#{stagger}", @@ -698,11 +699,12 @@ end end end def keys - return @data.collect{ |d| d[:title] } + i = 0 + return @data.collect{ |d| i+=1; d[:title] || "Serie #{i}" } end # Draws the legend on the graph def draw_legend if key @@ -790,10 +792,10 @@ def parse_css css = get_style rv = {} while css =~ /^(\.(\w+)(?:\s*,\s*\.\w+)*)\s*\{/m - names_orig = names = $1 + names = $1 css = $' css =~ /([^}]+)\}/m content = $1 css = $'