Skip to content

Commit

Permalink
Fix bar chart label position
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreben committed Mar 28, 2018
1 parent 5d03286 commit 3791de7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/plot/barchart.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (c *BarChart) Draw(data *DataTable) string {
}

// Group label
barMiddle := (barLeft + barRight) / 2
c.GetBuffer().WriteCenter(0, barMiddle/c.RuneSize().Width, []rune(group))
barMiddle := int(math.Floor(float64(barLeft+barRight) / float64(2*c.RuneSize().Width)))
c.GetBuffer().WriteCenter(0, barMiddle, []rune(group))

// Count label
countLabelY := int(math.Ceil(float64(barTop)/float64(c.RuneSize().Height))) * c.RuneSize().Height
Expand All @@ -78,7 +78,7 @@ func (c *BarChart) Draw(data *DataTable) string {
countLabelY = 3 * c.RuneSize().Height
}

c.GetBuffer().WriteCenter(countLabelY/c.RuneSize().Height, barMiddle/c.RuneSize().Width, Ff(y))
c.GetBuffer().WriteCenter(countLabelY/c.RuneSize().Height, barMiddle, Ff(y))
}

b := bytes.NewBuffer(nil)
Expand Down

0 comments on commit 3791de7

Please sign in to comment.