vicanso / go-charts

A charts library for Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

为图设置标题,并且同时为展示每条线的LegendLabels,两都会叠在一起,看不清

leslieDD opened this issue · comments

image

另外Y轴是流量,在数据达到G以上时,能不能展示成相应的以G为单位的效果

@leslieDD legend可以设置top的位置以及padding,通过指定此属性可以调整位置。Y轴的展示晚点支持

			opt.Legend.Padding = charts.Box{
				Top:    200,
				Bottom: 100,
			}
			opt.Legend.Top = "200"

这个尝试很多,没有效果,

 charts.LegendLabelsOptionFunc(lineTitle, charts.PositionCenter)

上面这行,后面的位置参数倒是有效果

通过设置如下属性,效果如图,如果还有问题需要完整的示例代码贴出来。

func(opt *charts.ChartOption) {
	opt.Title.Left = charts.PositionCenter
	opt.Legend.Padding = charts.Box{
		Top:    50,
		Bottom: 10,
	}
}

image

可以,和顺序有关系:
在设置charts.LineRenderopts ...OptionFunc参数时,charts.LegendLabelsOptionFunc放在func(opt *charts.ChartOption) {opt.Legend.Padding = ....}之前就有效果,之前是放在后面的,怎么调都没有效果

自定义属性放在最后的函数处理,因为默认的OptionFunc都有可能会有默认的覆盖值