Skip to content

Commit

Permalink
improve sparkline paddings on top and bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Oct 16, 2023
1 parent 0637103 commit 2ac1adb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/modules/axes/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Grid {
-strokeSize - barWidthLeft - 2,
-strokeSize * 2 - 2,
gl.gridWidth + strokeSize + barWidthRight + barWidthLeft + 4,
gl.gridHeight + strokeSize * 2 + 4,
gl.gridHeight + strokeSize * 4 + 4,
0,
'#fff'
)
Expand Down
28 changes: 18 additions & 10 deletions src/modules/dimensions/Dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ export default class Dimensions {

this.lgRect = this.dimHelpers.getLegendsRect()

if (
this.isSparkline &&
(w.config.markers.discrete.length > 0 || w.config.markers.size > 0)
) {
Object.entries(this.gridPad).forEach(([k, v]) => {
this.gridPad[k] = Math.max(v, this.w.globals.markers.largestSize / 1.5)
})
if (this.isSparkline) {
if (w.config.markers.discrete.length > 0 || w.config.markers.size > 0) {
Object.entries(this.gridPad).forEach(([k, v]) => {
this.gridPad[k] = Math.max(
v,
this.w.globals.markers.largestSize / 1.5
)
})
}

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
)
}

if (gl.axisCharts) {
Expand Down Expand Up @@ -95,11 +103,11 @@ export default class Dimensions {
// store the labels and titles coords in global vars
w.globals.yLabelsCoords.push({
width: yaxisLabelCoords[index].width,
index
index,
})
w.globals.yTitleCoords.push({
width: yTitleCoords[index].width,
index
index,
})
})

Expand Down Expand Up @@ -148,7 +156,7 @@ export default class Dimensions {
if (this.isSparkline) {
this.lgRect = {
height: 0,
width: 0
width: 0,
}
}

Expand Down

0 comments on commit 2ac1adb

Please sign in to comment.