) : (
)}
)
}
export function PieWidget(p: WidgetRenderProps) {
return
}
export function DonutWidget(p: WidgetRenderProps) {
return
}
// --- list (top-N with proportion bars) ------------------------------------
export function ListWidget(p: WidgetRenderProps) {
const ctx = fmtCtx(p.spec, p.locale, p.currency)
const a = accentClasses(p.spec.accent)
const series = p.data?.series ?? []
const max = series.reduce((m, s) => Math.max(m, s.value), 0) || 1
return (
{series.length > 0 ? (
{series.map((pt) => (
{pt.label}
{formatWidgetValue(pt.value, ctx)}
))}
) : (
)}
)
}
// --- progress -------------------------------------------------------------
// A scalar rendered as a proportion bar. When `format:'percent'` the value is
// a fraction in [0,1]; otherwise it's shown as the big number with a full bar.
export function ProgressWidget(p: WidgetRenderProps) {
const ctx = fmtCtx(p.spec, p.locale, p.currency)
const a = accentClasses(p.spec.accent)
const value = p.data?.value
const hasValue = typeof value === 'number' && !Number.isNaN(value)
const pct =
p.spec.format === 'percent'
? Math.min(100, Math.max(0, (value ?? 0) * 100))
: 100
return (
{hasValue ? (