@@ -489,7 +489,7 @@ func (m *instanceDetail) renderBackups() string {
489489 return " (no backup data — check `backups:read_only` scope)\n "
490490 }
491491 var b strings.Builder
492- if bks . Automatic != nil && len (bks .Automatic ) > 0 {
492+ if len (bks .Automatic ) > 0 {
493493 b .WriteString (" Automatic Backups\n " + strings .Repeat ("─" , 40 ) + "\n " )
494494 for _ , bk := range bks .Automatic {
495495 created := ""
@@ -809,68 +809,6 @@ func bucketValues(values []float64, width int) []float64 {
809809 return out
810810}
811811
812- // renderSparkline turns a series of values into a single line of unicode
813- // block characters. Width controls how many cells to render — values are
814- // bucketed if there are more samples than cells. Baseline is 0 so the
815- // height of each bar corresponds to the absolute value (not min-max scale).
816- func renderSparkline (values []float64 , width int ) string {
817- if len (values ) == 0 || width <= 0 {
818- return ""
819- }
820- // Bucket to width cells. Each cell is the mean of its bucket.
821- buckets := make ([]float64 , width )
822- if len (values ) <= width {
823- // Stretch: pad the left with zeros so the recent samples land on
824- // the right edge (most readable).
825- offset := width - len (values )
826- for i , v := range values {
827- buckets [offset + i ] = v
828- }
829- } else {
830- samplesPerCell := float64 (len (values )) / float64 (width )
831- for cell := 0 ; cell < width ; cell ++ {
832- lo := int (float64 (cell ) * samplesPerCell )
833- hi := int (float64 (cell + 1 ) * samplesPerCell )
834- if hi > len (values ) {
835- hi = len (values )
836- }
837- if lo >= hi {
838- buckets [cell ] = values [lo ]
839- continue
840- }
841- var sum float64
842- for _ , v := range values [lo :hi ] {
843- sum += v
844- }
845- buckets [cell ] = sum / float64 (hi - lo )
846- }
847- }
848- var maxV float64
849- for _ , v := range buckets {
850- if v > maxV {
851- maxV = v
852- }
853- }
854- if maxV == 0 {
855- // All zeros — render a flat baseline.
856- return strings .Repeat ("▁" , width )
857- }
858- // 8-level unicode block ramp.
859- levels := []rune {'▁' , '▂' , '▃' , '▄' , '▅' , '▆' , '▇' , '█' }
860- var b strings.Builder
861- for _ , v := range buckets {
862- idx := int ((v / maxV ) * float64 (len (levels )- 1 ))
863- if idx < 0 {
864- idx = 0
865- }
866- if idx >= len (levels ) {
867- idx = len (levels ) - 1
868- }
869- b .WriteRune (levels [idx ])
870- }
871- return b .String ()
872- }
873-
874812func stats (values []float64 ) (minV , maxV , cur , avg float64 ) {
875813 if len (values ) == 0 {
876814 return 0 , 0 , 0 , 0
0 commit comments