go-ehcharts(https://github.com/go-echarts/go-echarts)是golang的图表库,api兼容echarts(https://github.com/apache/echarts),在使用中,发现X轴显示不全,可以通过以下方式解决:
bar := charts.NewBar()
// set some global options like Title/Legend/ToolTip or anything else
bar.SetGlobalOptions(
charts.WithTitleOpts(opts.Title{
Title: "代码统计",
Subtitle: "柱形图",
}),
charts.WithTooltipOpts(opts.Tooltip{Show: true}),
charts.WithInitializationOpts(opts.Initialization{
Width: width,
Height: height,
}),
charts.WithXAxisOpts(opts.XAxis{
AxisLabel: &opts.AxisLabel{Rotate: 45, ShowMinLabel: true, ShowMaxLabel: true, Interval: "0"},
}),
)
网友评论