Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBoundingClientRect() returns different values in Chrome and FireFox #2614

Closed
tjohannto opened this issue May 6, 2019 · 0 comments · Fixed by #2672
Closed

getBoundingClientRect() returns different values in Chrome and FireFox #2614

tjohannto opened this issue May 6, 2019 · 0 comments · Fixed by #2672

Comments

@tjohannto
Copy link

tjohannto commented May 6, 2019

My problem is that in the piechart legend the event rects are sized differently in FireFox (66.0.2) and Chrome (73.0.3683.86).

The difference bases on line 10086 in c3.js:

ChartInternal.prototype.getTextRect = function (text, cls, element) {
    var dummy = this.d3.select('body').append('div').classed('c3', true),
        svg = dummy.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0),
        font = this.d3.select(element).style('font'),
        rect;
    svg.selectAll('.dummy').data([text]).enter().append('text').classed(cls ? cls : "", true).style('font', font).text(text).each(function () {
      rect = this.getBoundingClientRect();
    });
    dummy.remove();
    return rect;
  };

example: http://jsfiddle.net/q6gzr4th/
rect = this.getBoundingClientRect();
The getBoundingClientRect() function returns height = 13.328 for Chrome (which I would assume correct for my CSS settings, isn't it?) and height = 16 for Firefox.

Is there a way to fix that and ensure compatibility for both browsers?

Maybe use getBBox() instead of getBoundingClientRect()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant