Skip to content

Commit d5ee20b

Browse files
committed
Cut off the bar chart labels at 2 places after decimal
Showing the entire float64 value is not practical and overflows badly in most situations.
1 parent fc5524a commit d5ee20b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

plotter/barchart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (b *BarChart) Plot(c draw.Canvas, plt *plot.Plot) {
161161
c.StrokeLines(b.LineStyle, outline...)
162162
if b.ShowValue {
163163
// Display the value of each bar above it
164-
barLabel := fmt.Sprintf("%f", ht)
164+
barLabel := fmt.Sprintf("%.2f", ht)
165165
ft, _ := vg.MakeFont(plot.DefaultFont, 10)
166166
c.FillText(draw.TextStyle{Color: color.Black, Font: ft}, vg.Point{X: labelX, Y: labelY}, barLabel)
167167
}

0 commit comments

Comments
 (0)