diff --git a/lib/SVG/Graph/Graph.rb b/lib/SVG/Graph/Graph.rb index 6e5bb5d..c0d6eeb 100644 --- a/lib/SVG/Graph/Graph.rb +++ b/lib/SVG/Graph/Graph.rb @@ -530,10 +530,9 @@ def add_popup( x, y, label, style="" ) t = @foreground.add_element( "text", { "x" => tx.to_s, "y" => (y - font_size).to_s, - "class" => "dataPointLabel", - "visibility" => "hidden", + "class" => "dataPointPopup" }) - t.attributes["style"] = "stroke-width: 2; fill: #000; #{style}"+ + t.attributes["style"] = style + (x+txt_width > @graph_width ? "text-anchor: end;" : "text-anchor: start;") t.text = label.to_s t.attributes["id"] = t.object_id.to_s @@ -545,9 +544,9 @@ def add_popup( x, y, label, style="" ) "r" => "#{popup_radius}", "style" => "opacity: 0", "onmouseover" => - "document.getElementById(#{t.object_id}).setAttribute('visibility', 'visible' )", + "document.getElementById(#{t.object_id}).style.visibility ='visible'", "onmouseout" => - "document.getElementById(#{t.object_id}).setAttribute('visibility', 'hidden' )", + "document.getElementById(#{t.object_id}).style.visibility = 'hidden'", }) end # if add_popups end # add_popup @@ -712,12 +711,11 @@ def make_datapoint_text( x, y, value, style="" ) elsif x > @graph_width - textStr.length/2 * font_size style << "text-anchor: end;" end - # white background for better readability + # background for better readability @foreground.add_element( "text", { "x" => x.to_s, "y" => y.to_s, - "class" => "dataPointLabel", - "style" => "#{style} stroke: #fff; stroke-width: 2;" + "class" => "dataPointLabelBackground", }).text = textStr # actual label text = @foreground.add_element( "text", { @@ -1212,7 +1210,7 @@ def get_style font-weight: normal; } -.dataPointLabel{ +.dataPointLabel, .dataPointLabelBackground, .dataPointPopup{ fill: #000000; text-anchor:middle; font-size: 10px; @@ -1220,6 +1218,17 @@ def get_style font-weight: normal; } +.dataPointLabelBackground{ + stroke: #ffffff; + stroke-width: 2; +} + +.dataPointPopup{ + fill: #000000; + visibility: hidden; + stroke-width: 2; +} + .staggerGuideLine{ fill: none; stroke: #000000; diff --git a/lib/SVG/Graph/Pie.rb b/lib/SVG/Graph/Pie.rb index 3524519..5a1dc2b 100644 --- a/lib/SVG/Graph/Pie.rb +++ b/lib/SVG/Graph/Pie.rb @@ -343,7 +343,7 @@ def round val, to def get_css return <