diff --git a/component/barchart/barchart.go b/component/barchart/barchart.go index 0e0ccda..4a7d1a8 100644 --- a/component/barchart/barchart.go +++ b/component/barchart/barchart.go @@ -89,7 +89,7 @@ func (b *BarChart) reselectMaxValue() { func (b *BarChart) Draw(buf *ui.Buffer) { b.Block.Draw(buf) - barWidth := (b.Inner.Dx() - 2*barIndent) / len(b.bars) + barWidth := int(math.Ceil(float64(b.Inner.Dx()-2*barIndent-len(b.bars)*barIndent) / float64(len(b.bars)))) barXCoordinate := b.Inner.Min.X + barIndent labelStyle := ui.NewStyle(console.ColorWhite) diff --git a/component/component.go b/component/component.go index dbd41d3..f8e5ea0 100644 --- a/component/component.go +++ b/component/component.go @@ -6,7 +6,7 @@ import ( ) const ( - minDimension = 3 + minDimension = 1 ) type Component struct { diff --git a/component/layout.go b/component/layout.go index c7ac75c..26e1d9c 100644 --- a/component/layout.go +++ b/component/layout.go @@ -5,6 +5,7 @@ import ( "github.com/sqshq/sampler/config" "github.com/sqshq/sampler/console" ui "github.com/sqshq/termui" + "math" ) type Layout struct { @@ -30,7 +31,7 @@ const ( const ( columnsCount = 80 - rowsCount = 55 + rowsCount = 40 statusbarHeight = 1 ) @@ -204,15 +205,15 @@ func (l *Layout) getSelectedComponent() *Component { func (l *Layout) Draw(buffer *ui.Buffer) { - columnWidth := float64(l.GetRect().Dx()) / columnsCount - rowHeight := float64(l.GetRect().Dy()-statusbarHeight) / rowsCount + columnWidth := float64(l.GetRect().Dx()) / float64(columnsCount) + rowHeight := float64(l.GetRect().Dy()-statusbarHeight) / float64(rowsCount) for _, component := range l.Components { - x1 := float64(component.Position.X) * columnWidth - y1 := float64(component.Position.Y) * rowHeight - x2 := x1 + float64(component.Size.X)*columnWidth - y2 := y1 + float64(component.Size.Y)*rowHeight + x1 := math.Floor(float64(component.Position.X) * columnWidth) + y1 := math.Floor(float64(component.Position.Y) * rowHeight) + x2 := x1 + math.Floor(float64(component.Size.X))*columnWidth + y2 := y1 + math.Floor(float64(component.Size.Y))*rowHeight component.Drawable.SetRect(int(x1), int(y1), int(x2), int(y2)) component.Drawable.Draw(buffer) diff --git a/config.yml b/config.yml index 828f65a..e9ec7ef 100644 --- a/config.yml +++ b/config.yml @@ -5,7 +5,7 @@ runcharts: h: 0 size: w: 53 - h: 22 + h: 16 scale: 3 items: - label: GOOGLE @@ -14,31 +14,16 @@ runcharts: value: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com - label: BING value: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com -- title: SEARCH ENGINE RESPONSE TIME 2 (sec) - refresh-rate-ms: 5000 - position: - w: 53 - h: 0 - size: - w: 27 - h: 22 - legend: - enabled: true - details: false - items: - - label: GOOGLE - value: curl -o /dev/null -s -w '%{time_total}' https://www.google.com - - label: YAHOO - value: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com - - label: BING - value: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com - title: MONGO COLLECTIONS COUNT position: - w: 26 - h: 23 + w: 53 + h: 0 size: w: 27 - h: 17 + h: 8 + legend: + enabled: true + details: false scale: 0 items: - label: ACTIVE @@ -50,10 +35,10 @@ barcharts: refresh-rate-ms: 1000 position: w: 0 - h: 23 - size: - w: 26 h: 17 + size: + w: 53 + h: 12 scale: 0 items: - label: NEW @@ -69,44 +54,44 @@ barcharts: gauges: - title: YEAR PROGRESS position: - w: 0 - h: 41 + w: 53 + h: 8 size: - w: 26 - h: 3 + w: 27 + h: 2 values: cur: date +%j max: echo 365 min: echo 0 - title: DAY PROGRESS position: - w: 0 - h: 41 + w: 53 + h: 10 size: - w: 26 - h: 3 + w: 27 + h: 2 values: cur: date +%H max: echo 24 min: echo 0 - title: HOUR PROGRESS position: - w: 0 - h: 44 + w: 53 + h: 12 size: - w: 26 - h: 3 + w: 27 + h: 2 values: cur: date +%M max: echo 60 min: echo 0 - title: MINUTE PROGRESS position: - w: 0 - h: 47 + w: 53 + h: 14 size: - w: 26 - h: 3 + w: 27 + h: 2 values: cur: date +%S max: echo 60 @@ -115,17 +100,17 @@ asciiboxes: - title: LOCAL TIME position: w: 53 - h: 23 + h: 17 size: w: 27 - h: 8 + h: 5 value: date +%r - title: UTC TIME position: w: 53 - h: 31 + h: 22 size: w: 27 - h: 9 + h: 7 value: env TZ=UTC date +%r font: 3d diff --git a/console/palette.go b/console/palette.go index d4dd638..026d459 100644 --- a/console/palette.go +++ b/console/palette.go @@ -40,9 +40,9 @@ type Palette struct { func GetPalette(theme Theme) Palette { switch theme { case ThemeDark: - return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGreen, ColorOrange, ColorCian, ColorPurple}} + return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGrey, ColorGreen, ColorOrange, ColorCian, ColorPurple}} case ThemeLight: - return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGreen, ColorOrange, ColorCian, ColorPurple}} + return Palette{Colors: []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGrey, ColorGreen, ColorOrange, ColorCian, ColorPurple}} default: panic(fmt.Sprintf("Following theme is not supported: %v", theme)) }