WIP components (as built)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 15:43:43 -04:00
1 parent c236ea7ece
commit 33e924f2b1
98 files changed
+2746 -1204

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
package mujica
import (
"github.com/egoist/mygo/ui"
"math"
)
// SparkBarOptions configure a SparkBar; Frame.Height 0 means 28 DIPs.
type SparkBarOptions struct {
Frame ChartFrame
// BarWidth defaults to 6 DIPs; width fits the window.
BarWidth float32
Format func(v float64) string
}
// SparkBar draws signed inline bars and highlights the last.
func SparkBar(c *ui.Context, values []float64, opts SparkBarOptions) ChartResult {
if opts.BarWidth < 0 || math.IsNaN(float64(opts.BarWidth)) || math.IsInf(float64(opts.BarWidth), 0) {
panic("mujica: SparkBar BarWidth must be ≥ 0")
}
bw := opts.BarWidth
if bw == 0 {
bw = 6
}
w, _ := c.Size()
frame := opts.Frame
if frame.Empty == "" {
frame.Empty = msg(c, "spark_bar.empty")
}
return Sparkline(c, values, SparklineOptions{Frame: frame, Kind: SparklineBar, Width: min(max(28, float32(len(values))*(bw+1)+6), max(28, w-48)), Format: opts.Format})
}