lib/gruffy/side_bar.rb in gruffy-1.2.2 vs lib/gruffy/side_bar.rb in gruffy-1.2.3
- old
+ new
@@ -45,13 +45,16 @@
# part of the bart chart we wish to stack.
temp1 = @graph_left + (@graph_width - data_point * @graph_width - height[point_index])
temp2 = @graph_left + @graph_width - height[point_index]
difference = temp2 - temp1
- left_x = length[point_index] - 1
+ reverse_difference = 0
+ reverse_difference = (@graph_width / (@marker_labels.min.abs + @marker_labels.max.abs)) * @marker_labels.min.abs if @marker_labels.min < 0
+
+ left_x = length[point_index] - 1 + reverse_difference
left_y = @graph_top + (@bars_width * point_index) + (@bar_width * row_index) + padding
- right_x = left_x + difference
+ right_x = left_x + difference - reverse_difference
right_y = left_y + @bar_width * @bar_spacing
height[point_index] += (data_point * @graph_width)
@d = @d.rectangle(left_x, left_y, right_x, right_y)
@@ -76,13 +79,13 @@
@d.draw(@base_image)
end
# Instead of base class version, draws vertical background lines and label
def draw_line_markers
-
return if @hide_line_markers
+ @marker_labels = []
@d = @d.stroke_antialias false
# Draw horizontal line markers and annotate with numbers
@d = @d.stroke(@marker_color)
@d = @d.stroke_width 1
@@ -96,9 +99,10 @@
line_diff = (@graph_right - @graph_left) / number_of_lines
x = @graph_right - (line_diff * index) - 1
@d = @d.line(x, @graph_bottom, x, @graph_top)
diff = index - number_of_lines
marker_label = diff.abs * increment + @minimum_value
+ @marker_labels << marker_label
unless @hide_line_numbers
@d.fill = @font_color
@d.font = @font if @font
@d.stroke = 'transparent'