-
Notifications
You must be signed in to change notification settings - Fork 0
/
widgets.go
77 lines (61 loc) · 1.75 KB
/
widgets.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"github.com/gizak/termui"
)
const (
gaugeHeight = 3
yAxisWidth = 15
)
func newPar(label string) *termui.Par {
par := termui.NewPar("N/A")
par.BorderLabel = label
par.BorderFg = termui.ColorWhite
par.BorderLabelFg = termui.ColorYellow
par.Height = gaugeHeight
par.PaddingLeft = 10
return par
}
func newGauge(label string) *termui.Gauge {
gauge := termui.NewGauge()
gauge.BarColor = termui.ColorRed
gauge.Border = true
gauge.BorderLabel = label
gauge.BorderLabelFg = termui.ColorYellow
gauge.Height = gaugeHeight
gauge.LabelAlign = termui.AlignCenter
gauge.PaddingLeft = 1
gauge.PaddingRight = 1
gauge.Percent = 0
gauge.PercentColorHighlighted = termui.AttrBold
return gauge
}
func newLineChart(label string) *termui.LineChart {
height := (termui.TermHeight() - gaugeHeight) / 3
width := termui.TermWidth() - yAxisWidth
lineChart := termui.NewLineChart()
lineChart.AxesColor = termui.ColorWhite
lineChart.BorderLabel = label
lineChart.BorderLabelFg = termui.ColorYellow
lineChart.Data = make([]float64, width)
lineChart.DataLabels = make([]string, width)
lineChart.Height = height
lineChart.LineColor = termui.ColorYellow | termui.AttrBold
lineChart.Mode = "dot"
return lineChart
}
func newBarChart(label string, dataLabels []string) *termui.BarChart {
height := (termui.TermHeight() - gaugeHeight) / 3
width := termui.TermWidth() / 2
bc := termui.NewBarChart()
bc.BarColor = termui.ColorBlue
bc.BarWidth = (width/len(dataLabels) - len(dataLabels))
bc.BorderLabel = label
bc.BorderLabelFg = termui.ColorYellow
bc.Data = make([]int, len(dataLabels))
bc.DataLabels = dataLabels
bc.Height = height
bc.NumColor = termui.ColorWhite | termui.AttrBold
bc.PaddingLeft = 1
bc.TextColor = termui.ColorWhite
return bc
}