Examples
Growth by day
import { LineChart } from '@kition/tessera-ui'
const days = Array.from({ length: 14 }, (_, index) => `10-${String(index + 10).padStart(2, '0')}`)
const DATA = days.flatMap((date, index) => [
{ date, metric: 'Visitors', value: Math.round(420 + Math.sin(index / 2) * 90 + index * 12) },
{ date, metric: 'Downloads', value: Math.round(120 + Math.cos(index / 3) * 30 + index * 6) },
{ date, metric: 'Sign-ups', value: Math.round(40 + Math.sin(index) * 8 + index * 2) },
])
export default function Demo() {
return <LineChart label="Growth by day" data={DATA} xField="date" yField="value" seriesField="metric" height={260} />
}Bars and a donut
import { BarChart, PieChart } from '@kition/tessera-ui'
const STAGES = [
{ stage: 'Backlog', tasks: 14 },
{ stage: 'To do', tasks: 9 },
{ stage: 'Doing', tasks: 6 },
{ stage: 'Review', tasks: 4 },
{ stage: 'Done', tasks: 21 },
]
export default function Demo() {
return (
<div style={{ display: 'grid', gridTemplateColumns: '3fr 2fr', gap: 24 }}>
<BarChart label="Tasks by stage" data={STAGES} xField="stage" yField="tasks" height={240} />
<PieChart label="Share of tasks" data={STAGES} labelField="stage" valueField="tasks" innerRadius={0.6} height={200} />
</div>
)
}Props
LineChart
Lines of one or more series over ordered categories, with a legend and a hover readout.
| Prop | Type | Default | Description |
|---|---|---|---|
datarequired | readonly T[] | — | |
xFieldrequired | keyof T & string | — | The field of each datum on the horizontal axis (categories in order of first appearance). |
yFieldrequired | keyof T & string | — | The field holding the number. |
seriesField | keyof T & string | — | The field naming the series a datum belongs to; one series without it. |
height | ChartHeight | — | |
color | string | — | The colour of a single series (the palette's first by default). |
integers | boolean | — | Counts: the axis steps only by whole numbers. |
formatX | (value: string) => string | — | |
formatY | (value: number) => string | — | |
labelrequired | string | — | The chart's accessible name. |
className | string | — | |
testId | string | — | |
dots | boolean | — | Marks each point with a dot. |
BarChart
Bars of one or more series per category, side by side, with rounded tops.
| Prop | Type | Default | Description |
|---|---|---|---|
datarequired | readonly T[] | — | |
xFieldrequired | keyof T & string | — | The field of each datum on the horizontal axis (categories in order of first appearance). |
yFieldrequired | keyof T & string | — | The field holding the number. |
seriesField | keyof T & string | — | The field naming the series a datum belongs to; one series without it. |
height | ChartHeight | — | |
color | string | — | The colour of a single series (the palette's first by default). |
integers | boolean | — | Counts: the axis steps only by whole numbers. |
formatX | (value: string) => string | — | |
formatY | (value: number) => string | — | |
labelrequired | string | — | The chart's accessible name. |
className | string | — | |
testId | string | — | |
maxBarWidth | number | — | The widest a bar draws, in px. |
PieChart
Parts of a whole as slices of a pie (or a donut), with a legend and a readout of the slice under the pointer.
| Prop | Type | Default | Description |
|---|---|---|---|
datarequired | readonly T[] | — | |
labelFieldrequired | keyof T & string | — | The field naming each slice. |
valueFieldrequired | keyof T & string | — | The field holding each slice's number. |
height | ChartHeight | 240 | |
innerRadius | number | 0 | The hole's size as a share of the radius (0.6 for a donut); a full pie by default. |
colors | readonly string[] | — | Colours for the slices, in order; the chart palette by default. |
formatValue | (value: number) => string | (value) => value.toLocaleString() | |
labelrequired | string | — | The chart's accessible name. |
className | string | — | |
testId | string | — |
Used in
1 of Kition's 16 kits use these components.
Table