gauge component enhancements

This commit is contained in:
sqshq 2019-02-26 23:23:56 -05:00
parent 7b22a083a4
commit c8c63a4bfb
7 changed files with 54 additions and 33 deletions

View File

@ -89,7 +89,7 @@ func (b *BarChart) reselectMaxValue() {
func (b *BarChart) Draw(buf *ui.Buffer) { func (b *BarChart) Draw(buf *ui.Buffer) {
b.Block.Draw(buf) b.Block.Draw(buf)
barWidth := (b.Inner.Dx() - 2*barIndent - len(b.bars)) / len(b.bars) barWidth := (b.Inner.Dx() - 2*barIndent) / len(b.bars)
barXCoordinate := b.Inner.Min.X + barIndent barXCoordinate := b.Inner.Min.X + barIndent
labelStyle := ui.NewStyle(console.ColorWhite) labelStyle := ui.NewStyle(console.ColorWhite)

View File

@ -60,7 +60,7 @@ func (g *Gauge) Draw(buf *ui.Buffer) {
g.Block.Draw(buf) g.Block.Draw(buf)
percent := 0.0 percent := 0.0
if g.curValue != 0 { if g.curValue != 0 && g.maxValue != g.minValue {
percent = (100 * g.curValue) / (g.maxValue - g.minValue) percent = (100 * g.curValue) / (g.maxValue - g.minValue)
} }

View File

@ -30,7 +30,7 @@ const (
const ( const (
columnsCount = 80 columnsCount = 80
rowsCount = 60 rowsCount = 55
statusbarHeight = 1 statusbarHeight = 1
) )

View File

@ -4,8 +4,8 @@ runcharts:
w: 0 w: 0
h: 0 h: 0
size: size:
w: 40 w: 53
h: 18 h: 22
scale: 3 scale: 3
items: items:
- label: GOOGLE - label: GOOGLE
@ -17,11 +17,11 @@ runcharts:
- title: SEARCH ENGINE RESPONSE TIME 2 (sec) - title: SEARCH ENGINE RESPONSE TIME 2 (sec)
refresh-rate-ms: 5000 refresh-rate-ms: 5000
position: position:
w: 40 w: 53
h: 0 h: 0
size: size:
w: 20 w: 27
h: 18 h: 22
legend: legend:
enabled: true enabled: true
details: false details: false
@ -34,11 +34,11 @@ runcharts:
value: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com value: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
- title: MONGO COLLECTIONS COUNT - title: MONGO COLLECTIONS COUNT
position: position:
w: 21 w: 26
h: 18 h: 23
size: size:
w: 19 w: 27
h: 13 h: 17
scale: 0 scale: 0
items: items:
- label: ACTIVE - label: ACTIVE
@ -50,10 +50,10 @@ barcharts:
refresh-rate-ms: 1000 refresh-rate-ms: 1000
position: position:
w: 0 w: 0
h: 18 h: 23
size: size:
w: 21 w: 26
h: 13 h: 17
scale: 0 scale: 0
items: items:
- label: NEW - label: NEW
@ -67,33 +67,54 @@ barcharts:
- label: FINISHED - label: FINISHED
value: mongo --quiet --host=localhost blog --eval "db.getCollection('posts').find({status:'INACTIVE'}).itcount()" value: mongo --quiet --host=localhost blog --eval "db.getCollection('posts').find({status:'INACTIVE'}).itcount()"
gauges: gauges:
- title: YEAR PROGRESS - title: YEAR PROGRESS (TODO day progress)
position: position:
w: 21 w: 0
h: 33 h: 41
size: size:
w: 20 w: 26
h: 3 h: 3
values: values:
cur: echo 245 cur: date +%j
max: echo 365 max: echo 365
min: echo 0 min: echo 0
items: [] - title: HOUR PROGRESS
position:
w: 0
h: 44
size:
w: 26
h: 3
values:
cur: date +%M
max: echo 60
min: echo 0
- title: MINUTE PROGRESS
position:
w: 0
h: 47
size:
w: 26
h: 3
values:
cur: date +%S
max: echo 60
min: echo 0
asciiboxes: asciiboxes:
- title: LOCAL TIME - title: LOCAL TIME
position: position:
w: 40 w: 53
h: 18 h: 23
size: size:
w: 20 w: 27
h: 6 h: 8
value: date +%r value: date +%r
- title: UTC TIME - title: UTC TIME
position: position:
w: 40 w: 53
h: 24 h: 31
size: size:
w: 20 w: 27
h: 7 h: 9
value: env TZ=UTC date +%r value: env TZ=UTC date +%r
font: 3d font: 3d

View File

@ -18,7 +18,7 @@ type GaugeConfig struct {
Scale *int `yaml:"scale,omitempty"` Scale *int `yaml:"scale,omitempty"`
Color *ui.Color `yaml:"color,omitempty"` Color *ui.Color `yaml:"color,omitempty"`
Values map[string]string `yaml:"values"` Values map[string]string `yaml:"values"`
Items []data.Item Items []data.Item `yaml:",omitempty"`
} }
type BarChartConfig struct { type BarChartConfig struct {

View File

@ -2,6 +2,6 @@ package console
const ( const (
SymbolSelection rune = '▲' SymbolSelection rune = '▲'
SymbolVerticalBar rune = '' SymbolVerticalBar rune = ''
SymbolShade rune = '' SymbolShade rune = ''
) )

View File

@ -9,7 +9,7 @@ import (
) )
const ( const (
refreshRateToRenderRateRatio = 0.3 refreshRateToRenderRateRatio = 0.5
) )
type Handler struct { type Handler struct {