Place chart points by their time, so a window's samples fill the chart's width
Five minutes at five-second steps is sixty samples on a chart a hundred and thirty dots wide, and resampling by count drew them on its right half. Points are now put in the column of their time, held across the columns between samples, a series that began late starting where it began. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e91f68a3bf
commit
0f70bdc99d
3 files changed
+109
-20
No files matched your search
@@ -3,6 +3,7 @@ package cli
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -591,3 +592,25 @@ func TestANodesPageHasItsCharts(t *testing.T) {
|
||||
t.Errorf("%s", v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAWindowsSamplesFillTheChartsWidth(t *testing.T) {
|
||||
// Five minutes at five-second steps is sixty samples; the chart is a
|
||||
// hundred and twenty dots across. Every column is drawn.
|
||||
to := time.Now()
|
||||
s := chartSeries{from: to.Add(-5 * time.Minute), to: to}
|
||||
for i := 0; i < 60; i++ {
|
||||
s.at = append(s.at, to.Add(-5*time.Minute+time.Duration(i)*5*time.Second))
|
||||
s.values = append(s.values, 50)
|
||||
}
|
||||
for c, v := range s.fit(120) {
|
||||
if math.IsNaN(v) {
|
||||
t.Fatalf("column %d of 120 empty", c)
|
||||
}
|
||||
}
|
||||
// A series that began two minutes ago fills the last two fifths only.
|
||||
s.at, s.values = s.at[36:], s.values[36:]
|
||||
got := s.fit(100)
|
||||
if !math.IsNaN(got[50]) || math.IsNaN(got[70]) || math.IsNaN(got[99]) {
|
||||
t.Errorf("a late start: %v", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user