> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Chart Colors

Change the colors a [chart](/dolan/chart.md) draws its marks in, or pin a chart to light or dark. Charts take your [theme](/dolan/theming.md)'s colors and follow the app's appearance with nothing to set up. This page is for when you change a theme color, or keep one chart light or dark.

## Installation

`provideChartTheme()` comes with the chart:

```bash
npx @blotch/dolan add chart
```

```typescript
import { provideChartTheme } from '../components/ui/chart';
```

## Usage

If you change a color in `default.css` or `dark.css`, change it in `chart-theme.ts` too, or override it in your app config. Pass only the tokens you changed:

```typescript title="src/app/app.config.ts"
providers: [
  provideChartTheme({
    light: { 'chart-1': 'rgba(37, 99, 235, 1)' },
    dark: { 'chart-1': 'rgba(96, 165, 250, 1)' },
  }),
],
```

:::info Why the colors are in TypeScript too
Lynx draws the marks with its native `<svg>` element, which never sees your CSS. And Lynx can't read a variable's value from JavaScript.

So `chart-theme.ts` keeps a copy of the theme colors, and the chart swaps each `var(--token)` for its value before drawing. Labels and the tooltip are native views, so they read the CSS variables directly.
:::

### Color scheme

Charts follow the app's appearance, as the [theme](/dolan/theming.md#dark-mode) and the icons do. The **color scheme** says which color table the marks use:

- **`'system'`** (the default): the appearance the app is drawn in. Use it unless one of the others fits.
- **`'light'`**: always light, for a chart on a surface that stays light.
- **`'dark'`**: always dark, for a chart on a surface that stays dark.
- **A function** returning `'light'` or `'dark'`: for an app that switches a theme class of its own. Read the same signal that sets it.

Set it for every chart with `provideChartTheme({ colorScheme: … })`. Or set it for one chart, preset or `<ui-chart>`, with its `colorScheme` input:

```angular-html
<ui-chart [definition]="definition" colorScheme="dark" />
```

## API

### provideChartTheme

`provideChartTheme(theme)` returns a provider for every chart in its injector. Every field is optional, and `light`, `dark` and `chart` merge over their defaults.

| Field         | Type                                                         | Description                                                                               |
| ------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
| `colorScheme` | `'light' \| 'dark' \| 'system' \| (() => 'light' \| 'dark')` | Which color table the marks use. Defaults to `'system'`.                                  |
| `light`       | `Record<string, string>`                                     | Light color per token, without `--` (e.g. `'chart-1'`). Merged over `CHART_LIGHT_COLORS`. |
| `dark`        | `Record<string, string>`                                     | Dark color per token. Merged over `CHART_DARK_COLORS`.                                    |
| `chart`       | `Partial<ChartTheme>`                                        | The TanStack theme, such as its `palette`. Merged over `DEFAULT_CHART_THEME`.             |

- **Keep paints as `var(--token)` strings,** so one definition serves both color schemes.
- **An unknown token** falls back to the `var()`'s fallback, as in `var(--brand, #2563eb)`, or to the foreground color.

## Related

- [Chart](/dolan/chart.md#theming-and-dark-mode): which colors marks take
- [Theming](/dolan/theming.md): the theme colors marks can use
- [Dark mode](/guide/dark-mode.md): switch the app's `.dark` class
