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
12
bar_chart.go
12
bar_chart.go
|
|
@ -168,14 +168,16 @@ func (b *barChart) render(result *defaultRenderResult, seriesList SeriesList) (B
|
||||||
}
|
}
|
||||||
y := barMaxHeight - h
|
y := barMaxHeight - h
|
||||||
radians := float64(0)
|
radians := float64(0)
|
||||||
var fontColor Color
|
fontColor := series.Label.Color
|
||||||
if series.Label.Position == PositionBottom {
|
if series.Label.Position == PositionBottom {
|
||||||
y = barMaxHeight
|
y = barMaxHeight
|
||||||
radians = -math.Pi / 2
|
radians = -math.Pi / 2
|
||||||
if isLightColor(fillColor) {
|
if fontColor.IsZero() {
|
||||||
fontColor = defaultLightFontColor
|
if isLightColor(fillColor) {
|
||||||
} else {
|
fontColor = defaultLightFontColor
|
||||||
fontColor = defaultDarkFontColor
|
} else {
|
||||||
|
fontColor = defaultDarkFontColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
labelPainter.Add(LabelValue{
|
labelPainter.Add(LabelValue{
|
||||||
|
|
|
||||||
|
|
@ -149,19 +149,22 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
labelValue := LabelValue{
|
labelValue := LabelValue{
|
||||||
Orient: OrientHorizontal,
|
Orient: OrientHorizontal,
|
||||||
Index: index,
|
Index: index,
|
||||||
Value: item.Value,
|
Value: item.Value,
|
||||||
X: right,
|
X: right,
|
||||||
Y: y + barHeight>>1,
|
Y: y + barHeight>>1,
|
||||||
Offset: series.Label.Offset,
|
Offset: series.Label.Offset,
|
||||||
|
FontColor: series.Label.Color,
|
||||||
}
|
}
|
||||||
if series.Label.Position == PositionLeft {
|
if series.Label.Position == PositionLeft {
|
||||||
labelValue.X = 0
|
labelValue.X = 0
|
||||||
if isLightColor(fillColor) {
|
if labelValue.FontColor.IsZero() {
|
||||||
labelValue.FontColor = defaultLightFontColor
|
if isLightColor(fillColor) {
|
||||||
} else {
|
labelValue.FontColor = defaultLightFontColor
|
||||||
labelValue.FontColor = defaultDarkFontColor
|
} else {
|
||||||
|
labelValue.FontColor = defaultDarkFontColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
labelPainter.Add(labelValue)
|
labelPainter.Add(labelValue)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue