Skip to content

Commit

Permalink
use offsetWidth instead of boundingClientRect for legend
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Jul 19, 2024
1 parent ed863d7 commit 456e900
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/modules/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export default class Core {
!w.config.legend.floating
) {
legendHeight =
new Legend(this.ctx).legendHelpers.getLegendBBox().clwh + 10
new Legend(this.ctx).legendHelpers.getLegendDimensions().clwh + 10
}

let el = w.globals.dom.baseEl.querySelector(
Expand Down
8 changes: 3 additions & 5 deletions src/modules/legend/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ export default class Helpers {
return stylesheet
}

getLegendBBox() {
getLegendDimensions() {
const w = this.w
let currLegendsWrap =
w.globals.dom.baseEl.querySelector('.apexcharts-legend')
let currLegendsWrapRect = currLegendsWrap.getBoundingClientRect()

let currLegendsWrapWidth = currLegendsWrapRect.width
let currLegendsWrapHeight = currLegendsWrapRect.height
let currLegendsWrapWidth = currLegendsWrap.offsetWidth
let currLegendsWrapHeight = currLegendsWrap.offsetHeight

return {
clwh: currLegendsWrapHeight,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/legend/Legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class Legend {

elLegendWrap.style.right = 0

let lRect = this.legendHelpers.getLegendBBox()
let lRect = this.legendHelpers.getLegendDimensions()

let dimensions = new Dimensions(this.ctx)
let titleRect = dimensions.dimHelpers.getTitleSubtitleCoords('title')
Expand All @@ -401,7 +401,7 @@ class Legend {
legendAlignVertical() {
let w = this.w

let lRect = this.legendHelpers.getLegendBBox()
let lRect = this.legendHelpers.getLegendDimensions()

let offsetY = 20
let offsetX = 0
Expand Down

0 comments on commit 456e900

Please sign in to comment.