View as Markdown

Foundation

Rendering and colors

Server-rendered SVG with deterministic layout, decimation for large data, the opt-in canvas plot layer and the visualization palette derived from the five theme seeds.

Every visualization renders SVG on the server from a pure layout of the props and the nominal size (the given width, else 600 px), and relays out once after hydration when the measured width differs. Text widths come from a fixed table, so the server and the first client render agree.

Every family renders SVG. The figure families (Chart, BulletChart, StockChart, PieChart, FunnelChart, HeatMap, TreeMap, SankeyChart, GeoMap, Gauge) hide the drawing from assistive technology and render a <figure> labelled by the title and described by an automatic summary, with an accessible equivalent: a visually hidden data table (accessibleTable, default on; showDataTable shows it), the TreeMap hierarchy as a nested list, a meter per gauge pointer. Sparkline, Barcode and QRCode are images named by an automatic summary or the encoded value, and RangeSelector is a multi-thumb slider.

Data is a plain array on every data-bound component, with per-series data on Chart and dotted field paths ('price.close') everywhere a field is named. An empty chart keeps its axes and shows the localized text.noData, or renderEmpty() on Chart, StockChart and PieChart.

Renderers, large data and data colors

Open demo

Up to 500,000 points drawn as SVG or on a canvas with min/max or LTTB decimation, a server-rendered SVG figure with an accessible data table, the derived palette or a brand palette, and per-point data colors.

Vibration signal

100,000 samples; decimation keeps the extremes of every pixel column.

