2019-02-01 00:02:34 +00:00
|
|
|
package config
|
|
|
|
|
2019-02-02 04:39:34 +00:00
|
|
|
import (
|
2019-02-02 14:45:53 +00:00
|
|
|
"github.com/sqshq/sampler/console"
|
2019-02-02 04:39:34 +00:00
|
|
|
)
|
2019-02-01 00:02:34 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
defaultRefreshRateMs = 300
|
|
|
|
defaultTimeScaleSec = 1
|
2019-02-02 04:39:34 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
if chart.TimeScaleSec == 0 {
|
|
|
|
chart.TimeScaleSec = defaultTimeScaleSec
|
|
|
|
}
|
|
|
|
self.RunCharts[i] = chart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (config *Config) setDefaultLayout() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (config *Config) setDefaultColors() {
|
|
|
|
|
2019-02-02 04:39:34 +00:00
|
|
|
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]
|
|
|
|
chart.Items[j] = item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|