refactor: adjust label value of horizontal bar
This commit is contained in:
parent
6db8e2c8dc
commit
5f0aec60d3
1 changed files with 12 additions and 14 deletions
|
|
@ -148,25 +148,23 @@ func (h *horizontalBarChart) render(result *defaultRenderResult, seriesList Seri
|
|||
if labelPainter == nil {
|
||||
continue
|
||||
}
|
||||
x := right
|
||||
var fontColor Color
|
||||
if series.Label.Position == PositionLeft {
|
||||
x = 0
|
||||
if isLightColor(fillColor) {
|
||||
fontColor = defaultLightFontColor
|
||||
} else {
|
||||
fontColor = defaultDarkFontColor
|
||||
}
|
||||
}
|
||||
labelPainter.Add(LabelValue{
|
||||
labelValue := LabelValue{
|
||||
Orient: OrientHorizontal,
|
||||
Index: index,
|
||||
Value: item.Value,
|
||||
X: x,
|
||||
X: right,
|
||||
Y: y + barHeight>>1,
|
||||
FontColor: fontColor,
|
||||
Offset: series.Label.Offset,
|
||||
})
|
||||
}
|
||||
if series.Label.Position == PositionLeft {
|
||||
labelValue.X = 0
|
||||
if isLightColor(fillColor) {
|
||||
labelValue.FontColor = defaultLightFontColor
|
||||
} else {
|
||||
labelValue.FontColor = defaultDarkFontColor
|
||||
}
|
||||
}
|
||||
labelPainter.Add(labelValue)
|
||||
}
|
||||
}
|
||||
err := doRender(rendererList...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue