Skip to content

Commit

Permalink
Include legend text in column
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Nov 1, 2020
1 parent 8700ba6 commit bb32762
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
17 changes: 15 additions & 2 deletions diagnoser/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ func gridLayout(w *widgets) ([]container.Option, error) {
grid.ColWidthPerc(50, grid.Widget(w.CPUChart, container.Border(linestyle.Light), container.BorderTitle("CPU Usage (%)"))),
grid.ColWidthPerc(50, grid.Widget(w.GoroutineChart, container.Border(linestyle.Light), container.BorderTitle("Goroutines"))),
)
raw3 := grid.RowHeightPerc(45,
grid.Widget(w.HeapChart, container.Border(linestyle.Light), container.BorderTitle("Heap (MB)")),
raw3 := grid.RowHeightPercWithOpts(45,
[]container.Option{container.Border(linestyle.Light), container.BorderTitle("Heap (MB)")},
grid.RowHeightPerc(97, grid.ColWidthPerc(99, grid.Widget(w.HeapChart))),
grid.RowHeightPercWithOpts(3,
[]container.Option{container.MarginLeftPercent(w.HeapChart.Options().MinimumSize.X)},
textsInColumn(w.HeapAllocLegend.text, w.HeapIdelLegend.text, w.HeapInuseLegend.text)...,
),
)
builder := grid.New()
builder.Add(
Expand All @@ -121,6 +126,14 @@ func gridLayout(w *widgets) ([]container.Option, error) {
return builder.Build()
}

func textsInColumn(texts ...Text) []grid.Element {
els := make([]grid.Element, 0, len(texts))
for _, text := range texts {
els = append(els, grid.ColWidthPerc(3, grid.Widget(text)))
}
return els
}

// appendStats appends entities as soon as a stats arrives.
// Note that it doesn't redraw the moment stats are appended.
func (g *GUI) appendStats(ctx context.Context) {
Expand Down
8 changes: 4 additions & 4 deletions diagnoser/gui/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ func newWidgets(meta *stats.Meta) (*widgets, error) {
return nil, err
}

allocColor := cell.FgColor(cell.ColorMagenta)
allocColor := cell.FgColor(cell.ColorYellow)
allocText, err := newText("alloc", text.WriteCellOpts(allocColor))
if err != nil {
return nil, err
}
idleColor := cell.FgColor(cell.ColorGreen)
idleColor := cell.FgColor(cell.ColorNumber(87))
idleText, err := newText("idle", text.WriteCellOpts(idleColor))
if err != nil {
return nil, err
}
inuseColor := cell.FgColor(cell.ColorYellow)
inuseText, err := newText("idle", text.WriteCellOpts(inuseColor))
inuseColor := cell.FgColor(cell.ColorGreen)
inuseText, err := newText("inuse", text.WriteCellOpts(inuseColor))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit bb32762

Please sign in to comment.