vicanso / go-charts

A charts library for Golang

Home Page:https://charts.npmtrend.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何给柱状图添加自定义label?

huizhang001 opened this issue · comments

如何给柱状图添加自定义label?

类似这种:
image

横向无法展示

暂未支持此种方式展示label,可以使用render返回的Painter实现自定义的处理

好,谢谢,后续有计划实现这个能力吗。

能给个例子吗。。。自定义label

main 分支增加了TextRotation的方法,使用方法如下:

p.TextRotation("Hello world", 100, 100, -math.Pi/2)

但是需要计算每个柱状图的位置,以及根据其对应的颜色设置字体颜色,较为复杂

@huizhang001 最新版本已支持此设置,代码如下:

func(opt *charts.ChartOption) {
	// 显示label
	opt.SeriesList[0].Label.Show = true
	// 设置位置
	opt.SeriesList[0].Label.Position = charts.PositionBottom
	// 设置左偏移量(也可设置top)
	opt.SeriesList[0].Label.Offset.Left = -1
}

image