package ui import ( "log" ui "github.com/gizak/termui/v3" "github.com/gizak/termui/v3/widgets" ) type Position struct { X int Y int Width int Height int } func InitDashBoard() { if err := ui.Init(); err != nil { log.Fatalf("failed to initialize termui: %v", err) } } func DrawDashBoard() { defer ui.Close() uiEvents := ui.PollEvents() for { e := <-uiEvents switch e.ID { case "q", "": return } } } func LineChart(title string, position Position, data []float64) { lineData1 := func() [][]float64 { d := make([][]float64, 2) d[0] = data d[1] = data return d }() p0 := widgets.NewPlot() p0.Title = title p0.Data = lineData1 p0.SetRect(position.X, position.Y, position.Width, position.Height) p0.AxesColor = ui.ColorWhite p0.LineColors[0] = ui.ColorGreen ui.Render(p0) } func ListChart(title string, position Position, list []string) { l := widgets.NewList() l.Title = title l.Rows = list // l.SelectedRowStyle = ui.NewStyle(ui.ColorClear) l.TextStyle = ui.NewStyle(ui.ColorClear) l.WrapText = false l.SetRect(position.X, position.Y, position.Width, position.Height) ui.Render(l) }