For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /dolan/chart-colors.md.

Chart Colors

Change the colors a chart draws its marks in, or pin a chart to light or dark. Charts take your theme'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:

npx @blotch/dolan add chart
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:

src/app/app.config.ts
providers: [
  provideChartTheme({
    light: { 'chart-1': 'rgba(37, 99, 235, 1)' },
    dark: { 'chart-1': 'rgba(96, 165, 250, 1)' },
  }),
],
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 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:

<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.

FieldTypeDescription
colorScheme'light' | 'dark' | 'system' | (() => 'light' | 'dark')Which color table the marks use. Defaults to 'system'.
lightRecord<string, string>Light color per token, without -- (e.g. 'chart-1'). Merged over CHART_LIGHT_COLORS.
darkRecord<string, string>Dark color per token. Merged over CHART_DARK_COLORS.
chartPartial<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.
  • Chart: which colors marks take
  • Theming: the theme colors marks can use
  • Dark mode: switch the app's .dark class