From 7dcb55eff531ac124bb30b61b544e9852bdd63c6 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 20 Feb 2015 11:08:59 +0000 Subject: [PATCH] Setting a class on the "body" (even for a brief moment), is causing chrome to change other non C3 elements positions. Signed-off-by: Gordon Smith --- c3.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/c3.js b/c3.js index fb446bb..0cb04d3 100644 --- a/c3.js +++ b/c3.js @@ -3244,8 +3244,8 @@ ]; }; c3_chart_internal_fn.getTextRect = function (text, cls) { - var body = this.d3.select('body').classed('c3', true), - svg = body.append("svg").style('visibility', 'hidden').style('height', 0), rect; + var body = this.d3.select('body'), + svg = body.append("svg").classed('c3', true).style('visibility', 'hidden').style('height', 0), rect; svg.selectAll('.dummy') .data([text]) .enter().append('text') @@ -3253,7 +3253,6 @@ .text(text) .each(function () { rect = this.getBoundingClientRect(); }); svg.remove(); - body.classed('c3', false); return rect; }; c3_chart_internal_fn.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) { @@ -4364,8 +4363,8 @@ axis = $$.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues); $$.updateXAxisTickValues(targetsToShow, axis); } - body = this.d3.select('body').classed('c3', true); - svg = body.append('svg').style('visibility', 'hidden').style('height', 0); + body = this.d3.select('body'); + svg = body.append('svg').classed('c3', true).style('visibility', 'hidden').style('height', 0); svg.append('g').call(axis).each(function () { $$.d3.select(this).selectAll('text tspan').each(function () { var box = this.getBoundingClientRect(); @@ -4376,7 +4375,6 @@ window.setTimeout(function () { svg.remove(); }, 100); - body.classed('c3', false); } $$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; return $$.currentMaxTickWidths[id];