fix: truncate the legend definitions

pull/21/head
Dominique Merle 3 years ago
parent 7235317cdc
commit 071ebd5c8d

@ -83,7 +83,7 @@ func (t *TextFormatter) Format(
for gradeIndex, gradeName := range grades {
legendDefinitions = append(
legendDefinitions,
fmt.Sprintf("%s=%s", getCharForIndex(gradeIndex), gradeName),
fmt.Sprintf("%s=%s", getCharForIndex(gradeIndex), truncateString(gradeName, chartWidth-3, '…')),
)
}
@ -147,9 +147,9 @@ func makeAsciiMeritProfile(
amountOfJudges := float64(tally.CountJudgments())
for gradeIndex, gradeTallyInt := range tally.Tally {
gradeTally := float64(gradeTallyInt)
gradeRune := getCharForIndex(gradeIndex)
gradeChar := getCharForIndex(gradeIndex)
ascii += strings.Repeat(
gradeRune,
gradeChar,
int(math.Round(float64(width)*gradeTally/amountOfJudges)),
)
}

@ -112,7 +112,7 @@ func (t *TextOpinionFormatter) Format(
fmt.Sprintf(
"%s=%s",
getCharForIndex(proposalResult.Index),
proposals[proposalResult.Index],
truncateString(proposals[proposalResult.Index], chartWidth-2, '…'),
),
)
}

Loading…
Cancel
Save