Treemap
Display hierarchical data as nested rectangles with the Treemap component.
A treemap presents data hierarchically as nested rectangles. The size of each rectangle follows its measure value, so a treemap compares proportions within a hierarchy, for example, the share of product categories within each region.

Buckets
| Prop | Required | Takes | What it does |
|---|---|---|---|
measures | Yes | One or more measures | Sets the size of the rectangles. |
viewBy | No | One attribute | Draws one rectangle per attribute value. Works only with a single measure. |
segmentBy | No | One attribute | Splits each rectangle into a second level. The largest segment takes the parent’s color, and each smaller segment a lighter shade of it. |
filters | No | Filters | Limits the data the treemap shows. |
Sorting
The treemap places the rectangles at each level by size, largest first. With both viewBy and segmentBy set, it requests the data sorted by the viewBy attribute in ascending order, then by the measures in descending order, so the legend lists the viewBy values in ascending order. Treemap has no sortBy prop.
Configuration
Pass these options in the config prop. See Chart configuration for details.
| Option | What it changes |
|---|---|
colors, colorPalette, colorMapping | Colors of the top-level rectangles. With segmentBy, the largest segment takes its parent’s color and smaller segments lighter shades of it. |
legend | Whether the legend shows and where. |
dataLabels | visible shows or hides the labels. style: "backplate" adds a background behind them. |
chartFill | type sets how rectangles are filled: "solid", "pattern", or "outline". With segmentBy set, the segments stay solid. |
separators | Thousands and decimal separators in the number format. |
Limits
- A treemap can’t show negative values. If the data contains any, the chart shows an error and
onErrorreceives aNegativeValuesSdkError. - A treemap renders up to 10,000 data points. With more, the chart shows an error and
onErrorreceives aDataTooLargeToDisplaySdkError. Filter the data to fit.
Structure
import "@gooddata/sdk-ui-charts/styles/css/main.css";
import { Treemap } from "@gooddata/sdk-ui-charts";
<Treemap
measures={<measures>}
viewBy={<attribute>}
segmentBy={<attribute>}
config={<chart-config>}
…
/>
Example
import "@gooddata/sdk-ui-charts/styles/css/main.css";
import { Treemap } from "@gooddata/sdk-ui-charts";
import * as Md from "./catalog.js";
const style = { height: 300 };
<div style={style}>
<Treemap
measures={[Md.NrChecks]}
viewBy={Md.LocationState}
segmentBy={Md.LocationCity}
/>
</div>
Props
| Prop | Type | Required | Description | Inherited from |
|---|---|---|---|---|
measures | AttributesMeasuresOrPlaceholders | Yes | Specify one or more measures whose values will be used to create the treemap rectangles. | ITreemapBucketProps |
backend | IAnalyticalBackend | No | Analytical backend, from which the chart will obtain data to visualize If you do not specify instance of analytical backend using this prop, then you MUST have BackendProvider up in the component tree. | IBucketChartProps |
config | IChartConfig | No | Configure chart’s behavior and appearance. | ICommonChartProps |
drillableItems | ExplicitDrill[] | No | Configure drillability; e.g. which parts of the visualization can be interacted with. | IVisualizationProps |
ErrorComponent | ComponentType<IErrorProps> | No | React component to display in the event when there is an error with either obtaining the data from backend or with the data itself. | IVisualizationProps |
execConfig | IExecutionConfig | No | Execution configuration, will provide the execution with necessary config before initiating execution. | ICommonChartProps |
exportTitle | string | No | Set title to use for exported files. | IVisualizationProps |
filters | NullableFiltersOrPlaceholders | No | Specify filters to apply on the data to chart. | ITreemapBucketProps |
height | number | No | Set height of the chart (in pixels). | ICommonChartProps |
LoadingComponent | ComponentType<ILoadingProps> | No | React component to display while loading data from the backend. | IVisualizationProps |
locale | string | No | Set Locale for visualization localization. | IVisualizationProps |
onDataView | OnDataView | No | (Alpha) Called when the visualization loads a DataView, i.e. it receives data from the backend. | IVisualizationCallbacks |
onDrill | OnFiredDrillEvent | No | Called when user triggers a drill on a visualization. | IVisualizationCallbacks |
onError | OnError | No | Called when an error occurs while loading data for the visualization. | IVisualizationCallbacks |
onExportReady | OnExportReady | No | Called when the visualization is ready to be exported. | IVisualizationCallbacks |
onLegendReady | OnLegendReady | No | Called when legend is rendered. | IChartCallbacks |
onLoadingChanged | OnLoadingChanged | No | Called when loading status of the visualization changes - vis starts or stops loading | IVisualizationCallbacks |
placeholdersResolutionContext | any | No | Resolution context for composed placeholders. | ITreemapBucketProps |
segmentBy | AttributeOrPlaceholder | No | Specify an attribute, whose values will be used to segment the rectangles created for the measures or the combination of measure and viewBy attribute values. | ITreemapBucketProps |
viewBy | AttributeOrPlaceholder | No | Specify an attribute whose values will be used to slice the measure. | ITreemapBucketProps |
width | number | No | Set width of the chart (in pixels). | ICommonChartProps |
workspace | string | No | Identifier of analytical workspace, from which the chart will obtain data to visualize. If you do not specify workspace identifier, then you MUST have WorkspaceProvider up in the component tree. | IBucketChartProps |
Related
Show proportions of a whole with the PieChart component.
Compare two measures across variable-width stacked columns with the Mekko component.
Visualize data density across two dimensions with the Heatmap component.
Configure chart appearance, axes, legends, colors, and data labels.
Shared behavior of GoodData.UI visual components — responsive sizing, the style and data props model, and the visualization lifecycle callbacks.