Treemap.

PRO

Represent hierarchical sizes as rectangle areas.

Live preview25 feature examples

LIVE EXAMPLE

Product composition

Match the page theme
Interact with the chart to see selection and range-change results here.
OptionsChanges are reflected in the preview and code.
Appearance and style5
Legend and interaction11
Title and dimensions3

Represent hierarchy leaf values as rectangle areas. All values are sample data.

View code
Current preview
<div id="chart-container" style="width: 100%; min-width: 0;"></div>

<script type="module">
  import { defineCustomElement as define0 } from '@syidax/advanced-pro/components/sy-treemap.js';
  define0();

  // Pro: complete registerLicense at app startup using your issued certificate.
  // The website preview certificate is not for use in customer apps.
  const specs = [
    {
      "id": "example-chart",
      "tag": "sy-treemap",
      "props": {
        "data": [
          {
            "id": "all",
            "label": "All",
            "children": [
              {
                "id": "platform",
                "label": "Platform",
                "color": "#8263d9",
                "children": [
                  {
                    "id": "web",
                    "label": "Web",
                    "value": 42
                  },
                  {
                    "id": "mobile",
                    "label": "Mobile",
                    "value": 28
                  }
                ]
              },
              {
                "id": "service",
                "label": "Services",
                "color": "#239c91",
                "children": [
                  {
                    "id": "consult",
                    "label": "Consulting",
                    "value": 18
                  },
                  {
                    "id": "support",
                    "label": "Support",
                    "value": 12
                  }
                ]
              }
            ]
          }
        ],
        "width": 640,
        "height": 360,
        "brandPosition": "bottom-right",
        "brandLogo": ""
      }
    }
  ];
  const container = document.querySelector('#chart-container');
  const elements = specs.map(({ tag, id, props }) => {
    const element = document.createElement(tag);
    element.id = id;
    Object.assign(element, props);
    element.setAttribute('aria-label', 'treemap example chart');
    return element;
  });
  container.replaceChildren(...elements);
  const chart = elements.at(-1);
  const onEvent = event => {
    console.log('nodeClick', event.detail);
  };
  chart.addEventListener('nodeClick', onEvent);
  const observer = new ResizeObserver(([entry]) => {
    const width = Math.max(160, Math.floor(entry.contentRect.width));
    elements.forEach(element => { element.width = width; });
  });
  observer.observe(container);

  // In an SPA, call this function when the view is disposed.
  function disposeChart() {
    observer.disconnect();
    chart.removeEventListener('nodeClick', onEvent);
    container.replaceChildren();
  }
</script>

Usage and data

#

Explore part-to-whole proportions, such as product composition or storage usage.

Labels may be omitted in small areas. Use drilldown and a data table to inspect details.

Data contract

PropertyInput format
dataAn array of nodes as { id, label?, value?, children? }. Branch values are calculated from their children.

Updating data

Assign a new array or object to the property instead of mutating values inside an array. Chart events provide selection results through event.detail. When disposing of the view, clean up ResizeObserver and event listeners registered by your app.

Add to your interface

#

The code tabs below the preview contain the full data, options, event bindings, and responsive sizing for the current example. Copy them into an app project, such as Vite, that can resolve the installed packages.

Shared sy-chart API versus direct tags

API reference

#

The full public API for sy-treemap. Pass objects and arrays as JavaScript properties. Select a name to view usage code and type definitions.

Key properties

Attribute / PropertyType / DefaultDescription
TreemapDataDefault: undefinedAn array of nodes as { id, label?, value?, children? }. Branch values are calculated from their children.
numberDefault: 900Chart width in pixels. Update with ResizeObserver when the container changes.
numberDefault: 400Chart height in pixels.
brandLogostringDefault: undefinedThe default is the Syidax logo. With the Pro chart.branding entitlement, use none or a PNG, JPEG, or WebP data URL.
brandPosition'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'Default: 'bottom-right'The corner where the logo is anchored. Applies equally to Community and Pro, on screen and in image exports.
numberDefault: 3Inner spacing of each branch, in CSS pixels.
booleanDefault: falseEnable branch navigation, breadcrumb controls and Alt+Enter / Backspace shortcuts.
headerHeightnumberDefault: 18Reserved header band inside each branch, in CSS pixels.
nodeLabelsTreemapLabelModeDefault: 'auto'Allowed values: auto, show, hide. Default: 'auto'.
nodeLabelValuebooleanDefault: falseSet as an HTML attribute or JavaScript property. type: boolean.
chartTitlestringDefault: undefinedThe title inside the chart. Explain the data's unit and meaning alongside it.
chartSubtitlestringDefault: undefinedThe subtitle inside the chart.
CartesianTooltipInputDefault: undefinedTooltip settings for pointer-driven values, position, and content.
tooltipEnabledbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
animatedbooleanDefault: falseWhether to animate initial display and data changes.
animationDurationnumberDefault: 600Animation duration in milliseconds.
animationEasingTreemapEasingDefault: 'ease-out'Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'.
animationTypeTreemapAnimationTypeDefault: undefinedAllowed values: initial, update. Default: undefined.
CartesianZoomInputDefault: undefinedSettings for zooming and the visible range.
Other properties 9
Attribute / PropertyType / DefaultDescription
stringDefault: 'auto'Set as an HTML attribute or JavaScript property. type: string.
activeColorstringDefault: '#f59e0b'Set as an HTML attribute or JavaScript property. type: string.
enableMouseTrackingbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
tooltipFormat(detail: TreemapHitDetail) => stringDefault: undefinedPass as a JavaScript property. type: (detail: TreemapHitDetail) => string.
streamSourceTreemapStreamSourceDefault: undefinedA stream source for live data. Check the contract for the specific type.
streamMaxnumberDefault: undefinedThe maximum number of streaming data points to retain.
streamWindownumberDefault: undefinedThe streaming data range to keep visible.
TreemapEngineModeDefault: 'auto'Renderer selection: auto, standard, or pro. Engine selection is separate from permission to use a Pro chart type.
TreemapUnavailableBehaviourDefault: 'fallback'Allowed values: fallback, error. Default: 'fallback'.
Events 15
EventsDetail typeDescription
TreemapRenderResult & { tier: TreemapEngineTier }Emits rendering results in detail when chart drawing completes.
TreemapHitDetailCustomEvent.detail type: TreemapHitDetail. Event names are case-sensitive.
TreemapHitDetail | nullCustomEvent.detail type: TreemapHitDetail | null. Event names are case-sensitive.
TreemapSelectionChangeEventDetailCustomEvent.detail type: TreemapSelectionChangeEventDetail. Event names are case-sensitive.
ChartPointContextMenuEventDetail<TreemapHitDetail>CustomEvent.detail type: ChartPointContextMenuEventDetail<TreemapHitDetail>. Event names are case-sensitive.
{ count: number; replaced: number }CustomEvent.detail type: { count: number; replaced: number }. Event names are case-sensitive.
{ dropped: number }CustomEvent.detail type: { dropped: number }. Event names are case-sensitive.
CartesianTooltipEventDetailWhether to display the built-in tooltip.
voidCustomEvent.detail type: void. Event names are case-sensitive.
CartesianTooltipActionEventDetailCustomEvent.detail type: CartesianTooltipActionEventDetail. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
CartesianZoomChangeEventDetailCustomEvent.detail type: CartesianZoomChangeEventDetail. Event names are case-sensitive.
TreemapDrillChangeEventDetailCustomEvent.detail type: TreemapDrillChangeEventDetail. Event names are case-sensitive.
Methods 39