Vibration signal
xSignal
00
13.24
26.45
39.62
412.73
515.74
618.65
78.43
811.08
913.58
1015.92
1118.1
1220.12
138.97
1410.67
1512.23
1613.64
1714.93
1816.12
1917.21
205.24
216.23
227.19
238.15
249.13
2510.17
26-1.74
27-0.55
280.74
292.16
303.72
315.42
327.28
33-3.7
34-1.52
350.83
363.33
375.98
388.76
39-1.33
401.69
414.79
427.96
4311.18
4414.41
4517.65
467.87
4711.04
4814.14
4917.15
5020.05
5122.83
5212.48
5314.97
5417.31
5519.49
5621.5
5723.36
5825.05
5913.6
6015.01
6116.3
6217.49
6318.58
6419.61
657.59
668.55
679.51
6810.5
6911.53
7012.62
7113.81
722.11
733.53
745.08
756.79
768.65
7710.67
78-0.14
792.2
804.7
817.35
8210.14
8313.05
8416.07
856.17
869.34
8712.56
8815.8
8919.03
9022.25
9112.41
9215.51
9318.52
9421.42
9524.2
9626.84
9729.33
9818.66
9920.84
10022.85
10124.69
10226.39
10327.93
10416.34
10517.63
10618.8
10719.9
10820.92
10921.9
11022.86
11110.82
11211.8
11312.83
11413.93
11515.12
11616.42
1174.83
1186.39
1198.1
1209.96
12111.98
12214.17
12316.52
1246.02
1258.67
12611.46
12714.37
12817.39
12920.49
13010.66
13113.87
13217.11
13320.34
13423.55
13526.72
13629.81
13719.82
13822.71
13925.49
14028.12
14130.61
14232.94
14322.11
14424.11
14525.95
14627.64
14729.18
14830.59
14931.87
15020.04
15121.13
15222.15
15323.13
15424.09
15525.04
15613.03
15714.05
15815.15
15916.34
16017.63
16119.05
16220.61
1639.32
16411.18
16513.2
16615.39
16717.74
16820.24
1699.89
17012.68
17115.59
17218.6
17321.71
17424.87
17528.09
17618.32
17721.55
17824.76
17927.92
18031.01
18134.01
18223.9
18326.67
18429.3
18531.78
18634.1
18736.27
18838.27
18927.1
19028.79
19130.32
19231.72
19333
19434.17
19522.25
19623.27
19724.24
19825.2
19926.15
20027.13
20128.16
20216.25
20317.44
20418.73
20520.15
20621.71
20723.41
20812.27
20914.3
21016.48
21118.83
21221.33
21323.99
21426.77
21516.68
21619.69
21722.79
21825.96
21929.17
22032.4
22122.63
22225.83
22328.98
22432.07
22535.06
22637.95
22740.71
22830.34
22932.81
23035.13
23137.29
23239.28
23341.11
23429.79
23531.32
23632.71
23733.98
23835.14
23936.22
24037.24
24125.21
24226.15
24327.11
24428.08
24529.11
24630.2
24718.38
24819.68
24921.09
25022.65
25124.35
25226.21
25328.23
25417.42
25519.77
25622.27
25724.92
25827.7
25930.61
26020.62
26123.72
26226.88
26330.09
26433.31
26536.54
26639.73
26729.88
26832.96
26935.95
27038.83
27141.59
27244.21
27333.67
27435.98
27538.13
27640.12
27741.94
27843.61
27945.13
28033.52
28134.78
28235.94
28337.02
28438.03
28538.99
28626.93
28727.88
28828.85
28929.87
29030.96
29132.15
29233.44
29321.85
29423.4
29525.1
29626.96
29728.99
29831.17
29920.51
30023.01
30125.66
30228.44
30331.35
30434.35
30537.45
30627.61
30730.81
30834.03
30937.25
31040.44
31143.59
31233.66
31336.64
31439.52
31542.26
31644.87
31747.33
31849.64
31938.78
32040.76
32142.57
32244.23
32345.75
32447.13
32535.38
32636.54
32737.6
32838.61
32939.57
33040.5
33141.45
33229.41
33330.43
33431.52
33532.69
33633.98
33735.39
33823.94
33925.64
34027.5
34129.52
34231.7
34334.04
34436.54
34526.18
34628.96
34731.86
34834.87
34937.96
35041.11
35131.31
35234.53
35337.74
35440.93
35544.06
35647.13
35750.1
35839.97
35942.71
36045.31
36147.77
36250.06
36352.19
36441.16
36542.97
36644.62
36746.13
36847.5
36948.75
37049.9
37137.96
37238.95
37339.9
37440.84
37541.77
37642.74
37730.75
37831.83
37933
38034.29
38135.7
38237.24
38338.94
38427.79
38529.81
38631.99
38734.33
38836.82
38939.46
39029.24
39132.13
39235.13
39338.22
39441.37
39544.56
39647.77
39737.98
39841.16
39944.29
40047.35
40150.31
40253.17
40342.9
40445.5
40547.94
40650.23
40752.35
40854.31
40956.11
41044.75
41146.25
41247.61
41348.86
41449.99
41551.05
41639.03
41739.98
41840.91
41941.84
42042.79
42143.8
42244.88
42333.05
42434.33
42535.73
42637.27
42738.97
42840.82
42929.83
43032
43134.34
43236.83
43339.47
43442.24
43545.13
43635.13
43738.21
43841.35
43944.53
44047.74
44150.94
44241.11
44344.23
44447.29
44550.25
44653.09
44755.82
44858.4
44947.84
45050.11
45152.23
45254.18
45355.97
45457.6
45546.09
45647.44
45748.68
45849.81
45950.85
46051.83
46152.77
46240.69
46341.61
46442.56
46543.56
46644.64
46745.8
46834.07
46935.47
47037.01
47138.7
47240.55
47342.56
47444.73
47534.06
47636.55
47739.18
47841.94
47944.83
48047.82
48137.9
48241.03
48344.21
48447.41
48550.6
48653.77
48756.88
48846.93
48949.88
49052.72
49155.43
49258
49360.43
49449.69
49551.8
49653.74
49755.52
49857.14
49958.62
99500 more rows not shown
Sales against target

Column chart: Sales against target, 2 series, x from North to Central. Actual: 5 points, minimum 40, maximum 74, trending up. Target: 5 points, minimum 55, maximum 55, flat.

Sales against target
xActualTarget
North4055
South5755
East7455
West5655
Central7355

Animation

animated (default true) plays one entrance and transitions later layouts on Chart (including the canvas plot layer): the reveal and the path transitions are CSS keyed on a data-animate attribute that is set after hydration, never in the server markup, and prefers-reduced-motion turns them off.

