Files
kjol/go/webui/chart.go

38 lines
1.2 KiB
Go

package webui
import "kjol/vdom"
// Placeholder port of jsruntime/uikit/Chart.tsx.
//
// NOTE: The Solid Chart is dependency-free SVG. Its drawing is pure geometry —
// nice-scale axes, rounded columns, arc slices, a pointer-driven crosshair — none of
// which is implemented here yet. This container keeps a props shape for API parity and
// renders nothing but its box; the example app draws real charts (`app/chart.go`) as
// go-chart SVG in WebAssembly. Porting the SVG geometry to `vdom` is the obvious
// follow-up.
// Chart kinds, kept for API parity with the TSX ChartKind union. Unused by this
// placeholder container.
const (
ChartKindLine = "line"
ChartKindArea = "area"
ChartKindBar = "bar"
ChartKindPie = "pie"
ChartKindDonut = "donut"
)
// ChartProps mirrors the TSX props loosely. Series/Labels are accepted for API
// parity but are not rendered here (no SVG geometry yet; see NOTE).
type ChartProps struct {
Kind string
Labels []string
Data any
Class string
}
// Chart renders the chart container (the user's box class). Drawing is not yet
// ported — see the file NOTE.
func Chart(p ChartProps) *vdom.VNode {
return vdom.Div(vdom.Attr("class", cx("relative w-full", p.Class)))
}