Only draw StackedBarChart label if it exists
This commit is contained in:
parent
7b48d56e0b
commit
1a62cfa10f
@ -79,15 +79,17 @@ func (self *StackedBarChart) Draw(buf *Buffer) {
|
||||
}
|
||||
|
||||
// draw label
|
||||
labelXCoordinate := barXCoordinate + MaxInt(
|
||||
int((float64(self.BarWidth)/2))-int((float64(rw.StringWidth(self.Labels[i]))/2)),
|
||||
0,
|
||||
)
|
||||
buf.SetString(
|
||||
TrimString(self.Labels[i], self.BarWidth),
|
||||
SelectStyle(self.LabelStyles, i),
|
||||
image.Pt(labelXCoordinate, self.Inner.Max.Y-1),
|
||||
)
|
||||
if i < len(self.Labels) {
|
||||
labelXCoordinate := barXCoordinate + MaxInt(
|
||||
int((float64(self.BarWidth)/2))-int((float64(rw.StringWidth(self.Labels[i]))/2)),
|
||||
0,
|
||||
)
|
||||
buf.SetString(
|
||||
TrimString(self.Labels[i], self.BarWidth),
|
||||
SelectStyle(self.LabelStyles, i),
|
||||
image.Pt(labelXCoordinate, self.Inner.Max.Y-1),
|
||||
)
|
||||
}
|
||||
|
||||
barXCoordinate += (self.BarWidth + self.BarGap)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user