Pyramid chart
Show hierarchical data as stacked layers with the PyramidChart component.
A pyramid chart displays values as proportional segments in a triangular shape, showing hierarchical structures and relative proportions. Pyramid charts are typically used for displaying demographic data, market segmentation, organizational structures, or workflows.

Buckets
| Prop | Required | Takes | What it does |
|---|---|---|---|
measures | Yes | One or more measures | Sets the size of the segments. With more than one measure, each measure is a segment. |
viewBy | No | One attribute | Draws one segment per attribute value. Works only with a single measure. |
filters | No | Filters | Limits the data the pyramid chart shows. |
For code samples of both setups, see Usage patterns.
Sorting
With viewBy set, the pyramid chart sorts the segments by value in descending order. With several measures and no viewBy, the segments keep the order of measures. PyramidChart has a sortBy prop. For the segments to follow sortBy when viewBy is set, also set enableChartSorting: true in config. Otherwise, the chart re-sorts them by value.
Configuration
Pass these options in the config prop. See Chart configuration for details.
| Option | What it changes |
|---|---|
colors, colorPalette, colorMapping | Colors of the segments: one per viewBy value, or one per measure without viewBy. |
legend | Whether the legend shows and where. position defaults to "right". The legend appears only with viewBy or more than one measure. |
dataLabels | visible shows or hides the labels. style: "backplate" adds a background behind them. |
enableChartSorting | With viewBy set, keeps the segment order that sortBy sets. See Sorting. |
chartFill | type sets how segments are filled: "solid", "pattern", or "outline". |
separators | Thousands and decimal separators in the number format. |
The following example shows the config structure with sample values for pyramid charts:
import type { IChartConfig } from "@gooddata/sdk-ui-charts";
const config: IChartConfig = {
colors: ["rgb(195, 49, 73)", "rgb(168, 194, 86)"],
colorPalette: [{
guid: "01",
fill: {
r: 195,
g: 49,
b: 73
}
}, {
guid: "02",
fill: {
r: 168,
g: 194,
b: 86
}
}],
colorMapping: [{
predicate: (headerItem) => {
return headerItem.measureHeaderItem && (headerItem.measureHeaderItem.localIdentifier === "m1_localIdentifier")
},
color: {
type: "guid",
value: "02"
}
}],
legend: {
enabled: true,
position: "top",
},
dataLabels: {
visible: "auto"
},
separators: {
thousand: ",",
decimal: "."
}
};
Limits
- A pyramid chart can’t show negative values. If the data contains any, the chart shows an error and
onErrorreceives aNegativeValuesSdkError. - A pyramid chart renders up to 10,000 segments. With more, the chart shows an error and
onErrorreceives aDataTooLargeToDisplaySdkError. Filter the data to fit. viewByworks only with a single measure. WithviewByand more than one measure, the chart shows an error andonErrorreceives aDataTooLargeToDisplaySdkError.- Pyramid charts are easiest to read with a small number of segments, typically three to ten.
Usage patterns
Single measure with a viewBy attribute
When using a single measure with a viewBy attribute, each attribute value creates a segment in the pyramid:
<PyramidChart
measures={[Md.$Revenue]}
viewBy={Md.Region}
/>
Multiple measures
When using multiple measures, each measure creates a segment in the pyramid. The viewBy attribute cannot be used in this case:
<PyramidChart
measures={[Md.$Revenue, Md.$Profit, Md.$Costs]}
/>
Structure
import "@gooddata/sdk-ui-charts/styles/css/main.css";
import { PyramidChart } from "@gooddata/sdk-ui-charts";
<PyramidChart
measures={<measures>}
config={<chart-config>}
…
/>
Example
import "@gooddata/sdk-ui-charts/styles/css/main.css";
import { PyramidChart } from "@gooddata/sdk-ui-charts";
import * as Md from "./catalog.js";
const style = { height: 300 };
<div style={style}>
<PyramidChart
measures={[Md.$TotalSales]}
viewBy={Md.Product.Name}
/>
</div>
Props
| Prop | Type | Required | Description | Inherited from |
|---|---|---|---|---|
measures | AttributesMeasuresOrPlaceholders | Yes | Specify one or more measures to chart into a pyramid. | IPyramidChartBucketProps |
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. | IPyramidChartBucketProps |
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. | IPyramidChartBucketProps |
sortBy | SortsOrPlaceholders | No | Specify how to sort the data to chart. | IPyramidChartBucketProps |
viewBy | AttributeOrPlaceholder | No | Specify attribute that will be used to slice the single measure into multiple pieces that will be charted into a pyramid. | IPyramidChartBucketProps |
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
Display sequential stages of a process with the FunnelChart component.
Display horizontal bar comparisons with the BarChart 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.