Export and print

Every instance (ref) exports: api.export({ format: 'png' | 'jpeg' | 'svg', fileName, scale }) downloads the drawing and settles once the download started; api.toBlob(format) and api.toDataURL(format) return the image. api.print() prints the vector drawing from a print document (every family except the barcode symbols). The export code is one lazy chunk shared by every family. Sparkline has no instance: its ref is the root <svg>; RangeSelector is a slider control whose ref offers element and focus only (export it with its StockChart).

api.toSVGString() returns a string synchronously on every family: the drawn SVG markup with the xmlns, theme colors kept as var(--salmon-*) references so the markup re-themes when it is inlined into a page that loads Salmon UI styles. api.toBlob('svg') (and export({ format: 'svg' })) is the standalone file: colors and the stylesheet's text and line styles inlined. On the server there is no instance; visualizationSvg(html, { theme, colorScheme }) from @salmonui/charts/server (server-safe, like @salmonui/core/server) turns the server-rendered HTML of any visualization into the same drawing as standalone SVG, colors resolved from the theme seeds, without a DOM:

import { renderToStaticMarkup } from 'react-dom/server';
import { visualizationSvg } from '@salmonui/charts/server';

const svg = visualizationSvg(renderToStaticMarkup(<Chart title="Sales" data={rows} series={series} />), { colorScheme: 'light' });

Data and documents

Chart (and StockChart and BulletChart, which render one) also exports its data and vector documents. The writers are not in any visualization bundle: the application passes loaders that import them on first use.

<Chart
  ref={chartRef}
  exportWriters={{
    pdf: () => import('@salmonui/export/graphics'),
    xlsx: () => import('@salmonui/export/xlsx'),
  }}
  {...props}
/>;

await chartRef.current?.export({ format: 'pdf', orientation: 'landscape', pageSize: 'a4' });
await chartRef.current?.export({ format: 'xlsx' });
await chartRef.current?.export({ format: 'csv' });
  • format: 'csv' writes the accessible table (the category column and one column per series) with the Data Grid's CSV writer from @salmonui/data-grid/engine/export (RFC 4180 quoting, spreadsheet formula prefixes neutralized). No loader is needed.
  • format: 'xlsx' writes the same table through exportWriters.xlsx; columns whose cells are all plain numbers become number cells.
  • format: 'pdf' writes the drawing as a vector PDF page through exportWriters.pdf (writeGraphicsPdf of @salmonui/export/graphics): paths, rectangles, circles and text become PDF path and text operators, never an image. orientation defaults to landscape for a wide drawing; pageSize takes the PDF writer's names (a4, letter, ...). The writer takes standalone SVG markup, so it also runs on the server with visualizationSvg output.
  • Without the loader, xlsx and pdf reject with a message naming the missing exportWriters entry. The other families export csv (their table) and images; put them in a PDF with exportVisualizations.

Several visualizations at once

