View as Markdown

API reference: @salmonui/charts/pie-chart

PieChartPropsinterface

import type { PieChartProps } from '@salmonui/charts/pie-chart';
interface PieChartProps extends AccumulationBaseProps {
    readonly text?: Partial<PieChartText> | undefined;
    readonly series?: readonly AccumulationSeries[] | undefined;
    readonly radius?: number | string | undefined;
    readonly innerRadius?: number | string | undefined;
    readonly center?: {
        readonly x?: number | string | undefined;
        readonly y?: number | string | undefined;
    } | undefined;
    readonly startAngle?: number | undefined;
    readonly endAngle?: number | undefined;
    readonly padAngle?: number | undefined;
    readonly explode?: boolean | {
        readonly offset?: number | undefined;
        readonly all?: boolean | undefined;
    } | undefined;
    readonly explodedPoints?: readonly number[] | undefined;
    readonly defaultExplodedPoints?: readonly number[] | undefined;
    readonly onExplodedPointsChange?: ((exploded: readonly number[], event: AccumulationChangeEvent) => void) | undefined;
    readonly groupSmall?: {
        readonly threshold: number;
        readonly by?: 'value' | 'count' | undefined;
        readonly label?: string | undefined;
    } | undefined;
    readonly labels?: boolean | {
        readonly position?: PieLabelPosition | undefined;
        readonly connector?: 'line' | 'curve' | undefined;
        readonly maxWidth?: number | undefined;
    } | undefined;
    readonly centerLabel?: ReactNode | ((context: {
        readonly point: AccumulationPoint | null;
        readonly total: number;
    }) => ReactNode);
    readonly size?: 'small' | 'default' | undefined;
}
PieChartProps members (54, 38 inherited)
NameSignatureDescription
textoptionalreadonly text?: Partial<PieChartText> | undefined;

Built-in text (over the nearest LocaleProvider's pieChart entry).

seriesoptionalreadonly series?: readonly AccumulationSeries[] | undefined;

Concentric rings, inner to outer; overrides data / valueField / labelField.

radiusoptionalreadonly radius?: number | string | undefined;

Outer radius: px or a percent of the half of the shorter side ('80%'). Default '80%'.

innerRadiusoptionalreadonly innerRadius?: number | string | undefined;

Doughnut hole: px, or a percent of the radius ('50%'). Default 0.

centeroptionalreadonly center?: { readonly x?: number | string | undefined; readonly y?: number | string | undefined; } | undefined;

Center as percents of the plot ({ x: '50%', y: '50%' }) or px.

startAngleoptionalreadonly startAngle?: number | undefined;

Degrees clockwise from 12 o'clock. Default 0 and 360.

endAngleoptionalreadonly endAngle?: number | undefined;
padAngleoptionalreadonly padAngle?: number | undefined;

Gap between slices, degrees.

explodeoptionalreadonly explode?: boolean | { readonly offset?: number | undefined; readonly all?: boolean | undefined; } | undefined;

Explosion: offset px (default 10) and all; click toggles when set.

explodedPointsoptionalreadonly explodedPoints?: readonly number[] | undefined;
defaultExplodedPointsoptionalreadonly defaultExplodedPoints?: readonly number[] | undefined;
onExplodedPointsChangeoptionalreadonly onExplodedPointsChange?: ((exploded: readonly number[], event: AccumulationChangeEvent) => void) | undefined;
groupSmalloptionalreadonly groupSmall?: { readonly threshold: number; readonly by?: 'value' | 'count' | undefined; readonly label?: string | undefined; } | undefined;

Merge small slices into one "Others" slice.

labelsoptionalreadonly labels?: boolean | { readonly position?: PieLabelPosition | undefined; readonly connector?: 'line' | 'curve' | undefined; readonly maxWidth?: number | undefined; } | undefined;
centerLabeloptionalreadonly centerLabel?: ReactNode | ((context: { readonly point: AccumulationPoint | null; readonly total: number; }) => ReactNode);

Doughnut center content; a function receives the hovered or focused point (null at rest).

sizeoptionalreadonly size?: 'small' | 'default' | undefined;

small: no legend, no labels, no title (the pie sparkline).

dataoptionalinheriteddata?: readonly unknown[];

Records, or numbers (labels then default to "1", "2", ...).

valueFieldoptionalinheritedvalueField?: string;
labelFieldoptionalinheritedlabelField?: string;
colorFieldoptionalinheritedcolorField?: string;

Record field holding a data color (pointColorMapping).

paletteoptionalinheritedpalette?: readonly string[];

Data colors by point index; default the derived --salmon-chart-* palette.

patternsoptionalinheritedpatterns?: boolean;

Overlay one system fill pattern per palette slot (non-color encoding).

emptyPointsoptionalinheritedemptyPoints?: "average" | "drop" | "zero";
widthoptionalinheritedwidth?: number;
heightoptionalinheritedheight?: number;
titleoptionalinheritedtitle?: string;
subtitleoptionalinheritedsubtitle?: string;
descriptionoptionalinheriteddescription?: string;

Accessible description; default the automatic summary.

localeoptionalinheritedlocale?: string;
formatoptionalinheritedformat?: NumberFormatOptions | ((value: number) => string);
legendoptionalinheritedlegend?: boolean | AccumulationLegendOptions;
tooltipoptionalinheritedtooltip?: boolean | AccumulationTooltipOptions;
highlightoptionalinheritedhighlight?: boolean;

Dim the other points while one is hovered or focused. Default true.

selectionoptionalinheritedselection?: boolean | { readonly multiple?: boolean | undefined; };

Click and Enter select points.

hiddenPointsoptionalinheritedhiddenPoints?: readonly number[];
defaultHiddenPointsoptionalinheriteddefaultHiddenPoints?: readonly number[];
onHiddenPointsChangeoptionalinheritedonHiddenPointsChange?: ((hidden: readonly number[], event: AccumulationChangeEvent) => void);
selectedPointsoptionalinheritedselectedPoints?: readonly AccumulationPointRef[];
defaultSelectedPointsoptionalinheriteddefaultSelectedPoints?: readonly AccumulationPointRef[];
onSelectedPointsChangeoptionalinheritedonSelectedPointsChange?: ((selected: readonly AccumulationPointRef[], event: AccumulationChangeEvent) => void);
annotationsoptionalinheritedannotations?: readonly AccumulationAnnotation[];
getPointStyleoptionalinheritedgetPointStyle?: ((point: AccumulationPoint) => AccumulationPointStyle | undefined);
formatLabeloptionalinheritedformatLabel?: ((point: AccumulationPoint) => string);
onPointClickoptionalinheritedonPointClick?: ((point: AccumulationPoint, event: AccumulationChangeEvent) => void);
onPointHoveroptionalinheritedonPointHover?: ((point: AccumulationPoint | null) => void);
showDataTableoptionalinheritedshowDataTable?: boolean;

Visible accessible data table (showDataTable).

accessibleTableoptionalinheritedaccessibleTable?: boolean;

false leaves the visually hidden data table out.

renderEmptyoptionalinheritedrenderEmpty?: (() => ReactNode);
classNameoptionalinheritedclassName?: string;
styleoptionalinheritedstyle?: CSSProperties;
idoptionalinheritedid?: string;
refoptionalinheritedref?: Ref<VizInstance>;
onResizeoptionalinheritedonResize?: ((size: { readonly width: number; readonly height: number; }) => void);
animatedoptionalinheritedanimated?: boolean;

Entrance and update transitions, default true: client only (never in server markup), off under prefers-reduced-motion. The CSS is the opt-in @salmonui/charts/viz-animations.css.