Skip to content
peakcharts

Props and types

Every chart requires title and data. Everything else is optional.

PropTypeDefaultNotes
titlestringrequiredThe chart's accessible name.
datasee ChartsrequiredInput arrays are never mutated. Order is preserved.
descriptionstringnoneExtra context for screen readers.
heightnumber280Minimum 100.
colorstringLagoon tealPrimary series color.
colorsstring[]built-in palettePalette for pie, donut, funnel and treemap.
variant'flat' | 'pixel' | '3d''flat'See Styles.
animatebooleantrueReduced-motion preferences always win.
formatValue(value: number) => stringIntl.NumberFormatApplies to labels, captions and tables.
classNamestringnoneAdded to the chart root.

Histogram also takes bins. WaterfallChart also takes negativeColor.

TypeScript

Prop types are exported: ChartProps, CategoryChartProps, HistogramProps, ScatterChartProps, BubbleChartProps, HeatmapProps, WaterfallChartProps, plus ChartKind, ChartVariant and the datum types Datum, Point, Bubble, HeatmapCell, WaterfallDatum.

tsx
import type { Datum, ChartVariant } from 'peakcharts';

const data: Datum[] = [{ label: 'Jan', value: 32 }];
const style: ChartVariant = 'pixel';

Helpers

Three pure functions are exported for drawing your own marks: histogram, treemap and waterfall.