Fix sparkline title overflowing

This commit is contained in:
Caleb Bassi 2019-01-01 02:29:14 -08:00
parent 5d17121510
commit 2934d6fd48
4 changed files with 16 additions and 16 deletions

View File

@ -30,7 +30,6 @@ func NewLineGraph() *LineGraph {
}
}
// Buffer implements Bufferer interface.
func (self *LineGraph) Draw(buf *Buffer) {
self.Block.Draw(buf)
// we render each data point on to the canvas then copy over the braille to the buffer at the end

View File

@ -41,7 +41,6 @@ func NewSparklines(ss ...*Sparkline) *Sparklines {
}
}
// Buffer implements Bufferer interface.
func (self *Sparklines) Draw(buf *Buffer) {
self.Block.Draw(buf)
@ -51,20 +50,24 @@ func (self *Sparklines) Draw(buf *Buffer) {
for i, line := range self.Lines {
// prints titles
title1Y := 2 + (self.Inner.Dy()/lc)*i
title2Y := (2 + (self.Inner.Dy()/lc)*i) + 1
title1Y := self.Inner.Min.Y + 1 + (self.Inner.Dy()/lc)*i
title2Y := self.Inner.Min.Y + 2 + (self.Inner.Dy()/lc)*i
title1 := TrimString(line.Title1, self.Inner.Dx())
title2 := TrimString(line.Title2, self.Inner.Dx())
buf.SetString(
title1,
image.Pt(self.Inner.Min.X, self.Inner.Min.Y+title1Y-1),
AttrPair{line.TitleColor | AttrBold, -1},
)
buf.SetString(
title2,
image.Pt(self.Inner.Min.X, self.Inner.Min.Y+title2Y-1),
AttrPair{line.TitleColor | AttrBold, -1},
)
if self.Inner.Dy() > 5 {
buf.SetString(
title1,
image.Pt(self.Inner.Min.X, title1Y),
AttrPair{line.TitleColor | AttrBold, -1},
)
}
if self.Inner.Dy() > 6 {
buf.SetString(
title2,
image.Pt(self.Inner.Min.X, title2Y),
AttrPair{line.TitleColor | AttrBold, -1},
)
}
sparkY := (self.Inner.Dy() / lc) * (i + 1)
// finds max data in current view used for relative heights

View File

@ -50,7 +50,6 @@ func NewTable() *Table {
func (self *Table) ColResize() {
}
// Buffer implements the Bufferer interface.
func (self *Table) Draw(buf *Buffer) {
self.Lock()

View File

@ -48,7 +48,6 @@ func NewTemp(fahrenheit bool) *Temp {
return self
}
// Buffer implements ui.Bufferer interface and renders the widget.
func (self *Temp) Draw(buf *ui.Buffer) {
self.Block.Draw(buf)