Treemap

Explore and open details

Select a region, open its detail and navigate back through the same data hierarchy.

Drilldown example

Explore the regionsSelect North and open its detail.40406060RegionsRegionsNorthNorthSouthSouth

Configuration

Adjust chart height at every drilldown level.

Example code

Copy the example with its current settings.

JS/TS · TypeScript
import { ChartToolbarAction, ChartToolbarPosition } from '@neural-charts/web';
import { createChartDrilldown, type ChartDrilldownData, type ChartDrilldownOptions } from '@neural-charts/web/drilldown';

const data: ChartDrilldownData = {
  "rootId": "regions",
  "nodes": [
    {
      "id": "regions",
      "data": {
        "type": "treemap",
        "root": {
          "id": "regions",
          "label": "Regions",
          "children": [
            {
              "id": "north",
              "label": "North",
              "value": 40
            },
            {
              "id": "south",
              "label": "South",
              "value": 60
            }
          ]
        }
      }
    },
    {
      "id": "north",
      "data": {
        "type": "column",
        "axes": {
          "x": {
            "type": "category",
            "values": [
              {
                "id": "a",
                "label": "A"
              },
              {
                "id": "b",
                "label": "B"
              },
              {
                "id": "c",
                "label": "C"
              }
            ]
          },
          "y": {
            "type": "linear"
          }
        },
        "series": [
          {
            "id": "orders",
            "name": "Orders",
            "data": [
              {
                "id": "a",
                "x": "a",
                "y": 0
              },
              {
                "id": "b",
                "x": "b",
                "y": 10
              },
              {
                "id": "c",
                "x": "c",
                "y": 30
              }
            ]
          }
        ]
      }
    },
    {
      "id": "channel",
      "data": {
        "type": "donut",
        "data": [
          {
            "id": "online",
            "label": "Online",
            "value": 12
          },
          {
            "id": "store",
            "label": "Store",
            "value": 18
          }
        ]
      }
    }
  ],
  "links": [
    {
      "fromNodeId": "regions",
      "datumId": {
        "seriesId": "north",
        "pointId": "north"
      },
      "toNodeId": "north"
    },
    {
      "fromNodeId": "north",
      "datumId": {
        "seriesId": "orders",
        "pointId": "c"
      },
      "toNodeId": "channel"
    }
  ]
};
const options: ChartDrilldownOptions = {
  chart: {
    "animation": {
      "enabled": true
    },
    "locale": "en",
    "theme": "light",
    toolbar: {
      actions: [ChartToolbarAction.Csv, ChartToolbarAction.Png, ChartToolbarAction.Svg],
      position: ChartToolbarPosition.Top,
    }
  },
  "nodes": {
    "regions": {
      "title": "Explore the regions",
      "description": "Select North and open its detail.",
      "height": 220,
      "appearance": {
        "colors": [
          "#2C6DCD",
          "#638A35",
          "#638A35"
        ],
        "dataLabels": true
      }
    },
    "north": {
      "title": "North · original breakdown",
      "description": "A: 0 · B: 10 · C: 30. Open C to see the channels.",
      "height": 220,
      "unit": "orders",
      "legend": {
        "position": "bottom"
      },
      "viewport": {
        "axes": "x",
        "controls": true
      },
      "appearance": {}
    },
    "channel": {
      "title": "C · channels",
      "height": 220,
      "unit": "orders",
      "legend": {
        "position": "bottom"
      },
      "appearance": {}
    }
  }
};
const host = document.createElement('div');
document.body.append(host);
const result = createChartDrilldown(host, data, options, { instanceId: 'regional-orders' });
if (result.status === 'invalid') throw new Error(result.diagnostic.message);
export function dispose() { result.value.destroy(); host.remove(); }

Data, options and events

Links use original IDs. Select a point and open its detail. Going back restores the previous view.

ChartDrilldownData

ChartDrilldownOptions

ChartDrilldownMountOptions