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 568200c commit de18598
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/report/reporters/boxplot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,23 @@ const getBottomNewlines = function (mini) {

const LABELS_HEIGHT = 1

// Retrieve the blocks that show the min|max on the left|right
const getMinMaxBlock = function (quantiles, statName) {
return getStat(quantiles, statName)
}

// Retrieve the width of those blocks
const getMinMaxBlockWidth = function (combinations, statName) {
const combinationsA = combinations.filter(isMeasuredCombination)
return combinationsA.length === 0
? 0
: Math.max(
...combinationsA.map((combination) =>
getCombinationWidth(combination, statName),
),
)
return Math.max(
...combinations.map((combination) =>
getSingleMinMaxWidth(combination, statName),
),
)
}

const getCombinationWidth = function ({ quantiles }, statName) {
return stringWidth(getStat(quantiles, statName))
const getSingleMinMaxWidth = function ({ quantiles }, statName) {
return quantiles === undefined
? 0
: addPadding(quantiles[statName].prettyPadded).length
}

const getStat = function (quantiles, statName) {
// Retrieve the blocks that show the min|max on the left|right
const getMinMaxBlock = function (quantiles, statName) {
return addPadding(quantiles[statName].prettyPaddedColor)
}

Expand Down

0 comments on commit de18598

Please sign in to comment.