feat: support font size for series label, #38
This commit is contained in:
parent
f9a534ea02
commit
ef04ac14ab
5 changed files with 13 additions and 2 deletions
|
|
@ -189,6 +189,7 @@ func (b *barChart) render(result *defaultRenderResult, seriesList SeriesList) (B
|
||||||
Radians: radians,
|
Radians: radians,
|
||||||
FontColor: fontColor,
|
FontColor: fontColor,
|
||||||
Offset: series.Label.Offset,
|
Offset: series.Label.Offset,
|
||||||
|
FontSize: series.Label.FontSize,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
||||||
Y: y + barHeight>>1,
|
Y: y + barHeight>>1,
|
||||||
Offset: series.Label.Offset,
|
Offset: series.Label.Offset,
|
||||||
FontColor: series.Label.Color,
|
FontColor: series.Label.Color,
|
||||||
|
FontSize: series.Label.FontSize,
|
||||||
}
|
}
|
||||||
if series.Label.Position == PositionLeft {
|
if series.Label.Position == PositionLeft {
|
||||||
labelValue.X = 0
|
labelValue.X = 0
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,8 @@ func (l *lineChart) render(result *defaultRenderResult, seriesList SeriesList) (
|
||||||
Value: item.Value,
|
Value: item.Value,
|
||||||
X: p.X,
|
X: p.X,
|
||||||
Y: p.Y,
|
Y: p.Y,
|
||||||
|
// 字体大小
|
||||||
|
FontSize: series.Label.FontSize,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 如果需要填充区域
|
// 如果需要填充区域
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ type SeriesLabel struct {
|
||||||
Position string
|
Position string
|
||||||
// The offset of label's position
|
// The offset of label's position
|
||||||
Offset Box
|
Offset Box
|
||||||
|
// The font size of label
|
||||||
|
FontSize float64
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,10 @@ type LabelValue struct {
|
||||||
Radians float64
|
Radians float64
|
||||||
// 字体颜色
|
// 字体颜色
|
||||||
FontColor Color
|
FontColor Color
|
||||||
Orient string
|
// 字体大小
|
||||||
Offset Box
|
FontSize float64
|
||||||
|
Orient string
|
||||||
|
Offset Box
|
||||||
}
|
}
|
||||||
|
|
||||||
type SeriesLabelPainter struct {
|
type SeriesLabelPainter struct {
|
||||||
|
|
@ -89,6 +91,9 @@ func (o *SeriesLabelPainter) Add(value LabelValue) {
|
||||||
FontSize: labelFontSize,
|
FontSize: labelFontSize,
|
||||||
Font: o.font,
|
Font: o.font,
|
||||||
}
|
}
|
||||||
|
if value.FontSize != 0 {
|
||||||
|
labelStyle.FontSize = value.FontSize
|
||||||
|
}
|
||||||
if !value.FontColor.IsZero() {
|
if !value.FontColor.IsZero() {
|
||||||
label.Color = value.FontColor
|
label.Color = value.FontColor
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue