Navid Yaghoobi a187d4ddc6 barchart - allow to set axes line and label color
Signed-off-by: Navid Yaghoobi <navidys@fedoraproject.org>
2022-12-24 12:21:58 +11:00

29 lines
783 B
Go

// 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)
}
}