From a470ddf1c585771c7d0f53436aa122e89e2a3419 Mon Sep 17 00:00:00 2001 From: Bence Kiglics Date: Fri, 3 Mar 2017 16:38:15 +0100 Subject: [PATCH] Fixed wrong Y-axis labels for small values --- types/chartrenderer.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/chartrenderer.go b/types/chartrenderer.go index 2e0b1b9..774e796 100644 --- a/types/chartrenderer.go +++ b/types/chartrenderer.go @@ -18,7 +18,7 @@ func max(data []uint64) uint64 { return max } -func humanReadableInt(value uint64) string { +func humanReadableDouble(value float64) string { val := float64(value) suffices := []string{"", "k", "M", "G", "T", "P"} magnitude := 0 @@ -257,11 +257,11 @@ func (r *ChartRenderer) Render() string { for y := 0; y < int(mulHeight); y += hMult { line := bytes.NewBufferString("") - value := max - (uint64(y+hMult)*max)/mulHeight + value := float64(max) - float64(uint64(y+hMult)*max)/float64(mulHeight) if r.settings.YAxisLabels { if (chartAreaHeight-y/hMult-1)%5 == 0 { - line.WriteString(fmt.Sprintf("%4s ", humanReadableInt(value))) + line.WriteString(fmt.Sprintf("%4s ", humanReadableDouble(value))) } else { line.WriteString(" ") }