summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-04-16 18:13:57 -0500
committerSean E. Russell <ser@ser1.net>2020-04-16 18:13:57 -0500
commite506b0284243dedd442e4e1a049a0bd047992d4a (patch)
tree6af9b0674f844606a76679433e4631be48153d02
parent9e1b63be3250661124babf270f8a13326ef0d2f0 (diff)
Closes #40, overflow line graph labels.
-rw-r--r--CHANGELOG.md4
-rw-r--r--termui/linegraph.go16
2 files changed, 16 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba003ac..43f7437 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Help prints location of logs.
- CLI option to scale out (#84).
- Ability to report network traffic rates as mbps (#46).
+- Ignore lines matching `/^#.*/` in layout files.
+- Instructions for Gentoo (thanks @tormath1!)
+- Graph labels that don't fit (vertically) in the window are now drawn in additional columns (#40)
### Changed
@@ -37,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Help & statusbar don't obey theme (#47).
- Fix help text layout.
+- Merged fix from @markuspeloquin for custom color scheme loading crash
## [3.5.1] - 2020-04-09
diff --git a/termui/linegraph.go b/termui/linegraph.go
index fffad55..de6ca35 100644
--- a/termui/linegraph.go
+++ b/termui/linegraph.go
@@ -71,7 +71,7 @@ func (self *LineGraph) Draw(buf *Buffer) {
y := ((self.Inner.Dy() + 1) * 4) - 1 - int((float64((self.Inner.Dy())*4)-1)*(seriesData[i]/100))
if x < 0 {
// render the line to the last point up to the wall
- if x > 0-self.HorizontalScale {
+ if x > -self.HorizontalScale {
for _, p := range drawille.Line(lastX, lastY, x, y) {
if p.X > 0 {
c.Set(p.X, p.Y)
@@ -111,9 +111,14 @@ func (self *LineGraph) Draw(buf *Buffer) {
}
// renders key/label ontop
+ maxWid := 0
+ xoff := 0 // X offset for additional columns of text
+ yoff := 0 // Y offset for resetting column to top of widget
for i, seriesName := range seriesList {
- if i+2 > self.Inner.Dy() {
- continue
+ if yoff+i+2 > self.Inner.Dy() {
+ xoff += maxWid + 2
+ yoff = -i
+ maxWid = 0
}
seriesLineColor, ok := self.LineColors[seriesName]
if !ok {
@@ -122,11 +127,14 @@ func (self *LineGraph) Draw(buf *Buffer) {
// render key ontop, but let braille be drawn over space characters
str := seriesName + " " + self.Labels[seriesName]
+ if len(str) > maxWid {
+ maxWid = len(str)
+ }
for k, char := range str {
if char != ' ' {
buf.SetCell(
NewCell(char, NewStyle(seriesLineColor)),
- image.Pt(self.Inner.Min.X+2+k, self.Inner.Min.Y+i+1),
+ image.Pt(xoff+self.Inner.Min.X+2+k, yoff+self.Inner.Min.Y+i+1),
)
}
}