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 2ce4a48 commit 610ee33
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/report/reporters/histogram/rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ const getHistogramColumns = function ({
}) {
const medianMaxWidth = Math.max(medianIndex, contentWidth - 1 - medianIndex)
const maxHeight = getMaxHeight(frequencies, height)
return frequencies.map(
getHistogramColumn.bind(undefined, {
return frequencies.map((frequency, columnIndex) =>
getHistogramColumn({
frequency,
columnIndex,
maxHeight,
medianIndex,
medianMaxWidth,
Expand All @@ -64,11 +66,13 @@ const getMaxHeight = function (frequencies, height) {
// Retrieve the height of each column.
// `heightLevel` is the integer part (full character) and `charIndex` is the
// fractional part (final character on top of column).
const getHistogramColumn = function (
{ maxHeight, medianIndex, medianMaxWidth },
const getHistogramColumn = function ({
frequency,
columnIndex,
) {
maxHeight,
medianIndex,
medianMaxWidth,
}) {
const columnHeight = maxHeight * frequency
const heightLevel = Math.floor(columnHeight)
const charIndex = Math.ceil(
Expand Down

0 comments on commit 610ee33

Please sign in to comment.