sampler-fork/config/default.go

47 lines
848 B
Go
Raw Normal View History

2019-02-01 00:02:34 +00:00
package config
import (
2019-02-02 14:45:53 +00:00
"github.com/sqshq/sampler/console"
)
2019-02-01 00:02:34 +00:00
const (
defaultRefreshRateMs = 300
2019-02-04 04:03:59 +00:00
defaultPrecision = 1
defaultTheme = console.ThemeDark
2019-02-01 00:02:34 +00:00
)
func (self *Config) setDefaultValues() {
if len(self.Theme) == 0 {
self.Theme = defaultTheme
}
for i, chart := range self.RunCharts {
if chart.RefreshRateMs == 0 {
chart.RefreshRateMs = defaultRefreshRateMs
}
2019-02-04 04:03:59 +00:00
if chart.Precision == 0 {
chart.Precision = defaultPrecision
}
2019-02-01 00:02:34 +00:00
self.RunCharts[i] = chart
}
}
func (config *Config) setDefaultLayout() {
}
func (config *Config) setDefaultColors() {
palette := console.GetPalette(config.Theme)
2019-02-01 00:02:34 +00:00
for i, chart := range config.RunCharts {
for j, item := range chart.Items {
if item.Color == 0 {
item.Color = palette.Colors[i+j] // TODO handle out of range case
2019-02-01 00:02:34 +00:00
chart.Items[j] = item
}
}
}
}