exportVisualizations(items, options) combines several visualizations into one image or PDF page. items are instances (any ref API) or elements (a Sparkline's <svg>); unmounted entries are skipped.

import { exportVisualizations } from '@salmonui/charts/chart/export';

await exportVisualizations([chartApi, pieApi, gaugeApi], {
  format: 'pdf', // 'png' (default), 'jpeg', 'svg' or 'pdf'
  direction: 'horizontal', // 'vertical' (default)
  writers: { pdf: () => import('@salmonui/export/graphics') },
  fileName: 'dashboard.pdf',
});

It resolves to the file and downloads it unless download: false. The function is a few bytes in each entry and loads the shared export chunk on first use. It is exported by /chart, /chart/bullet, /stock-chart, /pie-chart, /heat-map, /tree-map, /sankey-chart, /barcode and the barcode symbology subpaths. /gauge and /geo-map (their initial bundles are at their gates) and /sparkline (its bundle never reaches the visualization export code) do not export it; a page with those uses it from any of the other entries, and it accepts their instances and elements.

Export and print

Open demo

Download a chart as PNG, JPEG, SVG, CSV, XLSX or a vector PDF, print it, read it as a data URL, blob or SVG string, and combine two charts into one image or PDF page.

Revenue by channel

Column chart: Revenue by channel, 2 series, x from Jan to Jun. Online: 6 points, minimum 120, maximum 190, trending up. Stores: 6 points, minimum 130, maximum 160, trending down.

Revenue by channel
xOnlineStores
Jan120160
Feb134154
Mar148148
Apr162142
May176136
Jun190130
Margin

Line chart: Margin, 1 series, x from Jan to Jun. Margin: 6 points, minimum 18, maximum 25, trending up.

Margin
xMargin
Jan18%
Feb23%
Mar19%
Apr24%
May20%
Jun25%

Ready

Large data

decimation reduces what reaches the renderer, outside React render: 'auto' (default) keeps the first, minimum, maximum and last point of each pixel column for lines and areas, 'lttb' keeps two points per column with Largest-Triangle-Three-Buckets, scatter series keep one point per pixel cell, and financial series merge candles per pixel bucket. false turns it off. Tooltips, keyboard navigation and the accessible table keep reading the original data. A 1,000,000-point line decimates well within the 50 ms budget.

renderer: 'canvas' (or 'auto', above 20,000 drawn points) moves only the marks to a canvas; axes, legend, labels and the accessible table stay SVG and DOM.

Render functions

Per-element customization uses pure function props, never events that change their arguments in place. Every family calls them while rendering (on the server too) and only for the elements it draws; they return a style or content and never mutate their argument:

Family Functions
Chart, StockChart series.getPointStyle(point) (data color, hidden leaves a gap; one call per point per layout), series.labels.format / render, series.renderMarker, axis.formatLabel / renderLabel, legend.renderItem, tooltip.format / header / render
PieChart, FunnelChart getPointStyle, formatLabel
Sparkline getPointStyle, tooltip.format
HeatMap getCellStyle
TreeMap getItemStyle
SankeyChart getNodeStyle, getLinkStyle
GeoMap layer.getShapeStyle, markers.getStyle
Gauge axis.formatLabel
RangeSelector formatLabel, tooltip.format
Kanban renderCard, getCardProps

Colors

The theme stays five seeds plus colorScheme. Visualization colors are derived roles, defined on .salmon-viz by the visualization stylesheet:

  • --salmon-chart-1 to --salmon-chart-10: slots 1 to 5 take the hues of primary, warning, info, danger and success, slots 6 to 10 the hues halfway between neighbors. Lightness alternates between two fixed values per scheme and chroma is fixed, so every slot meets 3:1 against the plot surface for any hue and adjacent slots stay apart under simulated protanopia, deuteranopia and tritanopia.
  • --salmon-chart-sequential-1..9 (primary, from the surface side) and --salmon-chart-diverging-1..11 (danger through neutral to primary).

palette={['#…', …]} and series.color take data colors (hex values that encode data, not theme tokens) and are used as given.

There is no named theme input: the theme is derived from a few values (color seeds, scheme, density, font family, neutral tint, surfaces), because named design-system themes would need a token table per component. Set the five seeds and colorScheme (light, dark or auto) once on ThemeProvider and every visualization follows, palette included; the theme's fontFamily applies to axis labels and legends too. High contrast relies on forced-colors support.

Visual tokens and backgrounds

Typography, stroke widths, radii, spacing, gradients and focus rings are system-owned, so contrast and layout stay guaranteed; there are no font, border, corner radius, gradient or spacing props. Data colors stay configurable. If a deviation is unavoidable, use className / style and CSS on the .salmon-chart-* parts; such overrides are unsupported but not blocked.

Surfaces follow the theme in both color schemes, because a hard-coded background breaks dark mode and contrast, so there is no background color, background image or plot area fill prop. Style the root with className or style, and use axis bands for data-driven backgrounds.

Fill patterns

PieChart takes patterns, a boolean that assigns one system pattern per palette slot for non-color encoding; there are no named pattern options. Chart has no pattern fill: distinguish its series by marker shape or lineStyle.

The Chart page has a live-data demo that clears its data to show renderEmpty. Export, renderer and decimation props are listed under ChartProps and ChartApi in the API reference, exportVisualizations in @salmonui/charts/chart/export.