fix: fix the color of series label, #37
This commit is contained in:
parent
df6180e59a
commit
f9a534ea02
2 changed files with 20 additions and 15 deletions
|
|
@ -168,16 +168,18 @@ func (b *barChart) render(result *defaultRenderResult, seriesList SeriesList) (B
|
|||
}
|
||||
y := barMaxHeight - h
|
||||
radians := float64(0)
|
||||
var fontColor Color
|
||||
fontColor := series.Label.Color
|
||||
if series.Label.Position == PositionBottom {
|
||||
y = barMaxHeight
|
||||
radians = -math.Pi / 2
|
||||
if fontColor.IsZero() {
|
||||
if isLightColor(fillColor) {
|
||||
fontColor = defaultLightFontColor
|
||||
} else {
|
||||
fontColor = defaultDarkFontColor
|
||||
}
|
||||
}
|
||||
}
|
||||
labelPainter.Add(LabelValue{
|
||||
Index: index,
|
||||
Value: item.Value,
|
||||
|
|
|
|||
|
|
@ -155,15 +155,18 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
|||
X: right,
|
||||
Y: y + barHeight>>1,
|
||||
Offset: series.Label.Offset,
|
||||
FontColor: series.Label.Color,
|
||||
}
|
||||
if series.Label.Position == PositionLeft {
|
||||
labelValue.X = 0
|
||||
if labelValue.FontColor.IsZero() {
|
||||
if isLightColor(fillColor) {
|
||||
labelValue.FontColor = defaultLightFontColor
|
||||
} else {
|
||||
labelValue.FontColor = defaultDarkFontColor
|
||||
}
|
||||
}
|
||||
}
|
||||
labelPainter.Add(labelValue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue