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 {
|
if labelPainter == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
x := right
|
labelValue := LabelValue{
|
||||||
var fontColor Color
|
Orient: OrientHorizontal,
|
||||||
|
Index: index,
|
||||||
|
Value: item.Value,
|
||||||
|
X: right,
|
||||||
|
Y: y + barHeight>>1,
|
||||||
|
Offset: series.Label.Offset,
|
||||||
|
}
|
||||||
if series.Label.Position == PositionLeft {
|
if series.Label.Position == PositionLeft {
|
||||||
x = 0
|
labelValue.X = 0
|
||||||
if isLightColor(fillColor) {
|
if isLightColor(fillColor) {
|
||||||
fontColor = defaultLightFontColor
|
labelValue.FontColor = defaultLightFontColor
|
||||||
} else {
|
} else {
|
||||||
fontColor = defaultDarkFontColor
|
labelValue.FontColor = defaultDarkFontColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
labelPainter.Add(LabelValue{
|
labelPainter.Add(labelValue)
|
||||||
Orient: OrientHorizontal,
|
|
||||||
Index: index,
|
|
||||||
Value: item.Value,
|
|
||||||
X: x,
|
|
||||||
Y: y + barHeight>>1,
|
|
||||||
FontColor: fontColor,
|
|
||||||
Offset: series.Label.Offset,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err := doRender(rendererList...)
|
err := doRender(rendererList...)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue