Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Commit

Permalink
Fix sparkline title overflowing
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbassi committed Jan 1, 2019
1 parent 5d17121 commit 2934d6f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/termui/linegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 16 additions & 13 deletions src/termui/sparkline.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func NewSparklines(ss ...*Sparkline) *Sparklines {
}
}

// Buffer implements Bufferer interface.
func (self *Sparklines) Draw(buf *Buffer) {
self.Block.Draw(buf)

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/termui/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func NewTable() *Table {
func (self *Table) ColResize() {
}

// Buffer implements the Bufferer interface.
func (self *Table) Draw(buf *Buffer) {
self.Lock()

Expand Down
1 change: 0 additions & 1 deletion src/widgets/temp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 2934d6f

Please sign in to comment.