Skip to main content

Themes

theme recolours everything that is not data — background, axes, grid, text, legend chrome. Give it a name, or an object to override individual colours (starting from light).

Named themes​

ValueLook
"light"The default: white background, black text.
"dark"Dark background, light text.
"minimal"Stripped back: no grid, minimal chrome.
"solarized"The Solarized palette.

What the built-in themes set​

Propertylight (default)darkminimalsolarized
Backgroundwhite#1e1e1ewhite#fdf6e3
Axes / ticksblack#ccccccblack#586e75
Textblack#e0e0e0black#657b83
Grid#ccc#444444#e0e0e0#eee8d5
Legend backgroundwhite#2d2d2dwhite#fdf6e3
Legend borderblack#666666none#93a1a1
Fontthe default stackthe default stackserifthe default stack
Grid drawnyesyesnoyes

Those are the exact values a built-in theme installs — a theme object starts from light and overrides the keys you give, which is how the custom theme below is built.

Fonts and portability​

The default font stack — DejaVu Sans, Verdana, Liberation Sans, Arial, sans-serif — is resolved by whatever renders the SVG. That is fine on any desktop, but a tool processing the file on a machine with no system fonts (a container, a CI job) will substitute something else. kuva can embed the font as a base64 @font-face block to make the file self-contained, at the cost of roughly 1 MB of extra size.

This extension does not expose that switch. The embedded font would have to travel inside the .duckdb_extension itself, making every install about a megabyte larger for a case that does not arise in DuckDB: the SVG is displayed by a browser or a document tool, both of which have fonts. If you do need a self-contained SVG, re-render it with kuva directly.

Custom theme​

An object starts from the light theme and overrides only the keys you give:

FieldTypeWhat it sets
backgroundstringCanvas background.
axis_colorstringAxis lines.
grid_colorstringGrid lines.
tick_colorstringTick marks.
text_colorstringAll text.
legend_bgstringLegend background.
legend_borderstringLegend border.
pie_leaderstringPie leader lines.
box_medianstringThe box plot median line.
violin_borderstringViolin outline.
colorbar_borderstringThe colour-bar border on heatmaps.
font_familystringFont family (the same as font.family).
show_gridbooleanWhether the grid is drawn.

Example​

The dark theme, on the same overlay the series page uses:

SELECT kuva_render(to_json({
'theme': 'dark',
'x_axis': {'name': 'time'},
'y_axis': {'name': 'value'},
'series': [
{'type': 'line', 'data': pts, 'legend': 'trend'},
{'type': 'scatter', 'data': pts, 'legend': 'points'}
]
})) AS chart
FROM (
SELECT array_agg({'x': time, 'y': value} ORDER BY time) AS pts
FROM read_csv_auto('{{DFK_BASE_URL}}data/measurements.tsv')
WHERE "group" = 'Condition_A'
);

See also​