Only draw StackedBarChart label if it exists

This commit is contained in:
Caleb Bassi 2019-01-24 05:38:28 -08:00
parent 7b48d56e0b
commit 1a62cfa10f

View File

@ -79,6 +79,7 @@ func (self *StackedBarChart) Draw(buf *Buffer) {
}
// draw label
if i < len(self.Labels) {
labelXCoordinate := barXCoordinate + MaxInt(
int((float64(self.BarWidth)/2))-int((float64(rw.StringWidth(self.Labels[i]))/2)),
0,
@ -88,6 +89,7 @@ func (self *StackedBarChart) Draw(buf *Buffer) {
SelectStyle(self.LabelStyles, i),
image.Pt(labelXCoordinate, self.Inner.Max.Y-1),
)
}
barXCoordinate += (self.BarWidth + self.BarGap)
}