summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Grebenshchikov <sgreben@gmail.com>2018-03-28 23:27:32 +0200
committerSergey Grebenshchikov <sgreben@gmail.com>2018-03-28 23:27:32 +0200
commit3791de72267fc1b561e7f22595c9e90353f2f351 (patch)
tree747c251461e84554d52ccbb2d82aba781aa3f363
parent5d032864a7a84dc3199b54e6216b718d6902d40a (diff)
Fix bar chart label position
-rw-r--r--pkg/plot/barchart.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/pkg/plot/barchart.go b/pkg/plot/barchart.go
index cb6c95c..6bcacd9 100644
--- a/pkg/plot/barchart.go
+++ b/pkg/plot/barchart.go
@@ -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
@@ -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)