lint fixes

Signed-off-by: Markus Ressel <mail@markusressel.de>
This commit is contained in:
Markus Ressel 2024-10-13 12:22:19 +02:00
parent fb7e4a8141
commit 12e9f953a3
No known key found for this signature in database
GPG Key ID: F79626FAB2A3AACF

View File

@ -298,6 +298,7 @@ func (plot *Plot) drawXAxisLabelsToScreen(
// determine the width needed for the largest label
maxXAxisLabelWidth := 0
for _, d := range plot.data {
for i := range d {
label := plot.xAxisLabelFunc(i)
labelMap[i] = label
@ -324,6 +325,7 @@ func (plot *Plot) drawXAxisLabelsToScreen(
// stopping when there is no more space
lastUsedLabelEnd := math.MinInt
initialOffset := xAxisAreaStartX
for i := 0; i < maxDataPoints; i++ {
labelStart := labelStartMap[i]
if labelStart < lastUsedLabelEnd {
@ -333,6 +335,7 @@ func (plot *Plot) drawXAxisLabelsToScreen(
rawLabel := labelMap[i]
labelWithGap := rawLabel
if i == 0 {
labelWithGap += strings.Repeat(gapRune, plotXAxisLabelsGap/2)
} else {
@ -341,6 +344,7 @@ func (plot *Plot) drawXAxisLabelsToScreen(
expectedLabelWidth := len(labelWithGap)
remainingWidth := xAxisAvailableWidth - labelStart
if expectedLabelWidth > remainingWidth {
// the label would be too long to fit in the remaining space
if expectedLabelWidth-1 <= remainingWidth {