-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.go
28 lines (25 loc) · 783 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Demo code for the bar chart primitive.
package main
import (
"github.com/gdamore/tcell/v2"
"github.com/navidys/tvxwidgets"
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
barGraph := tvxwidgets.NewBarChart()
barGraph.SetRect(4, 2, 50, 20)
barGraph.SetBorder(true)
barGraph.SetTitle("System Resource Usage")
// display system metric usage
barGraph.AddBar("cpu", 80, tcell.ColorBlue)
barGraph.AddBar("mem", 20, tcell.ColorRed)
barGraph.AddBar("swap", 40, tcell.ColorGreen)
barGraph.AddBar("disk", 40, tcell.ColorOrange)
barGraph.SetMaxValue(100)
barGraph.SetAxesColor(tcell.ColorAntiqueWhite)
barGraph.SetAxesLabelColor(tcell.ColorAntiqueWhite)
if err := app.SetRoot(barGraph, false).EnableMouse(true).Run(); err != nil {
panic(err)
}
}