> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Build X/Y charts with layers

> Use layers to control the mark, stacking, color, size, and labels of each measure in a bar, line, area, or scatter chart.

Layers give each measure in an X/Y chart its own settings. Every measure you plot on the left or right axis becomes a layer, and each layer has its own mark type, stacking, color, size, and labels. You can draw one measure as bars and another as a line, color one measure by a dimension and leave the other a single color, or put measures on separate axes with independent scales.

![A bar chart of order counts stacked by status, with a product count line on the right axis](https://mintcdn.com/omni-e7402367/MfOBu7zLqCKBhWY7/visualize-present/visualizations/layers/images/layered-chart-two-axes.png?fit=max\&auto=format\&n=MfOBu7zLqCKBhWY7\&q=85\&s=c7a077e5c6aa22b4ff9aa40a341d6cbf)

## Requirements

Layers must be turned on for your organization. To turn on layers, contact Omni support.

Layers apply to X/Y charts: bar, line, area, and scatter. Other chart types, such as tables, pie charts, and maps, don't use layers.

When enabled, new X/Y charts use layers automatically. Existing charts keep the classic editor until you move them to layers.

Refer to [Switch between the layers and classic editors](https://docs.omni.co/visualize-present/visualizations/layers/switch-editors.md) to move an existing chart to layers, or to move a chart back.

## How layers work

Each measure on the Y-axis is one layer. The **Y-axes** section always shows a **Left axis** and a **Right axis**, so you can drop a field on either axis. Each axis has its own scale. When you rotate the chart, the section is **X-axes**, with a **Bottom axis** and a **Top axis**.

On each axis, the first layer draws on top. Drag a layer's field to change the order.

A layer that stacks, such as a bar layer colored by `Status`, stacks only its own segments. Separate layers never stack on each other. To stack or group several measures together, put them in one [Measure values](https://docs.omni.co/visualize-present/visualizations/layers/measure-names-values.md) layer.

## Chart options

When a chart uses layers, the **Chart options** panel has two tabs:

* **Setup** - The axes and their layers, Small multiples, Tooltip, Measure values, and Available fields
* **Style** - The chart palette and the legends

### Add and change fields

You can drag fields to the axes and other sections. You can also use these controls:

* Click **+** in a section header, or click an empty **Add a field** slot, to pick a field from a list.
* Right-click a field, or open its menu, to use these options:
  * **Field properties...** - Opens the field's title, format, and analytics settings, such as regression lines and moving averages
  * **Aggregation** - Changes how the field aggregates
  * **Switch to...** - Replaces the field with another field in place
* Click the **X** on a field to remove it.

### Layer settings

A layer's settings are under its field on the axis. Click the arrow at the start of the field to expand or collapse the layer. When a chart has one layer, that layer is expanded by default. The icon on the field shows the layer's mark, so you can identify each layer when it's collapsed.

An expanded layer has these rows:

| Row | What it controls |
| - | - |
| **Mark** | The mark type: **Area**, **Bar**, **Line**, or **Scatter**. A **Stacking** select displays next to the mark when the layer has a color field. |
| **Color** | **Single color**, or a field that colors the layer's segments |
| **Size** | **Fixed size**, or a field that sets the size of each point. This row displays only for **Scatter** layers. |
| **Label** | The data labels for the layer. Click **+ Add labels** to label the layer with its own field in one click, or pick a different field from the menu. |

Click the  icon at the end of a row to open more options for that row.

![The Line options popover with Points, Stroke, Width, Interpolation, and Opacity settings](https://mintcdn.com/omni-e7402367/1vCSXxlQ6aWmyahJ/visualize-present/visualizations/layers/images/line-options.png?fit=max\&auto=format\&n=1vCSXxlQ6aWmyahJ\&q=85\&s=b48799b049f42d064148fb951df05119)

### Change every layer at once

Click the  icon next to the **Y-axes** heading to open the axes menu. Use the options under **All values** to set the same value on every layer:

* **Mark** - The mark type
* **Color** - **Single color**, or a field that colors each layer
* **Size** - **Fixed size**, or a field that sets the size of each point. This option displays only when the chart has a **Scatter** layer.
* **Label** - **No labels**, or a field that labels each layer

A value set from the menu replaces the value on each layer.

![The axes menu with the Color submenu open under All values](https://mintcdn.com/omni-e7402367/1vCSXxlQ6aWmyahJ/visualize-present/visualizations/layers/images/all-layers-menu.png?fit=max\&auto=format\&n=1vCSXxlQ6aWmyahJ\&q=85\&s=4189d4e5011a0797be76667b90575c3a)

The axes menu also has these options:

* **Swap left and right** - Moves every layer to the other axis. The layers keep their order, and each axis's settings, such as its title and scale, move with its layers. For a rotated chart, this option is **Swap top and bottom**.
* **Display order** - Sets which axis's layers draw on top: **Left values on top** or **Right values on top**. This option displays only when both axes have layers.

## Stacking

A layer can stack when it has a color field. For a Measure values layer, the color field is usually **Measure names**. The **Stacking** select displays next to the layer's mark only when the layer has a color field.

| Option | Result | Available for |
| - | - | - |
| **Stacked** | Segments stack on top of each other | All marks |
| **Stacked %** | Segments stack and show each segment's share of 100% | All marks |
| **Grouped** | Segments display side by side | Bar |
| **Overlay** | Segments draw on top of each other | All marks |

Bar and area layers stack by default. Line and scatter layers overlay by default.

A chart with two or more measure layers and no color field overlays the layers. To stack the measures, move them into [Measure values](https://docs.omni.co/visualize-present/visualizations/layers/measure-names-values.md).

### Stack order

For a **Stacked** or **Stacked %** layer, open the mark options to control the order of the segments:

* **Sort stack by** - The segment order:
  * **Label** - Alphabetical by the color field's values
  * **Segment value** - By each segment's value within its own stack. Not available for area or line layers.
  * **Overall sum** - By each segment's total across all stacks
  * **Unsorted** - The order of the query results
* **Sort order** - Ascending or descending, for example **Ascending (A to Z)** or **Descending (Z to A)**. This setting doesn't display for **Unsorted**.

![The Bar options popover with Stacking, Sort stack by, and Sort order settings](https://mintcdn.com/omni-e7402367/1vCSXxlQ6aWmyahJ/visualize-present/visualizations/layers/images/mark-options.png?fit=max\&auto=format\&n=1vCSXxlQ6aWmyahJ\&q=85\&s=4275b22c7d6b5d7f5b13e09e1a0be79f)

### Percentage axes

Layers on one axis share that axis's scale. The axis shows percentages only when every layer on it uses **Stacked %**. If you mix **Stacked %** with another option on one axis, a warning icon displays on the layer's field. The percentage layer's values run from 0 to 1 on the same scale as the other layers, so it's squashed at the bottom of the chart.

## Align zero on both axes

When a chart has layers on the left and right axes, each axis has its own scale, so zero can be at a different height on each axis. To put zero at the same height on both axes:

1. Next to **Left axis** or **Right axis**, click the  icon.
2. Under **Zero line**, select **Align with other axis**.

![The Left axis options popover with the Align with other axis setting under Zero line](https://mintcdn.com/omni-e7402367/1vCSXxlQ6aWmyahJ/visualize-present/visualizations/layers/images/axis-options-align-zero.png?fit=max\&auto=format\&n=1vCSXxlQ6aWmyahJ\&q=85\&s=5bce8fd0fdba9be06466fff8e5475459)

The setting applies to both axes.

To align zero, Omni extends the range of one or both axes. A minimum or maximum that you set for an axis doesn't change. If the values that you set don't let zero align, both axes use their usual range.

**Align with other axis** isn't available when:

* An axis uses a scale other than linear
* An axis has a minimum of zero or more, or a maximum of zero or less. These values put zero at the edge of the axis.
* Both axes have a minimum and a maximum

## Color and legends

### One color setup per field

Color settings belong to the field, not to the layer. If two layers color by `Country`, they share one set of colors and one legend. A change to the colors from one layer also changes the other layer.

![A bar layer on the left axis and a line layer on the right axis that both color by Country](https://mintcdn.com/omni-e7402367/1vCSXxlQ6aWmyahJ/visualize-present/visualizations/layers/images/shared-color-field.png?fit=max\&auto=format\&n=1vCSXxlQ6aWmyahJ\&q=85\&s=82aa67fe797a23055b5e6647e1d37ce3)

### Chart palette

The **Style** tab has the **Default chart palette** for the chart. All layers take colors from this palette unless a layer's color field has its own palette. Omni assigns palette colors in this order, so that layers don't duplicate colors:

1. Layers without a color field take the first colors, one each.
2. Each color field takes the next batch of colors, one for each of its values.

A color that you set by hand, or a color from the model's [`colors` parameter](https://docs.omni.co/modeling/dimensions/parameters/colors), keeps its place and doesn't move the other colors.

### Legends

The **Style** tab also lists each legend on the chart. A chart has one legend for each color field and each size field. When a chart has two or more layers, the layers without a color field share one **Series** legend, which has no title by default.

![The Style tab with the default chart palette and legend settings for Country and Series](https://mintcdn.com/omni-e7402367/MfOBu7zLqCKBhWY7/visualize-present/visualizations/layers/images/styles-tab.png?fit=max\&auto=format\&n=MfOBu7zLqCKBhWY7\&q=85\&s=784e78d74b928d361b50cdfc01cb8571)

Use the **Max width** or **Max height** controls above the legend list to set the share of the chart's width or height that legends on one side can take, as a percentage:

* **Max width** controls legends on the left or right.
* **Max height** controls legends on the top or bottom.

Each legend also has these settings:

| Setting | Options | Default |
| - | - | - |
| **Labels** | **Truncate** or **Wrap** | **Truncate** |
| **Max items** | A number of entries to show | Blank (shows every entry) |

You can also ask the Omni Agent to change a legend's labels or entry cap. Refer to [Build visualizations with AI](https://docs.omni.co/ai/visualizations.md).

A static export, such as a PDF, PNG, or scheduled delivery, can't scroll. It shows as many entries as fit, plus an **…N entries** row for the rest.

#### Filter with the legend

Legends in the chart are interactive. Click an item in a legend to show only that item. Cmd+click (Mac) or Ctrl+click (Windows) to select more than one item. When you select items in one legend, layers that belong to other legends are hidden until you clear the selection.

## Labels and totals

Labels are set per layer. When a layer has no labels, its **Label** row shows an **+ Add labels** button (**+ Add segment labels** when simple totals are on). Click it to label the layer with its own field in one click. To label the layer with a different field instead, open the menu from the chevron next to the button.

For a stacked layer, the label options include **Simple totals**, which labels the total of each stack. Simple totals are calculated per layer. To total several measures, put them in one Measure values layer and turn on **Simple totals** for that layer.

![The Label options popover with Simple totals turned on for a stacked layer](https://mintcdn.com/omni-e7402367/1vCSXxlQ6aWmyahJ/visualize-present/visualizations/layers/images/label-options-simple-totals.png?fit=max\&auto=format\&n=1vCSXxlQ6aWmyahJ\&q=85\&s=858ed20618f6913cbaea751910857227)

Omni hides labels that overlap, and labels on bars often overlap. If labels are missing, turn on **Show all** in the layer's label options.

## Tooltips

On line, area, and scatter layers, the tooltip displays when you hover near a point, and the point is highlighted.

## Axis sort order

For a text field on the X-axis:

* **Automatic** keeps the order of the query results when the query is sorted.
* **Ascending** sorts alphabetically.
* **Descending** sorts in reverse alphabetical order.

## Limitations

* Separate layers don't stack on each other. Use [Measure values](https://docs.omni.co/visualize-present/visualizations/layers/measure-names-values.md) to stack measures.
* Each color field has one set of colors for the whole chart. You can't color the same field differently in two layers.
* Layers on one axis share the axis's scale and title.
* Two layers that each leave out a different dimension can't both get totals. One of them looks jagged. Refer to [Smart aggregation](https://docs.omni.co/visualize-present/visualizations/layers/smart-aggregation.md#what-to-expect).
* **Size** is available only on **Scatter** layers. If you change a scatter layer to another mark, its size setting is removed.

## Next steps

* [Measure names and Measure values](https://docs.omni.co/visualize-present/visualizations/layers/measure-names-values.md)
* [Smart aggregation](https://docs.omni.co/visualize-present/visualizations/layers/smart-aggregation.md)
* [Switch between the layers and classic editors](https://docs.omni.co/visualize-present/visualizations/layers/switch-editors.md)
* [Build visualizations with AI](https://docs.omni.co/ai/visualizations.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.