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

replace getBoundingClientRect by getBBox where appropriate #2672

Merged
merged 1 commit into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/axis-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ AxisInternal.prototype.updateTickTextCharSize = function (tick) {
w: 5.5
};
tick.select('text').text(function(d) { return internal.textFormatted(d); }).each(function (d) {
var box = this.getBoundingClientRect(),
var box = this.getBBox(),
text = internal.textFormatted(d),
h = box.height,
w = text ? (box.width / text.length) : undefined;
Expand Down Expand Up @@ -387,4 +387,4 @@ AxisInternal.prototype.generateAxis = function () {
return axis;
};

export {AxisInternal};
export {AxisInternal};
2 changes: 1 addition & 1 deletion src/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute)
svg = dummy.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').each(function () {
var box = this.getBoundingClientRect();
var box = this.getBBox();
if (maxWidth < box.width) {
maxWidth = box.width;
}
Expand Down
2 changes: 1 addition & 1 deletion src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ ChartInternal.prototype.getDataLabelLength = function (min, max, key) {
return $$.dataLabelFormat(d.id)(d);
})
.each(function (d, i) {
lengths[i] = this.getBoundingClientRect()[key] * paddingCoef;
lengths[i] = this.getBBox()[key] * paddingCoef;
})
.remove();
return lengths;
Expand Down
2 changes: 1 addition & 1 deletion src/shape.bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ChartInternal.prototype.isWithinBar = function (mouse, that) {
if (that.pathSegList.numberOfItems < 2) {
return false;
}
var box = that.getBoundingClientRect(),
var box = that.getBBox(),
seg0 = that.pathSegList.getItem(0), seg1 = that.pathSegList.getItem(1),
x = Math.min(seg0.x, seg1.x), y = Math.min(seg0.y, seg1.y),
w = box.width, h = box.height, offset = 2,
Expand Down
6 changes: 3 additions & 3 deletions src/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ChartInternal.prototype.getTextRect = function (text, cls, element) {
.classed(cls ? cls : "", true)
.style('font', font)
.text(text)
.each(function () { rect = this.getBoundingClientRect(); });
.each(function () { rect = this.getBBox(); });
dummy.remove();
return rect;
};
Expand All @@ -81,7 +81,7 @@ ChartInternal.prototype.generateXYForText = function (areaIndices, barIndices, l
};
ChartInternal.prototype.getXForText = function (points, d, textElement) {
var $$ = this,
box = textElement.getBoundingClientRect(), xPos, padding;
box = textElement.getBBox(), xPos, padding;
if ($$.config.axis_rotated) {
padding = $$.isBarType(d) ? 4 : 6;
xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1);
Expand All @@ -100,7 +100,7 @@ ChartInternal.prototype.getXForText = function (points, d, textElement) {
};
ChartInternal.prototype.getYForText = function (points, d, textElement) {
var $$ = this,
box = textElement.getBoundingClientRect(),
box = textElement.getBBox(),
yPos;
if ($$.config.axis_rotated) {
yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2;
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export var getOption = function(options, key, defaultValue) {
return isDefined(options[key]) ? options[key] : defaultValue;
};
export var getPathBox = function(path) {
var box = path.getBoundingClientRect(),
var box = path.getBBox(),
items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)],
minX = items[0].x,
minY = Math.min(items[0].y, items[1].y);
Expand Down