import { type ReactElement } from 'react'; import { type StylingProps, type MaskingProps, type DataTestId } from '@dynatrace/strato-components/core'; import type { TruncationMode } from '@dynatrace/strato-components/typography'; import type { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units'; import type { ColorPalette, CustomColorPalette } from '../../core/types/color-palette.js'; import type { ColoredRange } from '../../core/types/colored-range.js'; import type { Formatter } from '../../core/types/formatter.js'; /** * @public */ export interface TreeMapLeafNode { name: string; value: number; } /** * @internal */ export interface TreeMapSeriesActionsLeafNode extends TreeMapLeafNode { id: string; } /** * @public */ export interface TreeMapClusterNode extends TreeMapLeafNode { nodes?: Array; } /** * @public */ export interface TreeMapRootNode extends Omit { nodes: Array; name?: string; } /** * Show/hide label on TreeMap nodes and clusters * * @defaultValue 'none' * @public */ export type LabelsDisplay = 'none' | 'nodes' | 'clusters' | 'all'; /** * @public */ export interface TreeMapData { /** The tree root node. */ tree: TreeMapRootNode; /** Optional unit to use for the tooltip. */ unit?: string; } /** * Data accessor on leaf nodes by which legend can be defined * * @defaultValue undefined * @deprecated - Will be removed, use `NameAccessor` instead. * @public */ export type ValueAccessor = 'name' | 'value'; /** * Data accessor on leaf nodes by which legend can be defined * * @defaultValue undefined * @public */ export type NameAccessor = 'name' | 'value'; /** * @public */ export interface TreeMapProps extends StylingProps, MaskingProps, DataTestId { /** The tree map data to display. */ data: TreeMapData; /** * Optional width of the chart. * * @defaultValue 100% */ width?: number; /** * Optional height of the chart. * * @defaultValue 400 */ height?: string | number; /** * Color palette to use for coloring the tree nodes. Nodes of height 1 * get a color assigned from the palette. * @defaultValue 'categorical' */ colorPalette?: ColorPalette | CustomColorPalette | ColoredRange[]; /** * Custom value formatter for the chart. */ formatter?: Formatter | FormatOptions; /** * The text truncation mode used for the chart legend. * * @defaultValue 'middle' */ truncationMode?: TruncationMode; /** * Show the loading indicator. * * @defaultValue false */ loading?: boolean; /** * Show/hide label on TreeMap nodes and clusters * * @defaultValue 'none' */ labelsDisplay?: LabelsDisplay; /** Exposed callback to display series actions for a node */ seriesActions?: (node: TreeMapLeafNode) => ReactElement; /** * Data accessor on leaf nodes by which legend can be defined * * @defaultValue undefined * @deprecated - Will be removed, use `nameAccessor` instead. */ valueAccessor?: ValueAccessor; /** * Data accessor on leaf nodes by which legend can be defined * * @defaultValue undefined */ nameAccessor?: NameAccessor; /** The min value configuration to display */ min?: 'data-min' | number; /** The max value configuration to display */ max?: 'data-max' | number; } /** * Ref for the treemap chart * @public */ export interface TreeMapElementRef { /** The TreeMap root element */ readonly element: HTMLDivElement | null; /** Returns the current serialized config of the TreeMap.*/ getConfig: () => string; /** Downloads TreeMap chart csv data .*/ downloadData: () => void; }