Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 5, 2021
1 parent f3abae3 commit 95236df
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/report/reporters/boxplot/width.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getWidths = function ({
maxAll,
}) {
const titlesWidth = getCombinationPaddedName(combinations[0]).length
const contentWidth = Math.max(screenWidth - titlesWidth, 1)
const contentWidth = subtractToContentWidth(screenWidth, titlesWidth)
const minBlockWidth = getMinMaxBlockWidth({
statName: 'min',
combinations,
Expand All @@ -22,7 +22,7 @@ export const getWidths = function ({
maxAll,
contentWidth,
})
const contentWidthA = Math.max(contentWidth - minBlockWidth, 1)
const contentWidthA = subtractToContentWidth(contentWidth, minBlockWidth)
const maxBlockWidth = getMinMaxBlockWidth({
statName: 'max',
combinations,
Expand All @@ -31,10 +31,14 @@ export const getWidths = function ({
maxAll,
contentWidth: contentWidthA,
})
const contentWidthB = Math.max(contentWidthA - maxBlockWidth, 1)
const contentWidthB = subtractToContentWidth(contentWidthA, maxBlockWidth)
return { titlesWidth, minBlockWidth, contentWidth: contentWidthB }
}

const subtractToContentWidth = function (contentWidth, columnWidth) {
return Math.max(contentWidth - columnWidth, 1)
}

// Finds the smallest `minBlockWidth`/`maxBlockWidth` that fits all `min`/`max`
// labels. Computing it depends on the position on the screen of each
// combination's `min`/`max`. However, this in turns depends on `minBlockWidth`
Expand Down

0 comments on commit 95236df

Please sign in to comment.