Stencil methods return Promises. Use await within an async function to read the result.

Method / ArgumentsReturn typeDescription
Promise<TreemapRenderResult>An asynchronous method. Check the argument and return types below.
Promise<TreemapEngineTier>An asynchronous method. Check the argument and return types below.
Promise<string | undefined>An asynchronous method. Check the argument and return types below.
data: TreemapDataPromise<void>An asynchronous method. Check the argument and return types below.
Promise<TreemapNode[]>An asynchronous method. Check the argument and return types below.
index: numberPromise<TreemapNode | null>An asynchronous method. Check the argument and return types below.
id: stringPromise<TreemapNode | null>An asynchronous method. Check the argument and return types below.
Promise<number>An asynchronous method. Check the argument and return types below.
Promise<TreemapExtent>An asynchronous method. Check the argument and return types below.
Promise<TreemapLayoutResult>The layout as shown (the frozen view while frozen); without a valid license it is refused and nothing is computed.
node: TreemapNodeInputPromise<void>An asynchronous method. Check the argument and return types below.
nodes: ReadonlyArray<TreemapNodeInput>Promise<void>An asynchronous method. Check the argument and return types below.
count: numberPromise<void>An asynchronous method. Check the argument and return types below.
nodes: ReadonlyArray<TreemapNodeInput>Promise<void>An asynchronous method. Check the argument and return types below.
Promise<ChartEngineStatus>Requested vs effective engine and why (CHART-ADD-08), with the chart.type.treemap license state.
Promise<TreemapStreamSource | undefined>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
options: { enabled?: boolean; duration?: number; easing?: TreemapEasing; type?: TreemapAnimationType }Promise<void>An asynchronous method. Check the argument and return types below.
cssX: number, cssY: numberPromise<TreemapHitDetail | null>An asynchronous method. Check the argument and return types below.
index: numberPromise<TreemapHitDetail | null>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
Promise<TreemapSelection>An asynchronous method. Check the argument and return types below.
rootId: string | nullPromise<TreemapDrillChangeEventDetail | null>Enter a positive branch by stable ID; null returns to the complete forest. Requires drilldown.
nodeIndex: numberPromise<TreemapDrillChangeEventDetail | null>Enter a positive branch by its normalized data index. Requires drilldown.
Promise<TreemapDrillChangeEventDetail | null>Return to the current branch's parent, then the forest.
Promise<TreemapNode | null>An asynchronous method. Check the argument and return types below.
index: numberPromise<CartesianTooltipEventDetail | null>An asynchronous method. Check the argument and return types below.
index: numberPromise<CartesianTooltipEventDetail | null>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
request: CartesianZoomRequestPromise<CartesianZoomChangeEventDetail | null>Zoom to explicit windows over the unit extents: `x` / `y` as `{ min, max }` or `[min, max]` (`null` clears that orientation).
factor: number, anchorFraction?: numberPromise<CartesianZoomChangeEventDetail | null>Scale the current windows by `factor` (< 1 zooms in) around `anchorFraction` (0..1, default centre).
delta: { x?: number; y?: number }Promise<CartesianZoomChangeEventDetail | null>Slide the zoomed windows by unit-extent units (`{ x?, y? }`); a no-op at the full extent.
Promise<CartesianZoomChangeEventDetail | null>Back to the full diagram.
Promise<CartesianZoomState | null>The current zoom state (`null` = the full diagram).
request?: CartesianZoomExtentRequestPromise<CartesianZoomExtentDetail | null>The full extent (0 … 1) and key of the diagram's orientations (`null` before the first layout).
Promise<ChartDataTable>An asynchronous method. Check the argument and return types below.
Promise<TreemapLabel[]>The labels as shown (the frozen view while frozen); without a valid license they are refused and nothing is computed.