Closes #40, overflow line graph labels.

This commit is contained in:
Sean E. Russell 2020-04-16 18:13:57 -05:00
parent 9e1b63be32
commit e506b02842
2 changed files with 16 additions and 4 deletions

View File

@ -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

View File

@ -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),
)
}
}