feat: support top setting for title

This commit is contained in:
vicanso 2022-01-02 09:45:12 +08:00
parent 25e9984ad8
commit 72896d1c3f
5 changed files with 379 additions and 4 deletions

View file

@ -88,6 +88,11 @@ func NewTitleCustomize(title Title) chart.Renderable {
}
titleY := cb.Top + title.Style.Padding.GetTop(chart.DefaultTitleTop) + (textHeight >> 1)
// TOP 暂只支持数值
if title.Top != "" {
value, _ := strconv.Atoi(title.Top)
titleY += value
}
for _, item := range measureOptions {
x := titleX + (textWidth-item.width)>>1