import type { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units'; import type { BehaviorTrackingProps } from '../../../core/types/behavior-tracking-props.js'; import { DataTestId } from '../../../core/types/data-props.js'; import { MaskingProps } from '../../../core/types/masking-props.js'; import { StylingProps } from '../../../core/types/styling-props.js'; import type { TruncationMode } from '../../../typography/text-ellipsis/TextEllipsis.js'; 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'; import type { SeriesActionsTemplate } from '../../core/types/series-actions-template.js'; /** * @public */ export interface TreeMapLeafNode extends Record { name: string; value: number; } /** * @internal */ export interface TreeMapSeriesActionsLeafNode extends Pick { id: string; } /** * @public */ export interface TreeMapClusterNode extends Pick { nodes?: Array; } /** * @public */ export interface TreeMapRootNode extends Pick { nodes: Array; name?: string; } /** * Show/hide label on TreeMap nodes and clusters * * @defaultValue 'none' * @public */ export type LabelsDisplay = 'none' | 'nodes' | 'clusters' | 'all' | 'clusters-and-values'; /** * @public */ export interface TreeMapData { /** The tree root node. */ tree: TreeMapRootNode; /** Optional unit to use for the tooltip. */ unit?: string | Unit; } /** * 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, BehaviorTrackingProps { /** The tree map data to display. */ data: TreeMapData; /** * Optional width of the chart. * * @defaultValue 100% */ width?: string | 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; /** Optional unit for value formatting. Takes priority over data.unit */ unit?: string | Unit; /** * 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) => SeriesActionsTemplate; /** * 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; }