feat: support top setting for title
This commit is contained in:
parent
25e9984ad8
commit
72896d1c3f
5 changed files with 379 additions and 4 deletions
|
|
@ -49,6 +49,7 @@ type (
|
|||
Style chart.Style
|
||||
Font *truetype.Font
|
||||
Left string
|
||||
Top string
|
||||
}
|
||||
Legend struct {
|
||||
Data []string
|
||||
|
|
@ -194,10 +195,11 @@ func newPieChart(opt Options) *chart.PieChart {
|
|||
if opt.Title.Left == "" {
|
||||
opt.Title.Left = "center"
|
||||
}
|
||||
themeColorPalette := &ThemeColorPalette{
|
||||
Theme: opt.Theme,
|
||||
titleColor := drawing.ColorBlack
|
||||
if opt.Theme == ThemeDark {
|
||||
titleColor = drawing.ColorWhite
|
||||
}
|
||||
titleRender := newTitleRenderable(opt.Title, p.GetFont(), themeColorPalette.TextColor())
|
||||
titleRender := newTitleRenderable(opt.Title, p.GetFont(), titleColor)
|
||||
if titleRender != nil {
|
||||
p.Elements = []chart.Renderable{
|
||||
titleRender,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue