-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { getCombinationPaddedName } from './name.js' | ||
|
||
// Compute the width of each column for reporters which show the following ones | ||
// for each combination: | ||
// - Title | ||
// - Min | ||
// - Main content | ||
// - Max | ||
// This is used for example by the `histogram` and `boxplot` reporters. | ||
// Using shared logic ensures those reporters are aligned when shown together. | ||
export const getColWidths = function ({ | ||
combinations, | ||
minWidths, | ||
maxWidths, | ||
mini, | ||
screenWidth, | ||
}) { | ||
const titlesWidth = getCombinationPaddedName(combinations[0]).length | ||
const minBlockWidth = getMinMaxBlockWidth(combinations, mini, minWidths) | ||
const maxBlockWidth = getMinMaxBlockWidth(combinations, mini, maxWidths) | ||
const contentWidth = Math.max( | ||
screenWidth - titlesWidth - minBlockWidth - maxBlockWidth, | ||
1, | ||
) | ||
return { titlesWidth, minBlockWidth, contentWidth } | ||
} | ||
|
||
const getMinMaxBlockWidth = function (combinations, mini, widths) { | ||
return mini ? 0 : Math.max(...widths) | ||
} |