Browse Source

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 <gordon.smith@lexisnexis.com>
pull/1014/head
Gordon Smith 10 years ago
parent
commit
7dcb55eff5
  1. 10
      c3.js

10
c3.js

@ -3244,8 +3244,8 @@
]; ];
}; };
c3_chart_internal_fn.getTextRect = function (text, cls) { c3_chart_internal_fn.getTextRect = function (text, cls) {
var body = this.d3.select('body').classed('c3', true), var body = this.d3.select('body'),
svg = body.append("svg").style('visibility', 'hidden').style('height', 0), rect; svg = body.append("svg").classed('c3', true).style('visibility', 'hidden').style('height', 0), rect;
svg.selectAll('.dummy') svg.selectAll('.dummy')
.data([text]) .data([text])
.enter().append('text') .enter().append('text')
@ -3253,7 +3253,6 @@
.text(text) .text(text)
.each(function () { rect = this.getBoundingClientRect(); }); .each(function () { rect = this.getBoundingClientRect(); });
svg.remove(); svg.remove();
body.classed('c3', false);
return rect; return rect;
}; };
c3_chart_internal_fn.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) { c3_chart_internal_fn.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) {
@ -4364,8 +4363,8 @@
axis = $$.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues); axis = $$.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues);
$$.updateXAxisTickValues(targetsToShow, axis); $$.updateXAxisTickValues(targetsToShow, axis);
} }
body = this.d3.select('body').classed('c3', true); body = this.d3.select('body');
svg = body.append('svg').style('visibility', 'hidden').style('height', 0); svg = body.append('svg').classed('c3', true).style('visibility', 'hidden').style('height', 0);
svg.append('g').call(axis).each(function () { svg.append('g').call(axis).each(function () {
$$.d3.select(this).selectAll('text tspan').each(function () { $$.d3.select(this).selectAll('text tspan').each(function () {
var box = this.getBoundingClientRect(); var box = this.getBoundingClientRect();
@ -4376,7 +4375,6 @@
window.setTimeout(function () { window.setTimeout(function () {
svg.remove(); svg.remove();
}, 100); }, 100);
body.classed('c3', false);
} }
$$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; $$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth;
return $$.currentMaxTickWidths[id]; return $$.currentMaxTickWidths[id];

Loading…
Cancel
Save