Skip to content

Commit 456e900

Browse files
committed
use offsetWidth instead of boundingClientRect for legend
1 parent ed863d7 commit 456e900

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/modules/Core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ export default class Core {
522522
!w.config.legend.floating
523523
) {
524524
legendHeight =
525-
new Legend(this.ctx).legendHelpers.getLegendBBox().clwh + 10
525+
new Legend(this.ctx).legendHelpers.getLegendDimensions().clwh + 10
526526
}
527527

528528
let el = w.globals.dom.baseEl.querySelector(

src/modules/legend/Helpers.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,12 @@ export default class Helpers {
7777
return stylesheet
7878
}
7979

80-
getLegendBBox() {
80+
getLegendDimensions() {
8181
const w = this.w
8282
let currLegendsWrap =
8383
w.globals.dom.baseEl.querySelector('.apexcharts-legend')
84-
let currLegendsWrapRect = currLegendsWrap.getBoundingClientRect()
85-
86-
let currLegendsWrapWidth = currLegendsWrapRect.width
87-
let currLegendsWrapHeight = currLegendsWrapRect.height
84+
let currLegendsWrapWidth = currLegendsWrap.offsetWidth
85+
let currLegendsWrapHeight = currLegendsWrap.offsetHeight
8886

8987
return {
9088
clwh: currLegendsWrapHeight,

src/modules/legend/Legend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class Legend {
374374

375375
elLegendWrap.style.right = 0
376376

377-
let lRect = this.legendHelpers.getLegendBBox()
377+
let lRect = this.legendHelpers.getLegendDimensions()
378378

379379
let dimensions = new Dimensions(this.ctx)
380380
let titleRect = dimensions.dimHelpers.getTitleSubtitleCoords('title')
@@ -401,7 +401,7 @@ class Legend {
401401
legendAlignVertical() {
402402
let w = this.w
403403

404-
let lRect = this.legendHelpers.getLegendBBox()
404+
let lRect = this.legendHelpers.getLegendDimensions()
405405

406406
let offsetY = 20
407407
let offsetX = 0

0 commit comments

Comments
 (0)