Mixins / foldkit-mixins-ui

ChartKind

interface · 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.

In the guides

Members

ChartKind.name

property · packages/mixins-ui/src/chart/kind.ts:51

readonly name: string

Written as data-kind on the chart's root and plot, for the recipe.

ChartKind.alwaysLegend

property · packages/mixins-ui/src/chart/kind.ts:53

readonly alwaysLegend?: boolean

Shows the legend even for one entry (a donut's parts); default only from two.

ChartKind.entries

property · packages/mixins-ui/src/chart/kind.ts:55

readonly entries: (data: Data) => ReadonlyArray<ChartEntry>

The legend's entries: series, or slices.

ChartKind.points

property · packages/mixins-ui/src/chart/kind.ts:57

readonly points: (data: Data) => ReadonlyArray<ChartPoint>

One per category or slice, in order.

property · packages/mixins-ui/src/chart/kind.ts:59

readonly head: (data: Data) => ReadonlyArray<string>

The data table's column heads.

ChartKind.draw

property · packages/mixins-ui/src/chart/kind.ts:61

readonly draw: <Message>(
  data: Data,
  frame: ChartFrame<Message>,
) => ReadonlyArray<Html>

The elements between the chart's heading and its status line: the legend, the plot.