> For the complete documentation index, see [llms.txt](https://docs.toucanai.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.toucanai.cloud/build/charts/chart-types/stacked-bar-chart.md).

# Stacked bar chart

{% hint style="info" %}
**Target Audience**: Non-technical users and builders configuring charts in the Library.
{% endhint %}

<figure><img src="/files/3ccr40bwfX2REP3UCHqe" alt="Stacked bar chart example"><figcaption></figcaption></figure>

## Overview

A stacked bar chart shows how a **total** splits into **segments** within each category. **Bar category** defines each bar; **Bar segment** defines stack layers; **Bar height** sets segment size.

* **Dimension:** **Bar category** and **Orientation** (vertical or horizontal).
* **Measure:** **Bar segment** (required) and **Bar height** with optional **Aggregation**.

In the **Library**, enable **Manual Edit**, set **Type** to **Stacked bars**, and map columns under **Data**.

Shared fields (**Title**, **Narrative**, **Data**) are in [Chart types](/build/charts/chart-types.md#shared-chart-level-settings).

## When to use it

**Good fit**

* Part-to-whole within each category (revenue by month split by product line).
* Compare segment mix across teams, regions, or periods.
* Survey or funnel answers stacked per question.

**Prefer another chart**

* Side-by-side category comparison → [Bar chart](/build/charts/chart-types/bar-chart.md).
* Trend over time → [Line chart](/build/charts/chart-types/line-chart.md).
* Few slices as % of one total → [Circular chart](/build/charts/chart-types/circular-chart.md).
* Raw row listing → [Table](/build/charts/chart-types/table.md).

**Examples:** revenue by month and product line, headcount by team and contract type.

{% hint style="warning" %}
Limit **Bar segment** to a modest number of categories so stacks stay readable.
{% endhint %}

**Common setups**

* **Vertical stacks:** **Bar category** + **Bar segment** + **Bar height** (e.g. Sum).
* **Over time:** date **Bar category** + **Date granularity** + segment column.
* **Horizontal:** set **Orientation** to **Horizontal**, then same fields.

## Configuration options

Open the chart in the **Library**, turn on **Manual Edit**, select **Data**, then set **Type** to **Stacked bars**. Panels: **Dimension** and **Measure** (*More dimension options* / *More measure options*).

Prerequisites: [connected database](/build/data-connections/how-to/add-a-database.md), Manual Edit ([how-to](/build/charts/how-to/customize-a-chart-manually.md)).

### Dimension

| Option               | How it works                                                                                               |
| -------------------- | ---------------------------------------------------------------------------------------------------------- |
| **Orientation**      | **Vertical** (default) or **Horizontal** stacked layout.                                                   |
| **Bar category**     | Column for each bar (category or time axis).                                                               |
| **Date granularity** | Only shown when **Bar category** is a date column. **Year**, **Quarter**, **Month**, **Week**, or **Day**. |
| **Date format**      | How date labels appear on the category axis.                                                               |
| **Order bars**       | *More dimension options.* Sort by a column, ascending or descending.                                       |
| **Show all labels**  | *More dimension options.* Label under each bar.                                                            |

### Measure

| Option                       | How it works                                                           |
| ---------------------------- | ---------------------------------------------------------------------- |
| **Bar segment**              | Column whose values become stack segments (e.g. status, product type). |
| **Bar height**               | Column for segment size. Often numeric; use **Aggregation** as needed. |
| **Aggregation**              | On **Bar height** after the column is selected.                        |
| **Format number**            | Shown when **Bar height** is numeric (after aggregation).              |
| **Show value on bar**        | *More measure options.* Values on segments (on by default).            |
| **Automatic y-axis scaling** | *More measure options.* On by default; off for **Min** / **Max**.      |

**Aggregations on Bar height**

| Aggregation                 | Typical column types |
| --------------------------- | -------------------- |
| Sum, Cumulated sum, Average | Integer, float       |
| Minimum, Maximum            | Integer, float, date |
| Count rows, Count distinct  | All types            |
| Standard deviation          | Integer, float       |

The AI assistant can pre-fill these fields; use **Manual Edit** to adjust.

**Suggested next steps:** [Chart types](/build/charts/chart-types.md) · [Bar chart](/build/charts/chart-types/bar-chart.md) · [Customize a chart manually](/build/charts/how-to/customize-a-chart-manually.md) · [Create a chart with AI](/build/charts/how-to/create-a-chart-with-ai.md)
