vicanso / go-charts

A charts library for Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

可以添加对X轴Label旋转角度设置和Series显示的FontSize设置的支持吗?

chaodayu opened this issue · comments

1、XAxisOption没有Rotation参数
2、SeriesLabel没有FontSize参数
通过style去设置不起效果。
bbbbbbbbbb
cccccccc
dddddddd

第一点暂未有规划支持,第二点后续版本增加支持配置

那如果不能规划支持X轴Label旋转,是否可以把XAxisOption.Show 为false的时候只隐藏label呢?
现在的情况XAxisOption.Show=FalseFlag后,底边直接就空了,连分隔点都没有了。
直接用Painter.TextRotation方法自己贴,也没法看。。。
aaaaaaaaa

  opt.XAxis.FontColor = drawing.ColorGreen.WithAlpha(0)

设置字体颜色为透明即可

非常感谢您的回答。

@chaodayu 最新版本可设置text rotation,方法如下:

// 旋转的角度
opt.XAxis.TextRotation = -math.Pi / 4
// 调整文本的左偏移值
opt.XAxis.LabelOffset.Left = 10
// 调整文本的上偏移值
opt.XAxis.LabelOffset.Top = -10

非常感谢您的支持!
aaaaaaaaa
ddddddddd

ccccccccc

发现旋转后文字会出现显示不全的情况,有什么好的方法解决吗

@lifenglsf 可以尝试设置更大的padding bottom。

			opt.Padding.Bottom = 50

bottom-30
bottom-300
部分代码
graph := gocharts.ChartOption{ Title: gocharts.TitleOption{Text: title, Left: "center"}, XAxis: gocharts.XAxisOption{FontSize: 8, Data: xLabel, Show: &show, TextRotation: -math.Pi / 4, LabelOffset: gocharts.Box{ Top: top, Bottom: 30, }, }, }
发现设置bottom为30和设置bottom为300没有什么区别,是哪里使用的不对吗

直接设置整个图的padding bottom,不是设置LabelOffset

我尝试设置下看看效果,试了可以一定程度上解决问题,但是如果x轴的label是通过程序自动生成的,那么这个label的文字长度是不固定的,这个时候还是可能会出现被遮挡的情况。如果能系统的计算出高度比较好