Chart
Time series drawn as a line or area, bound to a resource or given as points.
On this page
Props
| Prop | Type | Default | Description |
|---|---|---|---|
source | DataSource | None | Resource binding that supplies the series. Use either source or points. |
points | readonly ChartPoint[] | None | Points the page already holds, as { time, value } with time in milliseconds since the epoch |
windows | readonly ChartWindow[] | None | Time windows the viewer can choose. The first is selected. |
kind | ChartKind | "line" | Line or filled area |
exaggerate | boolean | false | Tighten the value axis so small movements fill the height |
lineWidth | number | 2 | Stroke width of the plotted line |
showValue | boolean | None | Print the latest value over the chart |
label | string | None | Accessible description of what is plotted |
scale | ChartScale | "higher-is-worse" | Which end of the value axis is bad |
referenceLine | { value: number; label?: string } | None | One fixed value to mark, such as a threshold |
referenceLines | readonly { value: number; label?: string }[] | None | Several fixed values to mark |
yRange | { min: number; max: number; unit?: string } | None | Fixed value axis range. Samples outside the range are clipped. |
Example
ts
Chart({
source: loadAverage(),
windows: [
{ label: "1 hour", secs: 3600 },
{ label: "24 hours", secs: 86400 },
],
scale: "higher-is-worse",
referenceLine: { value: 4, label: "CPU count" },
label: "Load average",
})Supporting types
ChartPoint
export interface ChartPoint {
readonly time: number;
readonly value: number;
}ChartWindow
export interface ChartWindow {
readonly label: string;
readonly secs: number;
}ChartScale
export type ChartScale = "higher-is-better" | "higher-is-worse";ChartKind
export type ChartKind = "line" | "area";