解决go-echarts X轴显示不全问题

2023-01-02  本文已影响0人  EasyNetCN

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"},
        }),
    )
上一篇 下一篇

猜你喜欢

热点阅读