Browse Source

Fix unexpected rest of body class - #659

pull/675/head
Masayuki Tanaka 10 years ago
parent
commit
4fcad88e31
  1. 4
      c3.js
  2. 2
      c3.min.js
  3. 4
      src/text.js

4
c3.js

@ -3091,7 +3091,8 @@
.style("fill-opacity", opacityForText)); .style("fill-opacity", opacityForText));
}; };
c3_chart_internal_fn.getTextRect = function (text, cls) { c3_chart_internal_fn.getTextRect = function (text, cls) {
var svg = this.d3.select('body').attr('class', 'c3').append("svg").style('visibility', 'hidden'), rect; var body = this.d3.select('body').classed('c3', true),
svg = body.append("svg").style('visibility', 'hidden'), rect;
svg.selectAll('.dummy') svg.selectAll('.dummy')
.data([text]) .data([text])
.enter().append('text') .enter().append('text')
@ -3099,6 +3100,7 @@
.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) {

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

4
src/text.js

@ -48,7 +48,8 @@ c3_chart_internal_fn.addTransitionForText = function (transitions, xForText, yFo
.style("fill-opacity", opacityForText)); .style("fill-opacity", opacityForText));
}; };
c3_chart_internal_fn.getTextRect = function (text, cls) { c3_chart_internal_fn.getTextRect = function (text, cls) {
var svg = this.d3.select('body').attr('class', 'c3').append("svg").style('visibility', 'hidden'), rect; var body = this.d3.select('body').classed('c3', true),
svg = body.append("svg").style('visibility', 'hidden'), rect;
svg.selectAll('.dummy') svg.selectAll('.dummy')
.data([text]) .data([text])
.enter().append('text') .enter().append('text')
@ -56,6 +57,7 @@ c3_chart_internal_fn.getTextRect = function (text, cls) {
.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) {

Loading…
Cancel
Save