lib/SVG/Graph/Graph.rb in svg-graph-2.2.1 vs lib/SVG/Graph/Graph.rb in svg-graph-2.2.2
- old
+ new
@@ -906,11 +906,14 @@
y_offset += font_size/3.0
for label in get_y_labels
if show_y_labels
# x = 0, y = 0 is top left right next to graph area
y = y_offset - (label_height * count)
- x = -label_width/2.0 + y_label_font_size/2.0
+ # instead of calculating the middle anchor position, simply use
+ # static offset and anchor end to right-align the labels. See line :936 below.
+ #x = -label_width/2.0 + y_label_font_size/2.0
+ x = 3
if stagger_y_labels and count % 2 == 1
x -= stagger
@graph.add_element( "path", {
"d" => "M0 #{y} h#{-stagger}",
@@ -927,10 +930,11 @@
if( numeric?(label) )
textStr = @number_format % label
end
text.text = textStr
# note text-anchor is at bottom of textfield
- text.attributes["style"] = "text-anchor: middle"
+ #text.attributes["style"] = "text-anchor: middle"
+ text.attributes["style"] = "text-anchor: end"
degrees = rotate_y_labels
text.attributes["transform"] = "translate( -#{font_size} 0 ) " +
"rotate( #{degrees} #{x} #{y} ) "
# text.attributes["y"] = (y - (y_label_font_size/2)).to_s