Skip to content

Commit

Permalink
Merge pull request #4410 from veryinsanee/patch-1
Browse files Browse the repository at this point in the history
Fix issue 4216: grid padding calc to support array of stroke widths
  • Loading branch information
junedchhipa authored Apr 21, 2024
2 parents a7e0429 + 8a9670e commit 44d61f6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/modules/dimensions/Dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export default class Dimensions {

this.lgRect = this.dimHelpers.getLegendsRect()

const maxStrokeWidth = Array.isArray(w.config.stroke.width) ? Math.max(...w.config.stroke.width) : w.config.stroke.width

if (this.isSparkline) {
if (w.config.markers.discrete.length > 0 || w.config.markers.size > 0) {
Object.entries(this.gridPad).forEach(([k, v]) => {
Expand All @@ -51,11 +53,8 @@ export default class Dimensions {
})
}

this.gridPad.top = Math.max(w.config.stroke.width / 2, this.gridPad.top)
this.gridPad.bottom = Math.max(
w.config.stroke.width / 2,
this.gridPad.bottom
)
this.gridPad.top = Math.max(maxStrokeWidth / 2, this.gridPad.top)
this.gridPad.bottom = Math.max(maxStrokeWidth / 2, this.gridPad.bottom)
}

if (gl.axisCharts) {
Expand All @@ -70,7 +69,7 @@ export default class Dimensions {

// after calculating everything, apply padding set by user
gl.gridHeight = gl.gridHeight - this.gridPad.top - this.gridPad.bottom

gl.gridWidth =
gl.gridWidth -
this.gridPad.left -
Expand Down

0 comments on commit 44d61f6

Please sign in to comment.