View as Markdown

API reference: @salmonui/charts/tree-map

TreeMapPropsinterface

import type { TreeMapProps } from '@salmonui/charts/tree-map';
interface TreeMapProps extends TreeMapRootHandlers {
    readonly data: readonly unknown[];
    readonly weightField?: string | undefined;
    readonly childrenField?: string | undefined;
    readonly levels?: readonly TreeMapLevel[] | undefined;
    readonly layout?: 'squarified' | 'sliceHorizontal' | 'sliceVertical' | 'sliceAuto' | undefined;
    readonly direction?: 'topStart' | 'topEnd' | 'bottomStart' | 'bottomEnd' | undefined;
    readonly leaves?: TreeMapLeaves | undefined;
    readonly colorField?: string | undefined;
    readonly colorScale?: TreeMapColorScale | undefined;
    readonly palette?: readonly string[] | undefined;
    readonly path?: TreeMapPath | undefined;
    readonly defaultPath?: TreeMapPath | undefined;
    readonly onPathChange?: ((path: TreeMapPath, event: TreeMapChangeEvent) => void) | undefined;
    readonly drill?: 'click' | false | undefined;
    readonly breadcrumbs?: boolean | undefined;
    readonly showParentLevels?: boolean | undefined;
    readonly selection?: boolean | {
        readonly mode?: 'item' | 'group' | undefined;
        readonly multiple?: boolean | undefined;
    } | undefined;
    readonly selectedItems?: readonly TreeMapPath[] | undefined;
    readonly defaultSelectedItems?: readonly TreeMapPath[] | undefined;
    readonly onSelectedItemsChange?: ((items: readonly TreeMapPath[], event: TreeMapChangeEvent) => void) | undefined;
    readonly highlight?: boolean | undefined;
    readonly onItemHover?: ((item: TreeMapItem | null) => void) | undefined;
    readonly onItemClick?: ((item: TreeMapItem, event: TreeMapChangeEvent) => void) | undefined;
    readonly getItemStyle?: ((item: TreeMapItem) => {
        readonly color?: string | undefined;
    } | undefined) | undefined;
    readonly legend?: boolean | {
        readonly mode?: 'list' | 'interactive' | undefined;
        readonly position?: 'top' | 'bottom' | 'start' | 'end' | undefined;
        readonly title?: string | undefined;
    } | undefined;
    readonly tooltip?: boolean | {
        readonly render?: ((item: TreeMapItem) => ReactNode) | undefined;
    } | undefined;
    readonly width?: number | undefined;
    readonly height?: number | undefined;
    readonly title?: string | undefined;
    readonly subtitle?: string | undefined;
    readonly description?: string | undefined;
    readonly locale?: string | undefined;
    readonly text?: Partial<TreeMapText> | undefined;
    readonly rootLabel?: string | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly id?: string | undefined;
    readonly ref?: Ref<TreeMapApi> | undefined;
    readonly onResize?: ((size: {
        readonly width: number;
        readonly height: number;
    }) => void) | undefined;
    readonly animated?: boolean | undefined;
}
TreeMapProps members (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.