2016-11-11 05:34:31 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
// Stat holds basic statistics data for
|
|
|
|
// integer data used for sparklines.
|
|
|
|
type Stat struct {
|
2016-11-14 04:29:14 +08:00
|
|
|
max int
|
|
|
|
maxStr string
|
2016-11-11 05:34:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewStat inits new Stat object.
|
|
|
|
func NewStat() *Stat {
|
2016-11-14 04:29:14 +08:00
|
|
|
return &Stat{}
|
2016-11-11 05:34:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update updates stats on each push.
|
|
|
|
func (s *Stat) Update(v IntVar) {
|
2016-11-14 04:29:14 +08:00
|
|
|
if v.Value() > s.max {
|
|
|
|
s.max = v.Value()
|
|
|
|
s.maxStr = v.String()
|
2016-11-11 05:34:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Max returns maximum recorded value.
|
2016-11-14 04:29:14 +08:00
|
|
|
func (s *Stat) Max() string {
|
|
|
|
return s.maxStr
|
2016-11-11 05:34:31 +08:00
|
|
|
}
|