minor legend improvements

This commit is contained in:
sqshq 2019-02-15 22:46:03 -05:00
parent 1b7f851174
commit 518b52c686
2 changed files with 20 additions and 2 deletions

View File

@ -144,6 +144,15 @@ func (l *Layout) HandleConsoleEvent(e string) {
}
case console.KeyUp:
switch l.mode {
case ModeDefault:
l.mode = ModeComponentSelect
l.selection = 0
l.menu.highlight(l.getComponent(l.selection))
case ModeComponentSelect:
if l.selection > 0 {
l.selection--
}
l.menu.highlight(l.getComponent(l.selection))
case ModeMenuOptionSelect:
l.menu.up()
case ModeComponentMove:
@ -153,6 +162,15 @@ func (l *Layout) HandleConsoleEvent(e string) {
}
case console.KeyDown:
switch l.mode {
case ModeDefault:
l.mode = ModeComponentSelect
l.selection = 0
l.menu.highlight(l.getComponent(l.selection))
case ModeComponentSelect:
if l.selection < len(l.components)-1 {
l.selection++
}
l.menu.highlight(l.getComponent(l.selection))
case ModeMenuOptionSelect:
l.menu.down()
case ModeComponentMove:

View File

@ -36,7 +36,7 @@ func (c *RunChart) renderLegend(buffer *ui.Buffer, rectangle image.Rectangle) {
height = heightOnDetails
}
rowCount := (c.Dx() - yAxisLegendIndent) / (height + yAxisLegendIndent)
rowCount := (c.Dy() - 2*yAxisLegendIndent) / (height + yAxisLegendIndent)
columnCount := int(math.Ceil(float64(len(c.lines)) / float64(rowCount)))
columnWidth := getColumnWidth(c.mode, c.lines, c.precision)
@ -71,9 +71,9 @@ func (c *RunChart) renderLegend(buffer *ui.Buffer, rectangle image.Rectangle) {
details := [4]string{
fmt.Sprintf("cur %s", formatValue(getCurrentValue(line), c.precision)),
fmt.Sprintf("dlt %s", formatValue(getDiffWithPreviousValue(line), c.precision)),
fmt.Sprintf("max %s", formatValue(line.extrema.max, c.precision)),
fmt.Sprintf("min %s", formatValue(line.extrema.min, c.precision)),
fmt.Sprintf("dif %s", formatValue(getDiffWithPreviousValue(line), c.precision)),
}
for i, detail := range details {