Appearance
Charts > Tree map
A tree map is a data visualization technique that represents hierarchical structures or nested data through nested rectangles, with each branch subdivided into smaller rectangles proportional to the values they represent.
The Chart
Download example CSV
Copy HTML
%
Playground
Style
Show percentages
Round corners of the box
Color for each area (separate with comma)
Usage Example (with tooltip)
vue
<template>
<TreeMap :data="data" class="h-full" @hover="setTooltip" />
<OTTooltip :info="tooltip">
<div>
<p class="font-semibold my-0">{{ tooltip.name }}</p>
<p class="my-0">{{ tooltip.value }}%</p>
</div>
</OTTooltip>
</template>
<script setup>
import useTooltip from "@/functions/useTooltip.js";
const [tooltip, setTooltip] = useTooltip();
</script>Component API
This chart is built using SVG and d3. It displays each category as a percentage of the total area.
Data
Data is given in hierarchical tree structure.
js
{
name: "root",
children: [
{
id: "data1",
name: "Data 1",
value: 30,
color: "#d97706"
},
...
]
};Props
| Name | Default | Type | Description |
|---|---|---|---|
data | {} | Object | The dataset |
unit | % | String | The unit to display on labels |
title | - | String | The title for ARIA label |
id | - | String | The id for ARIA label |
Events
| Event | Argument | Description |
|---|---|---|
@select | { target, data } | Emitted when box is clicked |
@hover | { target, data } | Emitted when box is hovered |
Dependencies
- d3
- number formatter from
utils/helpers.js