View as Markdown

API reference: @salmonui/charts/tree-map

TreeMapcomponent

import { TreeMap } from '@salmonui/charts/tree-map';
function TreeMap(props: TreeMapProps): ReactNode;

Props: TreeMapProps

TreeMap props (40)
NameSignatureDescription
datareadonly data: readonly unknown[];
weightFieldoptionalreadonly weightField?: string | undefined;
childrenFieldoptionalreadonly childrenField?: string | undefined;

Hierarchical data: children of a record.

levelsoptionalreadonly levels?: readonly TreeMapLevel[] | undefined;
layoutoptionalreadonly layout?: 'squarified' | 'sliceHorizontal' | 'sliceVertical' | 'sliceAuto' | undefined;
directionoptionalreadonly direction?: 'topStart' | 'topEnd' | 'bottomStart' | 'bottomEnd' | undefined;
leavesoptionalreadonly leaves?: TreeMapLeaves | undefined;
colorFieldoptionalreadonly colorField?: string | undefined;

Data color field of a record.

colorScaleoptionalreadonly colorScale?: TreeMapColorScale | undefined;
paletteoptionalreadonly palette?: readonly string[] | undefined;

Data colors per top-level group; default the derived palette.

pathoptionalreadonly path?: TreeMapPath | undefined;
defaultPathoptionalreadonly defaultPath?: TreeMapPath | undefined;
onPathChangeoptionalreadonly onPathChange?: ((path: TreeMapPath, event: TreeMapChangeEvent) => void) | undefined;
drilloptionalreadonly drill?: 'click' | false | undefined;

Clicking a group drills into it. Default 'click'.

breadcrumbsoptionalreadonly breadcrumbs?: boolean | undefined;
showParentLevelsoptionalreadonly showParentLevels?: boolean | undefined;

Keep the ancestors of the drilled node as header bands.

selectionoptionalreadonly selection?: boolean | { readonly mode?: 'item' | 'group' | undefined; readonly multiple?: boolean | undefined; } | undefined;
selectedItemsoptionalreadonly selectedItems?: readonly TreeMapPath[] | undefined;
defaultSelectedItemsoptionalreadonly defaultSelectedItems?: readonly TreeMapPath[] | undefined;
onSelectedItemsChangeoptionalreadonly onSelectedItemsChange?: ((items: readonly TreeMapPath[], event: TreeMapChangeEvent) => void) | undefined;
highlightoptionalreadonly highlight?: boolean | undefined;

Outline the hovered item. Default true.

onItemHoveroptionalreadonly onItemHover?: ((item: TreeMapItem | null) => void) | undefined;
onItemClickoptionalreadonly onItemClick?: ((item: TreeMapItem, event: TreeMapChangeEvent) => void) | undefined;
getItemStyleoptionalreadonly getItemStyle?: ((item: TreeMapItem) => { readonly color?: string | undefined; } | undefined) | undefined;
legendoptionalreadonly legend?: boolean | { readonly mode?: 'list' | 'interactive' | undefined; readonly position?: 'top' | 'bottom' | 'start' | 'end' | undefined; readonly title?: string | undefined; } | undefined;

Legend of the top-level groups; interactive highlights a group on hover.

tooltipoptionalreadonly tooltip?: boolean | { readonly render?: ((item: TreeMapItem) => ReactNode) | undefined; } | undefined;
widthoptionalreadonly width?: number | undefined;
heightoptionalreadonly height?: number | undefined;
titleoptionalreadonly title?: string | undefined;
subtitleoptionalreadonly subtitle?: string | undefined;
descriptionoptionalreadonly description?: string | undefined;
localeoptionalreadonly locale?: string | undefined;
textoptionalreadonly text?: Partial<TreeMapText> | undefined;

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

rootLabeloptionalreadonly rootLabel?: string | undefined;

Breadcrumb root label. Default text.all ("All").

classNameoptionalreadonly className?: string | undefined;
styleoptionalreadonly style?: CSSProperties | undefined;
idoptionalreadonly id?: string | undefined;
refoptionalreadonly ref?: Ref<TreeMapApi> | undefined;
onResizeoptionalreadonly onResize?: ((size: { readonly width: number; readonly height: number; }) => void) | undefined;
animatedoptionalreadonly animated?: boolean | undefined;

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.