Chart theming

An organisation's colours for its charts: set once around a page of charts, kept to the parts of a chart where colour is a choice and not a meaning.

What a theme changes

What a theme can change: colour in four roles, the words and formats, and the font. And what it can't.

Series Stations, casts, months, vessels palette: any colours, in order. Where brand colours go.
Parameters Temperature green in every chart parameters: a colour per parameter key, over the defaults.
Gradients An isopleth’s field, depth on a TS diagram ramps.parameters, ramps.sequential: picked from the curated ramps, not free colours. A gradient has to read in order and in greyscale; a hand-made one rarely does.
Classes A rose’s speed classes ramps.classes: jet, as the reports draw them, or blues.
Words and formats Compass points, readout labels, month names, 9,5 or 9.5, dates locale: language (en, nb), decimal mark, date format. Labels a page passes in are its own.
Font Every chart’s text, screen and print font: from a short list a PDF can embed. Unset, screen follows the page and print is Arial.
Not themed Classification colours, alarms and limits, text, axes and grid Classification colours mean something and are locked; red means a limit; the chart’s ink follows the page on screen and is dark on white in print.

Preview

The same charts under a theme built from the switches. Parameter colours stay put unless a theme names them; the palette moves the series, the ramps move the gradients; language, formats and font reach every chart's own text.

Colours
Language
Decimal
Dates
Font

Series: palette

Gradient: ramps.parameters.oxygen

Gradient: ramps.sequential

Classes: ramps.classes

Series: the first palette colour

Usage

The theme is a ChartTheme from @kystdata/figures, re-exported from @kystdata/ui/charts and validated there, so the same object is stored, edited and drawn. Layers merge per part: the platform's, the organisation's, then a figure's.

<ChartThemeProvider theme={mergeChartThemes(organisation.chartTheme, figure.theme)}>
	<BarChart ... />
	<IsoplethChart ... />
</ChartThemeProvider>
{
	palette?: string[];                         // 3–12 hex colours
	parameters?: Record<string, string>;        // parameter key → hex
	ramps?: {
		parameters?: Record<string, ColourRampId>; // greens, coolWarm, blues, rainbow, viridis
		sequential?: ColourRampId;                 // depth, time, intensity
		classes?: 'jet' | 'blues';                 // rose speed classes
	};
	locale?: {
		language?: 'en' | 'nb';                    // the chart's own words
		decimal?: ',' | '.';
		dates?: 'dd.mm.yyyy' | 'yyyy-mm-dd';
	};
	font?: 'arial' | 'inter' | 'roboto' | 'source-sans-3' | 'ibm-plex-sans' | 'instrument-sans';
}