mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-27 13:48:49 +08:00
Undo the experiments in the LineChart demo.
This commit is contained in:
parent
38ec4a9e1b
commit
5b89dbc1a0
@ -44,23 +44,13 @@ func sineInputs() []float64 {
|
||||
// playLineChart continuously adds values to the LineChart, once every delay.
|
||||
// Exits when the context expires.
|
||||
func playLineChart(ctx context.Context, lc *linechart.LineChart, delay time.Duration) {
|
||||
//inputs := sineInputs()
|
||||
var inputs []float64
|
||||
inputs := sineInputs()
|
||||
ticker := time.NewTicker(delay)
|
||||
defer ticker.Stop()
|
||||
for i := 0; ; {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
//i = (i + 1) % len(inputs)
|
||||
inputs = append(inputs, float64(i%30))
|
||||
if err := lc.Series("first", inputs,
|
||||
linechart.SeriesCellOpts(cell.FgColor(cell.ColorBlue)),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
i++
|
||||
|
||||
/*
|
||||
i = (i + 1) % len(inputs)
|
||||
rotated := append(inputs[i:], inputs[:i]...)
|
||||
if err := lc.Series("first", rotated,
|
||||
linechart.SeriesCellOpts(cell.FgColor(cell.ColorBlue)),
|
||||
@ -75,7 +65,7 @@ func playLineChart(ctx context.Context, lc *linechart.LineChart, delay time.Dura
|
||||
rotated2 := append(inputs[i2:], inputs[:i2]...)
|
||||
if err := lc.Series("second", rotated2, linechart.SeriesCellOpts(cell.FgColor(cell.ColorWhite))); err != nil {
|
||||
panic(err)
|
||||
}*/
|
||||
}
|
||||
|
||||
case <-ctx.Done():
|
||||
return
|
||||
@ -96,12 +86,11 @@ func main() {
|
||||
linechart.AxesCellOpts(cell.FgColor(cell.ColorRed)),
|
||||
linechart.YLabelCellOpts(cell.FgColor(cell.ColorGreen)),
|
||||
linechart.XLabelCellOpts(cell.FgColor(cell.ColorCyan)),
|
||||
//linechart.XAxisUnscaled(),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go playLineChart(ctx, lc, redrawInterval/10)
|
||||
go playLineChart(ctx, lc, redrawInterval/3)
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.Border(draw.LineStyleLight),
|
||||
|
Loading…
x
Reference in New Issue
Block a user