go-chart
go-chart copied to clipboard
Way to get "pretty" y-axis number ticks
I have a bar chart with the following auto-generated y-axis ticks.
Is there a way to make it more visually appealing including:
- nice rounded number ticks: e,g. 10,000,000, 20,000,000, 30,000,000 ... 120,000,000, 140,000,000
- right aligned numbers so the commas line up
For the first item, I'm looking into a way to auto-generate those ticks myself, but was wondering if a solution was already available.

I now have a initial implementation here:
https://godoc.org/github.com/grokify/gotilla/math/mathutil#PrettyTicks
This gives me the following:

I also have an abbreviation function now for the following:
https://godoc.org/github.com/grokify/gotilla/strconv/strconvutil#Int64Abbreviation

this is great
I use this to get nice ticks:
import (
"golang.org/x/text/language"
"golang.org/x/text/message"
)
YAxis: chart.YAxis{
ValueFormatter: func(v interface{}) string {
if vf, isFloat := v.(float64); isFloat {
p := message.NewPrinter(language.English)
vi := int64(vf)
return p.Sprintf("%d", vi)
}
return ""
},
}