Fix: show all the XAxis elements

This commit is contained in:
Óscar M. Lage 2024-12-05 17:42:15 +01:00
parent 37f5d50928
commit 5dac40aa86

View File

@ -93,6 +93,13 @@ func createBarChart(stats []CommandStat) *charts.Bar {
Title: "Top Commands", Title: "Top Commands",
Subtitle: "Most used commands", Subtitle: "Most used commands",
}), }),
charts.WithXAxisOpts(opts.XAxis{
AxisLabel: &opts.AxisLabel{
Show: opts.Bool(true),
Interval: "0",
Rotate: 45,
},
}),
) )
commands := make([]string, len(stats)) commands := make([]string, len(stats))
@ -103,13 +110,7 @@ func createBarChart(stats []CommandStat) *charts.Bar {
} }
bar.SetXAxis(commands). bar.SetXAxis(commands).
AddSeries("Freq", generateBarItems(counts)). AddSeries("Freq", generateBarItems(counts))
SetSeriesOptions(
charts.WithLabelOpts(opts.Label{
Color: "white",
Position: "top",
}),
)
return bar return bar
} }
@ -119,6 +120,7 @@ func generateBarItems(data []int) []opts.BarData {
for i, v := range data { for i, v := range data {
items[i] = opts.BarData{Value: v} items[i] = opts.BarData{Value: v}
} }
log.Printf("items: %#v", items)
return items return items
} }