Skip to content

Commit

Permalink
Fixed wrong Y-axis labels for small values
Browse files Browse the repository at this point in the history
  • Loading branch information
kbence committed Mar 3, 2017
1 parent a68d8db commit a470ddf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions types/chartrenderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(" ")
}
Expand Down

0 comments on commit a470ddf

Please sign in to comment.