Commit 0994da13 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix update of legend when svg hidden - #241

parent a3c1b7dd
...@@ -2136,6 +2136,18 @@ ...@@ -2136,6 +2136,18 @@
return Math.ceil(v / 10) * 10; return Math.ceil(v / 10) * 10;
} }
function getTextRect(text, cls) {
var rect;
d3.select('body').selectAll('.dummy')
.data([text])
.enter().append('text')
.classed(cls ? cls : "", true)
.text(text)
.each(function () { rect = this.getBoundingClientRect(); })
.remove();
return rect;
}
//-- Selection --// //-- Selection --//
function selectPoint(target, d, i) { function selectPoint(target, d, i) {
...@@ -3973,7 +3985,7 @@ ...@@ -3973,7 +3985,7 @@
withTransitionForTransform = getOption(options, "withTransitionForTransform", true); withTransitionForTransform = getOption(options, "withTransitionForTransform", true);
function updatePositions(textElement, id, reset) { function updatePositions(textElement, id, reset) {
var box = textElement.getBoundingClientRect(), var box = getTextRect(textElement.textContent, CLASS.legendItem),
itemWidth = Math.ceil((box.width + paddingRight) / 10) * 10, itemWidth = Math.ceil((box.width + paddingRight) / 10) * 10,
itemHeight = Math.ceil((box.height + paddingTop) / 10) * 10, itemHeight = Math.ceil((box.height + paddingTop) / 10) * 10,
itemLength = isLegendRight ? itemHeight : itemWidth, itemLength = isLegendRight ? itemHeight : itemWidth,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment