29 lines
783 B
Go
Raw Normal View History

2021-12-19 18:39:14 +11:00
// Demo code for the bar chart primitive.
package main
import (
"github.com/gdamore/tcell/v2"
2021-12-21 18:13:01 +11:00
"github.com/navidys/tvxwidgets"
2021-12-19 18:39:14 +11:00
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
2021-12-21 18:13:01 +11:00
barGraph := tvxwidgets.NewBarChart()
2021-12-19 19:08:41 +11:00
barGraph.SetRect(4, 2, 50, 20)
2021-12-19 18:39:14 +11:00
barGraph.SetBorder(true)
2021-12-19 19:06:37 +11:00
barGraph.SetTitle("System Resource Usage")
2021-12-19 18:39:14 +11:00
// display system metric usage
barGraph.AddBar("cpu", 80, tcell.ColorBlue)
2021-12-19 19:06:37 +11:00
barGraph.AddBar("mem", 20, tcell.ColorRed)
2021-12-19 18:39:14 +11:00
barGraph.AddBar("swap", 40, tcell.ColorGreen)
2021-12-19 19:06:37 +11:00
barGraph.AddBar("disk", 40, tcell.ColorOrange)
2021-12-19 18:39:14 +11:00
barGraph.SetMaxValue(100)
barGraph.SetAxesColor(tcell.ColorAntiqueWhite)
barGraph.SetAxesLabelColor(tcell.ColorAntiqueWhite)
2021-12-19 19:06:37 +11:00
2021-12-19 18:39:14 +11:00
if err := app.SetRoot(barGraph, false).EnableMouse(true).Run(); err != nil {
panic(err)
}
}