Browse Source

Use position = fixed instead of height = 1 when getBoundingClientRect - #1005 #1026

pull/1053/head
Masayuki Tanaka 10 years ago
parent
commit
a93fa4d38a
  1. 7
      c3.js
  2. 2
      c3.min.js
  3. 3
      src/axis.js
  4. 4
      src/text.js

7
c3.js

@ -3248,8 +3248,8 @@
};
c3_chart_internal_fn.getTextRect = function (text, cls) {
var body = this.d3.select('body').classed('c3', true),
// height = 1 is needed to get rect on Firefox - #1026
svg = body.append("svg").style('visibility', 'hidden').style('height', 1), rect;
svg = body.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0),
rect;
svg.selectAll('.dummy')
.data([text])
.enter().append('text')
@ -4370,8 +4370,7 @@
$$.updateXAxisTickValues(targetsToShow, axis);
}
body = this.d3.select('body').classed('c3', true);
// height = 1 is needed to get rect on Firefox - #1026
svg = body.append('svg').style('visibility', 'hidden').style('height', 1);
svg = body.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0),
svg.append('g').call(axis).each(function () {
$$.d3.select(this).selectAll('text tspan').each(function () {
var box = this.getBoundingClientRect();

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

3
src/axis.js

@ -290,8 +290,7 @@ c3_chart_internal_fn.getMaxTickWidth = function (id, withoutRecompute) {
$$.updateXAxisTickValues(targetsToShow, axis);
}
body = this.d3.select('body').classed('c3', true);
// height = 1 is needed to get rect on Firefox - #1026
svg = body.append('svg').style('visibility', 'hidden').style('height', 1);
svg = body.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0),
svg.append('g').call(axis).each(function () {
$$.d3.select(this).selectAll('text tspan').each(function () {
var box = this.getBoundingClientRect();

4
src/text.js

@ -49,8 +49,8 @@ c3_chart_internal_fn.redrawText = function (xForText, yForText, forFlow, withTra
};
c3_chart_internal_fn.getTextRect = function (text, cls) {
var body = this.d3.select('body').classed('c3', true),
// height = 1 is needed to get rect on Firefox - #1026
svg = body.append("svg").style('visibility', 'hidden').style('height', 1), rect;
svg = body.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0),
rect;
svg.selectAll('.dummy')
.data([text])
.enter().append('text')

Loading…
Cancel
Save