Browse Source

Fix legend when svg is hidden - #468

pull/590/head
Masayuki Tanaka 10 years ago
parent
commit
932b7fbacf
  1. 8
      c3.js
  2. 2
      c3.min.js
  3. 8
      src/text.js

8
c3.js

@ -3010,14 +3010,14 @@
.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 rect; var svg = this.d3.select('body').append("svg").style('visibility', 'hidden'), rect;
this.svg.selectAll('.dummy') svg.selectAll('.dummy')
.data([text]) .data([text])
.enter().append('text') .enter().append('text')
.classed(cls ? cls : "", true) .classed(cls ? cls : "", true)
.text(text) .text(text)
.each(function () { rect = this.getBoundingClientRect(); }) .each(function () { rect = this.getBoundingClientRect(); });
.remove(); svg.remove();
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

8
src/text.js

@ -48,14 +48,14 @@ 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 rect; var svg = this.d3.select('body').append("svg").style('visibility', 'hidden'), rect;
this.svg.selectAll('.dummy') svg.selectAll('.dummy')
.data([text]) .data([text])
.enter().append('text') .enter().append('text')
.classed(cls ? cls : "", true) .classed(cls ? cls : "", true)
.text(text) .text(text)
.each(function () { rect = this.getBoundingClientRect(); }) .each(function () { rect = this.getBoundingClientRect(); });
.remove(); svg.remove();
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