-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
X轴文字偏移问题 #63
Comments
麻烦提供完整的代码或者表格数据 |
代码: func Chart() {
values := [][]float64{
{65706, 66390, 60649, 56504, 53786, 52932, 72626, 57316, 65547, 57382, 56146, 53667, 53097, 57409},
{45705, 46607, 39843, 33040, 32105, 25387, 51778, 63254, 63402, 50700, 51853, 45923, 46298, 54673},
{25213, 23734, 23470, 24244, 11602, 10932, 18507, 11343, 10174, 14269, 14511, 5166, 3672, 6517},
{5756, 8977, 7739, 5177, 4363, 3223, 9964, 6189, 8359, 5743, 5572, 4029, 4365, 8164},
{2991, 3230, 3120, 2837, 2285, 2271, 3168, 3202, 3167, 3296, 3030, 2439, 2446, 3158},
}
xAxis := []string{"20231212", "20231213", "20231214", "20231215", "20231216", "20231217", "20231218", "20231219", "20231220", "20231221", "20231222", "20231223", "20231224", "20231225"}
legends := []string{"x1", "x2", "x3", "x4", "x5"}
painter, e1 := charts.LineRender(
values,
charts.TitleOptionFunc(charts.TitleOption{Text: "Trend", Left: charts.PositionCenter, FontSize: 20}),
charts.XAxisOptionFunc(charts.XAxisOption{Data: xAxis}),
charts.LegendOptionFunc(charts.LegendOption{Data: legends, Left: charts.PositionRight}),
charts.WidthOptionFunc(1600),
charts.HeightOptionFunc(800),
)
if e1 != nil {
fmt.Println(e1.Error())
return
}
data, e2 := painter.Bytes()
if e2 != nil {
fmt.Println(e2.Error())
return
}
file, e3 := os.Create("chart.png")
if e3 != nil {
fmt.Println(e3.Error())
return
}
if _, e3 = file.Write(data); e3 != nil {
fmt.Println(e3.Error())
}
} 效果: |
之前版本的计算问题,可能需要确认一下如何调整更方便。如果不是必须要使用golang的,那么可以尝试使用: https://charts.npmtrend.com/ ,提供了json形式配置生成图表,更简单方便,可直接使用docker部署。 |
试了一下 v2.6.0,是正常的,我先用这个版本吧,谢谢! |
的确是最近的一次mr影响了,我先revert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如上图,x轴最后一列文字的过于偏左,请问这种该怎么调整,谢谢!
The text was updated successfully, but these errors were encountered: