Chart.area
const · packages/mixins-ui/src/chart/area.ts:12
const area: ChartKind<AreaData>A line per series with the area under it filled. Pass it as a chart's kind.
Mixins / foldkit-mixins-ui
namespace · packages/mixins-ui/src/chart.ts:1
export * as Chart from './chart.js'Chart.areaconst · packages/mixins-ui/src/chart/area.ts:12
const area: ChartKind<AreaData>A line per series with the area under it filled. Pass it as a chart's kind.
Chart.AreaDatainterface · packages/mixins-ui/src/chart/area.ts:6
interface AreaData extends PathsData {
readonly stack?: boolean | undefined
}What the area reads beside what the line does.
Chart.barsconst · packages/mixins-ui/src/chart/bars.ts:16
const bars: ChartKind<BarsData>Bars: side by side per category, or stacked with stack: true. Pass it as
a chart's kind; a page that draws another kind ships none of this.
Chart.BarsDatainterface · packages/mixins-ui/src/chart/bars.ts:7
interface BarsData extends CartesianData {
readonly stack?: boolean | undefined
}What bars read beside the categories and series.
Chart.CartesianDatainterface · packages/mixins-ui/src/chart/cartesian.ts:16
interface CartesianData {
readonly categories: ReadonlyArray<string>
readonly series: ReadonlyArray<Series>
readonly categoryLabel?: string | undefined
}What the kinds over a value axis read: the categories along the bottom and the series.
Chart.ChartColortype · packages/mixins-ui/src/chart/kind.ts:7
type ChartColor = 1 | 2 | 3 | 4 | 5One of the five chart colors, chart-1 to chart-5.
Chart.ChartEntryinterface · packages/mixins-ui/src/chart/kind.ts:10
interface ChartEntry {
readonly name: string
readonly color: string
}A series or a slice as the legend lists it; color is the data-color its marks carry.
Chart.ChartFrameinterface · packages/mixins-ui/src/chart/kind.ts:26
interface ChartFrame<Message> {
readonly h: HtmlBuilder<Message>
readonly builders: SlotBuilders<typeof ChartSlots, Message>
readonly format: (value: number) => string
readonly point: Option.Option<number>
readonly points: ReadonlyArray<ChartPoint>
readonly legend: ReadonlyArray<Html>
readonly plot: SlotAttributes<Message>
readonly pointer: (at: number) => Attribute<Message>
}What a kind is given to draw with: the chart's state, words and parts.
Chart.ChartKindinterface · packages/mixins-ui/src/chart/kind.ts:49
interface ChartKind<Data> {
readonly name: string
readonly alwaysLegend?: boolean
readonly entries: (data: Data) => ReadonlyArray<ChartEntry>
readonly points: (data: Data) => ReadonlyArray<ChartPoint>
readonly head: (data: Data) => ReadonlyArray<string>
readonly draw: <Message>(
data: Data,
frame: ChartFrame<Message>,
) => ReadonlyArray<Html>
}A kind of chart: Chart.bars, Chart.line, Chart.area and Chart.donut
are values of it, and one of your own is an object with these four readers
and a draw. The chart draws the title, the status line and the data table
from entries, points and head, so a kind needs to draw only the plot.
Data is the options the kind reads beside the chart's own.
Chart.ChartOptionsinterface · packages/mixins-ui/src/chart.ts:80
interface ChartOptions<ParentMessage> {
readonly id: string
readonly label: string
readonly description?: string | undefined
readonly model: Model
readonly onMessage: (message: Message) => NoInfer<ParentMessage>
readonly format?: ((value: number) => string) | undefined
readonly legend?: boolean | undefined
readonly table?: 'hidden' | 'shown' | undefined
readonly style?: NamedStyle<typeof ChartSlots> | undefined
readonly mixins?: MixinList<ParentMessage> | undefined
}What every kind of chart is given: its name, state, words and look.
Chart.ChartPointinterface · packages/mixins-ui/src/chart/kind.ts:16
interface ChartPoint {
readonly name: string
readonly rows: ReadonlyArray<{
readonly name: string
readonly value: number
readonly color: string
}>
}What one category or slice says: the tooltip, the status line and the data table read these.
Chart.ChartSlotsconst · packages/mixins-ui/src/chart/slots.ts:19
const ChartSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly title: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly description: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly legend: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly legendItem: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly swatch: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<" …;A chart, after shadcn's over Recharts: bars, a line, an area or a donut, with a value axis whose ticks are round values the axis reaches, the categories along the bottom, gridlines, a legend, and a tooltip with every series' value at the point the pointer or the keys are on. The plot is drawn in percentages of its box, so it fills any width without measuring.
The data is the application's, and so is which point is lit: keep this
module's Model and fold the chart's Messages into it with update.
The plot takes the focus; the arrows, Home and End move through the
points, and a polite status says each one's values. The drawing is hidden
from assistive technology, which reads the same data from a table,
visually hidden unless table: 'shown'. Series take chart-1 to
chart-5 in order, as data-color on every mark; a series that a filter
may remove names its own color, so the others keep theirs.
Chart.ChartViewtype · packages/mixins-ui/src/chart.ts:107
type ChartView<ParentMessage, Data> = ChartOptions<ParentMessage> & {
readonly kind: ChartKind<Data>
} & NoInfer<Data>A chart of one kind: kind: Chart.bars with categories and series,
Chart.line, Chart.area, or Chart.donut with slices. The data's own
options are the kind's, so stack is accepted beside Chart.bars and not
beside Chart.line.
Chart.Curvetype · packages/mixins-ui/src/chart/scale.ts:66
type Curve = 'linear' | 'step'How a line joins its points: straight, or level to the next category and then up or down.
Chart.donutconst · packages/mixins-ui/src/chart/donut.ts:24
const donut = { name, alwaysLegend, entries, points, head, draw }Parts of a whole, as a ring. Pass it as a chart's kind.
Chart.DonutDatainterface · packages/mixins-ui/src/chart/donut.ts:12
interface DonutData {
readonly slices: ReadonlyArray<Slice>
readonly totalLabel?: string | undefined
readonly valueLabel?: string | undefined
readonly hole?: number | undefined
}What a donut reads: its parts, and the words around its total.
Chart.initfunction · packages/mixins-ui/src/chart.ts:46
function init(): ModelChart.lineconst · packages/mixins-ui/src/chart/line.ts:6
const line: ChartKind<PathsData>A line per series. Pass it as a chart's kind.
Chart.Messageconst · packages/mixins-ui/src/chart.ts:32
const Message: MessageUnion<{
readonly Pointed: { readonly point: Schema.Number }
readonly Left: {}
readonly Stepped: {
readonly step: Schema.Literals<
readonly ['next', 'previous', 'first', 'last']
>
readonly count: Schema.Number
}
readonly Focused: { readonly count: Schema.Number }
readonly Cleared: {}
}>Chart.Modelconst · packages/mixins-ui/src/chart.ts:21
const Model: Schema.Struct<{
readonly point: Schema.Option<Schema.Number>
readonly keyed: Schema.Boolean
}>Chart.PathsDatainterface · packages/mixins-ui/src/chart/paths.ts:8
interface PathsData extends CartesianData {
readonly curve?: Scale.Curve | undefined
readonly markers?: 'point' | 'always' | undefined
}What the line and the area read beside the categories and series.
Chart.Seriesinterface · packages/mixins-ui/src/chart/cartesian.ts:7
interface Series {
readonly name: string
readonly values: ReadonlyArray<number>
readonly color?: ChartColor | undefined
}Chart.Sliceinterface · packages/mixins-ui/src/chart/donut.ts:5
interface Slice {
readonly name: string
readonly value: number
readonly color?: ChartColor | undefined
}Chart.Stepconst · packages/mixins-ui/src/chart.ts:29
const Step: Schema.Literals<readonly ['next', 'previous', 'first', 'last']>Chart.updatefunction · packages/mixins-ui/src/chart.ts:57
function update(model: Model, message: Message): Return<Model, Message>The chart after message; the same Model when nothing changes.
Chart.viewfunction · packages/mixins-ui/src/chart.ts:135
function view<ParentMessage, Data>(
options: ChartView<ParentMessage, Data>,
h: HtmlBuilder<ParentMessage>,
): Html