Charts
Chart
One Chart component with a series collection covering line, area, column, bar, scatter, bubble, financial, waterfall, histogram, box plot and Pareto series, with curves, stacks and data colors.
Chart lives in @salmonui/charts/chart (CSS: @salmonui/charts/chart/styles.css).
It is one component with a series collection: mixed types combine freely
in one chart.
import { Chart } from '@salmonui/charts/chart';
import '@salmonui/charts/chart/styles.css';
<Chart
title="Sales"
data={rows}
series={[
{ type: 'column', xField: 'month', yField: 'north', name: 'North' },
{ type: 'line', xField: 'month', yField: 'south', name: 'South', curve: 'monotone', markers: true },
]}
/>;
Series can also be written as children, which compile to the same model (and render identically on the server):
import { Chart, ChartAxis, ChartSeries } from '@salmonui/charts/chart';
<Chart data={rows}>
<ChartSeries type="line" xField="month" yField="north" />
<ChartAxis direction="y" title="Units" />
</Chart>
Series types
type |
Covers | Notes |
|---|---|---|
'line' |
line, spline, step line, multicolored line | curve, segments |
'area' |
area, spline area, step area, range area, spline and step range area | lowField + highField draw a range |
'column', 'bar' |
column, bar, range column | bar transposes; lowField + highField for ranges |
'scatter', 'bubble' |
scatter, bubble | markers.shape, sizeField, radius: [min, max] |
'hilo', 'ohlc', 'candle' |
high-low, high-low-open-close, candlestick | openField, highField, lowField, closeField; candles use the success / danger seeds, upColor, downColor, hollow; volumeField draws volume columns in the bottom fifth of the plot, in the candle colors, and adds the volume to the tooltip |
'waterfall' |
waterfall | totals, subtotals (indexes or a predicate), connectors |
'histogram' |
histogram | automatic bins or binWidth, normalCurve |
'boxPlot' |
box and whisker | yField holds an array per category; quartileMethod: 'exclusive' | 'inclusive' | 'normal', mean, outliers |
'pareto' |
Pareto | sorted columns plus the cumulative percent line on a generated secondary axis; pareto: { line, markers, color } |
orientation="horizontal" transposes the whole chart, so bars combine with
lines and every other series type.
Lines, steps and areas
Open demoA Chart with a range area, a segmented line and an area on a second axis; switch the curve, the step position and the risers, and hide a series.
Area chart: Temperature and rain, 3 series, x from Jan to Dec. Average: 12 points, minimum 2, maximum 22, trending up. Rain: 12 points, minimum 40, maximum 96, trending up.
| x | Low to high | Average | Rain |
|---|---|---|---|
| Jan | 2 | 40 | |
| Feb | 3.3 | 77 | |
| Mar | 7 | 54 | |
| Apr | 12 | 91 | |
| May | 17 | 68 | |
| Jun | 20.7 | 45 | |
| Jul | 22 | 82 | |
| Aug | 20.7 | 59 | |
| Sep | 17 | 96 | |
| Oct | 12 | 73 | |
| Nov | 7 | 50 | |
| Dec | 3.3 | 87 |
Curves and steps
series.curve is 'linear' (default), 'natural', 'monotone' (no
overshoot), 'cardinal' with series.tension, 'clamped' or 'step'.
Steps take stepPosition: 'start' | 'center' | 'end' and
risers: false to draw the steps without vertical risers.
Stacks and groups
series.stack: true | 'percent' stacks series that share a value axis;
positive and negative values stack separately and stackGroup keeps
several stacks side by side. stackLabels draws the totals.
Columns of different series sit side by side; grouping="overlap"
overlaps them, series.group overlaps a subset, bandWidth (fraction of
the category, or px above 1) and gap size them.
Columns, bars and stacks
Open demoColumn and bar series stacked, stacked to 100 % or grouped side by side or overlapping, with stack totals, band widths, range columns and a horizontal chart that combines bars with a line.
Column chart: Units by region, 4 series, x from Q1 to Q4. North: 4 points, minimum 42, maximum 60, trending up. South: 4 points, minimum 30, maximum 39, trending up. West: 4 points, minimum 18, maximum 30, trending up. Returns: 4 points, minimum -8, maximum -4, flat.
| x | North | South | West | Returns |
|---|---|---|---|---|
| Q1 | 42 | 30 | 18 | -4 |
| Q2 | 48 | 37 | 22 | -6 |
| Q3 | 54 | 32 | 26 | -8 |
| Q4 | 60 | 39 | 30 | -4 |
Column chart: Price range and target, 2 series, x from Q1 to Q4. Target: 4 points, minimum 36, maximum 48, trending up.
| x | Price range | Target |
|---|---|---|
| Q1 | 36 | |
| Q2 | 40 | |
| Q3 | 44 | |
| Q4 | 48 |
Appearance and data colors
name, hidden, order and opacity set a series' legend name,
initial visibility, drawing order and opacity. Colors default to the derived palette slot (--salmon-chart-1
onward); series.color, palette, colorField and segment colors are
data colors, used as given. lineStyle: 'solid' | 'dashed' | 'dotted'
sets the stroke pattern. Segments color a line by value along
segmentAxis. colorRanges colors points by y value range and
feeds the range and gradient legends (see
Chart elements).
Scatter, bubble and data colors
Open demoScatter series with marker shapes, a bubble chart sized by population and colored per point, and columns colored by value ranges with a series, point, range or gradient legend.
Scatter chart: Height and weight, 2 series, Height (cm) from 150 to 200. Group A: 20 points, minimum 48, maximum 80, trending up. Group B: 20 points, minimum 48, maximum 80, trending up.
| Height (cm) | Group A | Group B |
|---|---|---|
| 150 | 48 | 63 |
| 166 | 62 | 60 |
| 182 | 76 | 75 |
| 153 | 53 | 68 |
| 169 | 67 | 66 |
| 185 | 64 | 80 |
| 156 | 58 | 57 |
| 172 | 72 | 71 |
| 188 | 70 | 48 |
| 159 | 64 | 62 |
| 175 | 61 | 76 |
| 191 | 75 | 53 |
| 162 | 69 | 68 |
| 178 | 66 | 65 |
| 194 | 80 | 59 |
| 165 | 57 | 73 |
| 181 | 71 | 70 |
| 152 | 48 | 64 |
| 168 | 63 | 61 |
| 184 | 77 | 75 |
Bubble chart: Wealth and health, 1 series, GDP per capita (k$) from 0 to 60. Countries: 6 points, minimum 63, maximum 83, trending up.
| GDP per capita (k$) | Countries |
|---|---|
| 12 | Aland |
| 24 | Borea |
| 35 | Corin |
| 48 | Dalvi |
| 8 | Estra |
| 56 | Fenn |
Column chart: Yield by day, 1 series, x from Mon to Sun. Yield: 7 points, minimum 20, maximum 85, trending up.
| x | Yield |
|---|---|
| Mon | 20 |
| Tue | 61 |
| Wed | 32 |
| Thu | 73 |
| Fri | 44 |
| Sat | 85 |
| Sun | 56 |
Financial series
Open demoCandle, OHLC and high-low series over daily prices, with hollow candles and volume columns in the candle colors.
Candlestick chart: ACME daily prices. No data.
| x | ACME |
|---|---|
| Jan 5 | O 100 H 101.5 L 98.8 C 100 V 1,200 |
| Jan 6 | O 102.98 H 108.45 L 101.28 C 105.95 V 1,577 |
| Jan 7 | O 105.84 H 109.34 L 102.87 C 105.07 V 1,954 |
| Jan 8 | O 108.45 H 109.95 L 102.98 C 105.68 V 1,431 |
| Jan 9 | O 110.73 H 114.71 L 109.53 C 112.21 V 1,808 |
| Jan 10 | O 107.59 H 113.49 L 105.89 C 109.99 V 1,285 |
| Jan 11 | O 108.98 H 110.48 L 104.68 C 106.88 V 1,662 |
| Jan 12 | O 109.87 H 112.37 L 105.32 C 108.02 V 2,039 |
| Jan 13 | O 110.27 H 116.35 L 109.07 C 112.85 V 1,516 |
| Jan 14 | O 110.22 H 112.91 L 108.52 C 111.41 V 1,893 |
| Jan 15 | O 104.79 H 107.29 L 99.7 C 101.9 V 1,370 |
| Jan 16 | O 104.05 H 107.55 L 100.91 C 103.61 V 1,747 |
| Jan 17 | O 103.13 H 107.63 L 101.93 C 106.13 V 1,224 |
| Jan 18 | O 102.13 H 104.63 L 100.11 C 101.81 V 1,601 |
| Jan 19 | O 101.19 H 104.69 L 96.08 C 98.28 V 1,978 |
| Jan 20 | O 95.43 H 98 L 92.73 C 96.5 V 1,455 |
| Jan 21 | O 94.95 H 100.08 L 93.75 C 97.58 V 1,832 |
| Jan 22 | O 94.84 H 98.34 L 91.38 C 93.08 V 1,309 |
| Jan 23 | O 95.18 H 96.68 L 90.79 C 92.99 V 1,686 |
| Jan 24 | O 96.01 H 100.83 L 93.31 C 98.33 V 2,063 |
| Jan 25 | O 92.33 H 97.42 L 91.13 C 93.92 V 1,540 |
| Jan 26 | O 94.13 H 95.63 L 89.7 C 91.4 V 1,917 |
| Jan 27 | O 96.36 H 98.86 L 93.27 C 95.47 V 1,394 |
| Jan 28 | O 98.93 H 105.39 L 96.23 C 101.89 V 1,771 |
| Jan 29 | O 101.76 H 103.39 L 100.56 C 101.89 V 1,248 |
| Jan 30 | O 99.73 H 102.23 L 95.05 C 96.75 V 1,625 |
| Jan 31 | O 102.72 H 106.87 L 100.52 C 103.37 V 2,002 |
| Feb 1 | O 105.6 H 109.92 L 102.9 C 108.42 V 1,479 |
| Feb 2 | O 108.26 H 110.76 L 105.68 C 106.88 V 1,856 |
| Feb 3 | O 110.58 H 114.08 L 106.42 C 108.12 V 1,333 |
Error bars
series.errorBars: { kind, amount, direction, caps, axis } draws whiskers:
kind is 'fixed', 'percent', 'standardDeviation',
'standardError' or 'custom' (plusField / minusField), direction
'both' | 'plus' | 'minus', and axis 'y' (default), 'x' (continuous
x axes) or 'both'.
Waterfall, histogram, box plot, Pareto and error bars
Open demoThe statistical Chart series: a profit bridge with subtotals and totals, a histogram with a normal curve, box plots with three quartile methods, a Pareto chart and columns with five kinds of error bars.
Waterfall chart: Profit bridge, 1 series, x from Revenue to Net profit. Amount: 7 points, minimum -180, maximum 420, trending down.
| x | Amount |
|---|---|
| Revenue | $420 |
| Cost of sales | -$180 |
| Gross profit | $240 |
| Marketing | -$60 |
| R&D | -$75 |
| Other income | $25 |
| Net profit | $130 |
Histogram chart: Response times, 1 series, x from 100 to 300. Requests: 200 points, minimum 119, maximum 337, trending down.
| x | Requests |
|---|---|
| 0 | 220 |
| 1 | 249 |
| 2 | 229 |
| 3 | 292 |
| 4 | 225 |
| 5 | 298 |
| 6 | 209 |
| 7 | 266 |
| 8 | 191 |
| 9 | 217 |
| 10 | 189 |
| 11 | 179 |
| 12 | 213 |
| 13 | 172 |
| 14 | 254 |
| 15 | 195 |
| 16 | 291 |
| 17 | 230 |
| 18 | 301 |
| 19 | 256 |
| 20 | 274 |
| 21 | 263 |
| 22 | 223 |
| 23 | 253 |
| 24 | 176 |
| 25 | 242 |
| 26 | 160 |
| 27 | 241 |
| 28 | 185 |
| 29 | 251 |
| 30 | 239 |
| 31 | 261 |
| 32 | 292 |
| 33 | 258 |
| 34 | 318 |
| 35 | 238 |
| 36 | 304 |
| 37 | 211 |
| 38 | 264 |
| 39 | 197 |
| 40 | 222 |
| 41 | 210 |
| 42 | 202 |
| 43 | 250 |
| 44 | 210 |
| 45 | 297 |
| 46 | 235 |
| 47 | 325 |
| 48 | 259 |
| 49 | 316 |
| 50 | 268 |
| 51 | 272 |
| 52 | 263 |
| 53 | 216 |
| 54 | 255 |
| 55 | 180 |
| 56 | 256 |
| 57 | 184 |
| 58 | 270 |
| 59 | 224 |
| 60 | 285 |
| 61 | 278 |
| 62 | 287 |
| 63 | 316 |
| 64 | 267 |
| 65 | 321 |
| 66 | 232 |
| 67 | 295 |
| 68 | 203 |
| 69 | 256 |
| 70 | 201 |
| 71 | 229 |
| 72 | 232 |
| 73 | 225 |
| 74 | 283 |
| 75 | 239 |
| 76 | 326 |
| 77 | 257 |
| 78 | 337 |
| 79 | 265 |
| 80 | 307 |
| 81 | 259 |
| 82 | 252 |
| 83 | 251 |
| 84 | 202 |
| 85 | 253 |
| 86 | 183 |
| 87 | 269 |
| 88 | 204 |
| 89 | 292 |
| 90 | 250 |
| 91 | 302 |
| 92 | 295 |
| 93 | 288 |
| 94 | 314 |
| 95 | 250 |
| 96 | 302 |
| 97 | 208 |
| 98 | 272 |
| 99 | 187 |
| 100 | 243 |
| 101 | 202 |
| 102 | 232 |
| 103 | 248 |
| 104 | 238 |
| 105 | 302 |
| 106 | 250 |
| 107 | 332 |
| 108 | 253 |
| 109 | 322 |
| 110 | 245 |
| 111 | 276 |
| 112 | 232 |
| 113 | 220 |
| 114 | 231 |
| 115 | 184 |
| 116 | 248 |
| 117 | 184 |
| 118 | 277 |
| 119 | 216 |
| 120 | 299 |
| 121 | 258 |
| 122 | 296 |
| 123 | 286 |
| 124 | 263 |
| 125 | 287 |
| 126 | 213 |
| 127 | 267 |
| 128 | 174 |
| 129 | 242 |
| 130 | 169 |
| 131 | 229 |
| 132 | 202 |
| 133 | 231 |
| 134 | 257 |
| 135 | 239 |
| 136 | 302 |
| 137 | 239 |
| 138 | 313 |
| 139 | 225 |
| 140 | 284 |
| 141 | 206 |
| 142 | 232 |
| 143 | 197 |
| 144 | 185 |
| 145 | 210 |
| 146 | 166 |
| 147 | 242 |
| 148 | 182 |
| 149 | 277 |
| 150 | 216 |
| 151 | 290 |
| 152 | 246 |
| 153 | 268 |
| 154 | 256 |
| 155 | 219 |
| 156 | 245 |
| 157 | 167 |
| 158 | 227 |
| 159 | 140 |
| 160 | 216 |
| 161 | 155 |
| 162 | 218 |
| 163 | 202 |
| 164 | 226 |
| 165 | 256 |
| 166 | 226 |
| 167 | 286 |
| 168 | 210 |
| 169 | 277 |
| 170 | 183 |
| 171 | 236 |
| 172 | 164 |
| 173 | 188 |
| 174 | 167 |
| 175 | 157 |
| 176 | 198 |
| 177 | 156 |
| 178 | 241 |
| 179 | 179 |
| 180 | 271 |
| 181 | 206 |
| 182 | 267 |
| 183 | 220 |
| 184 | 228 |
| 185 | 216 |
| 186 | 170 |
| 187 | 204 |
| 188 | 126 |
| 189 | 197 |
| 190 | 119 |
| 191 | 202 |
| 192 | 152 |
| 193 | 214 |
| 194 | 205 |
| 195 | 219 |
| 196 | 248 |
| 197 | 204 |
| 198 | 260 |
| 199 | 173 |
Box plot chart: Weekly hours per team. No data.
| x | Hours |
|---|---|
| Alpha | min 30, Q1 30, median 30, Q3 37, max 37 |
| Beta | min 33, Q1 35, median 39, Q3 43, max 45 |
| Gamma | min 36, Q1 38, median 42, Q3 46, max 48 |
| Delta | min 39, Q1 41, median 45, Q3 49, max 59 |
Pareto chart: Defects by cause, 1 series, x from Scratches to Other. Defects: 6 points, minimum 5, maximum 46, trending down.
| x | Defects |
|---|---|
| Scratches | 46 |
| Missing screw | 27 |
| Dent | 19 |
| Misalignment | 12 |
| Wrong part | 8 |
| Other | 5 |
Column chart: Effect by dose, 1 series, x from Placebo to 40 mg. Effect: 4 points, minimum 12, maximum 41, trending up.
| x | Effect |
|---|---|
| Placebo | 12 |
| 10 mg | 21 |
| 20 mg | 34 |
| 40 mg | 41 |
Live data
data is reactive: a new array (for example the old one with a point
appended and the oldest dropped) lays the chart out again, within 2 ms for
a 1,000-point window (chart-perf.spec.ts). api.appendPoints(seriesId, points, { maxPoints }) streams points through the chart store without a
React render of the parent; @salmonui/data live sources feed either.
Descriptions
series.description is appended to the chart summary and the accessible
table caption, so screen readers hear what each series means; keyboard focus
moves through the series in series order.
Live data and empty state
Open demoStream server load into one chart through reactive data and into another through api.appendPoints, clear the data to see the empty state, with series descriptions for screen readers.
Line chart: Server load (reactive data), 2 series, x from 0 to 50. CPU: 60 points, minimum 11, maximum 80, trending up. Memory: 60 points, minimum 52, maximum 68, trending down. CPU: CPU use of the web server in percent, sampled four times a second.. Memory: Memory use in percent..
| x | CPU | Memory |
|---|---|---|
| 0 | 45% | 60% |
| 1 | 58% | 61% |
| 2 | 57% | 61% |
| 3 | 49% | 62% |
| 4 | 50% | 63% |
| 5 | 64% | 64% |
| 6 | 74% | 64% |
| 7 | 69% | 65% |
| 8 | 59% | 65% |
| 9 | 61% | 66% |
| 10 | 74% | 66% |
| 11 | 80% | 67% |
| 12 | 71% | 67% |
| 13 | 60% | 67% |
| 14 | 62% | 68% |
| 15 | 72% | 68% |
| 16 | 73% | 68% |
| 17 | 60% | 68% |
| 18 | 49% | 68% |
| 19 | 51% | 68% |
| 20 | 60% | 68% |
| 21 | 57% | 68% |
| 22 | 42% | 67% |
| 23 | 31% | 67% |
| 24 | 36% | 67% |
| 25 | 43% | 66% |
| 26 | 38% | 66% |
| 27 | 23% | 65% |
| 28 | 16% | 64% |
| 29 | 24% | 64% |
| 30 | 32% | 63% |
| 31 | 26% | 63% |
| 32 | 13% | 62% |
| 33 | 11% | 61% |
| 34 | 22% | 60% |
| 35 | 31% | 60% |
| 36 | 25% | 59% |
| 37 | 16% | 58% |
| 38 | 19% | 58% |
| 39 | 33% | 57% |
| 40 | 41% | 56% |
| 41 | 36% | 56% |
| 42 | 29% | 55% |
| 43 | 35% | 54% |
| 44 | 51% | 54% |
| 45 | 58% | 53% |
| 46 | 51% | 53% |
| 47 | 46% | 53% |
| 48 | 54% | 52% |
| 49 | 69% | 52% |
| 50 | 72% | 52% |
| 51 | 63% | 52% |
| 52 | 58% | 52% |
| 53 | 67% | 52% |
| 54 | 79% | 52% |
| 55 | 77% | 52% |
| 56 | 65% | 53% |
| 57 | 59% | 53% |
| 58 | 68% | 53% |
| 59 | 76% | 54% |
Line chart: CPU (streamed with appendPoints), 1 series, x from 0 to 50. CPU: 60 points, minimum 11, maximum 80, trending up. CPU: The same CPU samples, streamed into the chart store..
| x | CPU |
|---|---|
| 0 | 45 |
| 1 | 58 |
| 2 | 57 |
| 3 | 49 |
| 4 | 50 |
| 5 | 64 |
| 6 | 74 |
| 7 | 69 |
| 8 | 59 |
| 9 | 61 |
| 10 | 74 |
| 11 | 80 |
| 12 | 71 |
| 13 | 60 |
| 14 | 62 |
| 15 | 72 |
| 16 | 73 |
| 17 | 60 |
| 18 | 49 |
| 19 | 51 |
| 20 | 60 |
| 21 | 57 |
| 22 | 42 |
| 23 | 31 |
| 24 | 36 |
| 25 | 43 |
| 26 | 38 |
| 27 | 23 |
| 28 | 16 |
| 29 | 24 |
| 30 | 32 |
| 31 | 26 |
| 32 | 13 |
| 33 | 11 |
| 34 | 22 |
| 35 | 31 |
| 36 | 25 |
| 37 | 16 |
| 38 | 19 |
| 39 | 33 |
| 40 | 41 |
| 41 | 36 |
| 42 | 29 |
| 43 | 35 |
| 44 | 51 |
| 45 | 58 |
| 46 | 51 |
| 47 | 46 |
| 48 | 54 |
| 49 | 69 |
| 50 | 72 |
| 51 | 63 |
| 52 | 58 |
| 53 | 67 |
| 54 | 79 |
| 55 | 77 |
| 56 | 65 |
| 57 | 59 |
| 58 | 68 |
| 59 | 76 |
Polar and radar
import { Chart } from '@salmonui/charts/chart';
import { polar } from '@salmonui/charts/chart/features';
<Chart
coordinate="radar"
features={[polar]}
xAxis={{ startAngle: 0 }}
radius={0.9}
data={wind}
series={[
{ type: 'area', xField: 'direction', yField: 'speed' },
{ type: 'line', xField: 'direction', yField: 'gust', closed: false },
]}
/>;
coordinate: 'polar' | 'radar' maps x to the angle (clockwise from
xAxis.startAngle, counterclockwise with xAxis.reversed) and y to the
radius from the center (yAxis.reversed inverts it); radius (0..1)
shrinks the circle. Polar charts draw circles, radar charts polygons
between the spokes. Every polar and radar draw type is a series type:
line, spline (curve), area, spline area, column (wedges, side by
side per series), range column (lowField / highField), scatter, and
the stacking variants with stack; lines and areas close back to the
first point unless series.closed is false. Hover, focus, tooltips,
selection and the accessible table work as on cartesian charts.
The polar layout is an opt-in feature: pass features={[polar]} from
@salmonui/charts/chart/features. It renders on the server and the client alike; a chart without it
never loads the code, draws the frame only and warns in development.
features={[interactions]} bundles the zoom, pan, selection and drag code
so it is ready on the first pointer event instead of loading after
hydration.
Polar and radar charts
Open demoWind speed by direction on polar circles or radar polygons, drawn as lines, areas, wedges or points, stacked or not, from any start angle.
Column chart: Wind by direction, 3 series, x from N to NW. Calm: 8 points, minimum 2, maximum 4, trending up. Speed: 8 points, minimum 8, maximum 16, trending up. Gust: 8 points, minimum 14, maximum 24, trending up.
| x | Calm | Speed | Gust |
|---|---|---|---|
| N | 2 | 8 | 14 |
| NE | 3 | 13 | 21 |
| E | 4 | 9 | 17 |
| SE | 2 | 14 | 24 |
| S | 3 | 10 | 20 |
| SW | 4 | 15 | 16 |
| W | 2 | 11 | 23 |
| NW | 3 | 16 | 19 |
Field mapping
xField, yField, lowField, highField, openField, closeField,
sizeField, colorField and tooltipField read plain records, including
dotted paths such as 'price.close'; series.xAxis / series.yAxis bind a
series to an axis by id. Per-series data overrides the chart
data.
State, events and accessibility
Every interactive state is a controlled triad you can also leave
uncontrolled: hiddenSeries / defaultHiddenSeries /
onHiddenSeriesChange, selectedPoints / defaultSelectedPoints /
onSelectedPointsChange and zoomRange / defaultZoomRange /
onZoomRangeChange. Point and plot events (onPointClick,
onPlotClick, ...) are covered in
Chart interaction.
The chart is a <figure> named by title (or aria-label /
aria-labelledby) with an automatic summary and a visually hidden data
table; the plot is one tab stop with arrow-key navigation between points
and the legend is a toolbar of toggle buttons
(Chart interaction,
"Keyboard").
The server renders the final SVG at the nominal size (width, else 600
px, and height, default 300) and the client relays out once after
hydration if the measured size differs, so there are no hydration
warnings; set locale and timeZone so the server and the browser format
alike (Rendering and colors).
Features and templates
Features load from their props through lazy chunks; nothing is registered up front. Two features are explicit opt-in imports because they do not fit the Chart bundle budget:
import { polar, interactions } from '@salmonui/charts/chart/features';
import { technicalIndicators } from '@salmonui/charts/chart/indicators';
<Chart coordinate="polar" features={[polar]} /* ... */ />;
<Chart indicators={indicators} features={[technicalIndicators]} /* ... */ />;
Passing interactions is optional and makes zoom, pan and selection ready on
the first pointer event.
Custom content comes from render props, never from HTML string templates:
a string template would need HTML parsing and a sanitizer on the render
path and could not be type-checked. Use a tooltip render,
series.renderMarker, an axis renderLabel or renderEmpty:
<Chart tooltip={{ render: ({ header, points }) => <div>{header}: {points[0]?.yText}</div> }} /* ... */ />
Data, state and lifecycle
Data. Chart and the other visualizations take an array in
data. Load the rows through a @salmonui/data source or your own fetch
and pass the result; Kanban takes a @salmonui/data source directly.
Persistence. Components never write to localStorage, and
server output never depends on client storage. To restore a view, store the
controlled values from their change callbacks and pass them back:
zoomRange, hiddenSeries and selectedPoints on Chart, value on
gauges, path on TreeMap, view on GeoMap and columnOrder on
Kanban.
Lifecycle. React owns the lifecycle and renders stay pure, so
there are no load or loaded events that mutate the instance. Configure the
chart through props, and run code that needs the rendered chart in an
effect that reads the ref. There is no animation-complete callback.
Updates. Props are reactive: a changed prop re-renders
only the affected part, so there is no refresh method. If you mutated data
in place, pass a new array. series and axes are plain arrays with one
source of truth, so there are no methods that add or remove series or axes:
keep them in application state and update the arrays. For streaming, use
api.appendPoints(seriesId, points).
WebMCP. WebMCP is a browser API proposal, so components do not
register tools. Your application can register its own tools against the
ref APIs.
3D and specialized charts
There are no 3D charts, because 3D perspective distorts length and area judgments and has poor accessibility.
- 3D column and bar series. Use
Chartwithcolumnandbarseries, in any stacking mode. - Depth, rotation and tilt. Not supported. Scientific 3D plotting would be a separate WebGL product.
- 3D pie and donut. Use PieChart, which has pie, donut, explode, labels, legend, tooltip, selection and export.
- 3D legend, tooltip, labels, selection, export and print. Each
is available on the flat
ChartorPieChart. - Smith chart. Not built, because it serves radio-frequency
engineering only; use a dedicated RF plotting library.
coordinateacceptscartesian,polarandradar. - Chart wizard. There is no built-in chart wizard.
Chartprops are plain data, so an application can build a guided editor on top.
Every prop is listed in the API reference.