Charts
Chart interaction
Tooltips, trackball, rectangle and wheel zoom, pan, point selection and the instance API, all driven by a per-chart store instead of React state.
Pointer, wheel and drag transients live in a per-chart store; React re-renders only the tooltip layer when the hovered point changes, never per pointer move. Committed changes go through controlled triads.
Tooltip
tooltip (or tooltip={{ format, header }}) shows the hovered point;
series.tooltip: false opts a series out. tooltip.render(ctx)
returns any ReactNode and runs only for the hovered point.
ref.current.showTooltip({ seriesId, index }) and hideTooltip() open and
close it from code.
tooltip.mode is 'point' (default), 'shared' (one box for every
series at the x) or 'split' (one box per series, each at its own point). tooltip.position is 'nearest' (default: above the nearest
point, found by binary search on the sorted x, no DOM hit-testing),
'pointer' (follows the pointer) or { x, y } (fixed, drawing px), and
tooltip.offset is the gap in px. The tooltip, crosshair and
hover marks are a lazy overlay chunk mounted after hydration; a pointer
move costs one store write (the hover handler stays under 1 ms on 100,000
points, chart-perf.spec.ts).
Crosshair
crosshair draws lines at the pointer: lines: 'both' | 'x' | 'y',
snap (to the nearest point), highlightCategory (shades the hovered
category band), axisLabels (value boxes on the axes) and
formatLabel(value, axisId) for their text. api.showCrosshair(point)
takes a point ({ seriesId, index }) or data values ({ x, y }) and
api.hideCrosshair() hides it; the position lives in the chart store.
Synchronized charts
<ChartSyncGroup tooltip crosshair zoom selection>
<Chart data={a} selection ... />
<Chart data={b} selection ... />
</ChartSyncGroup>
Charts in one ChartSyncGroup share the hovered x (tooltip and
crosshair), the x zoom range and, between charts with selection, the
selected point indices: a click in one chart proposes the same indices in
the others through onSelectedPointsChange with reason: 'sync'. Each
group instance has its own store.
Synchronized charts
Open demoTwo charts in a ChartSyncGroup share the hovered day (tooltip and crosshair), the x zoom range and the selected points; each kind of sync can be switched off.
Area chart: Visitors, 1 series, x from 10 to 60. Visitors: 60 points, minimum 644, maximum 1,207, trending up.
| x | Visitors |
|---|---|
| 1 | 800 |
| 2 | 854 |
| 3 | 905 |
| 4 | 953 |
| 5 | 995 |
| 6 | 1,030 |
| 7 | 1,057 |
| 8 | 1,074 |
| 9 | 1,082 |
| 10 | 1,079 |
| 11 | 1,067 |
| 12 | 1,046 |
| 13 | 1,017 |
| 14 | 981 |
| 15 | 940 |
| 16 | 895 |
| 17 | 849 |
| 18 | 804 |
| 19 | 761 |
| 20 | 723 |
| 21 | 691 |
| 22 | 666 |
| 23 | 650 |
| 24 | 644 |
| 25 | 647 |
| 26 | 660 |
| 27 | 683 |
| 28 | 715 |
| 29 | 754 |
| 30 | 800 |
| 31 | 850 |
| 32 | 903 |
| 33 | 957 |
| 34 | 1,010 |
| 35 | 1,060 |
| 36 | 1,104 |
| 37 | 1,142 |
| 38 | 1,173 |
| 39 | 1,194 |
| 40 | 1,206 |
| 41 | 1,207 |
| 42 | 1,199 |
| 43 | 1,182 |
| 44 | 1,156 |
| 45 | 1,122 |
| 46 | 1,083 |
| 47 | 1,040 |
| 48 | 994 |
| 49 | 948 |
| 50 | 904 |
| 51 | 864 |
| 52 | 829 |
| 53 | 801 |
| 54 | 781 |
| 55 | 771 |
| 56 | 770 |
| 57 | 779 |
| 58 | 798 |
| 59 | 826 |
| 60 | 863 |
Column chart: Orders, 1 series, x from 10 to 60. Orders: 60 points, minimum 30, maximum 64, trending up.
| x | Orders |
|---|---|
| 1 | 48 |
| 2 | 51 |
| 3 | 54 |
| 4 | 55 |
| 5 | 56 |
| 6 | 56 |
| 7 | 57 |
| 8 | 56 |
| 9 | 54 |
| 10 | 52 |
| 11 | 51 |
| 12 | 48 |
| 13 | 45 |
| 14 | 42 |
| 15 | 40 |
| 16 | 37 |
| 17 | 35 |
| 18 | 33 |
| 19 | 32 |
| 20 | 31 |
| 21 | 30 |
| 22 | 30 |
| 23 | 32 |
| 24 | 33 |
| 25 | 34 |
| 26 | 37 |
| 27 | 40 |
| 28 | 43 |
| 29 | 46 |
| 30 | 49 |
| 31 | 53 |
| 32 | 55 |
| 33 | 58 |
| 34 | 60 |
| 35 | 62 |
| 36 | 64 |
| 37 | 64 |
| 38 | 64 |
| 39 | 64 |
| 40 | 63 |
| 41 | 61 |
| 42 | 59 |
| 43 | 57 |
| 44 | 54 |
| 45 | 51 |
| 46 | 48 |
| 47 | 47 |
| 48 | 44 |
| 49 | 42 |
| 50 | 40 |
| 51 | 39 |
| 52 | 38 |
| 53 | 38 |
| 54 | 38 |
| 55 | 40 |
| 56 | 42 |
| 57 | 44 |
| 58 | 46 |
| 59 | 50 |
| 60 | 53 |
Selected days: visitors none, orders none
Plot events and touch
onPlotClick(point, event) and onPlotPointerMove(point, event) fire
anywhere on the plot (not only on points) with drawing coordinates and the
data values under the pointer: { x, y, xValue, yValue }, xValue a
category, Date or number of the x axis and yValue of the first y axis.
onClick, onDoubleClick, onContextMenu and onPointerDown,
onPointerUp, onPointerMove and onPointerLeave are DOM handlers on the
chart root. StockChart and Gauge take the same set, TreeMap the click,
double click, context menu and pointer move handlers. Sparkline and
GeoMap keep their bundles small and take none: put the handlers on a
wrapping element, where these events bubble.
Touch uses Pointer Events: a long press (500 ms) shows the tooltip of the
nearest point and moving the finger cancels it; the plot sets
touch-action: pan-y so the page still scrolls vertically, and none when
zoom, pan, range or lasso selection or point drag need the gestures.
Layout follows the container size, never device detection.
Trackball
crosshair={{ snap: true }} with tooltip={{ mode: 'shared' }} makes a
trackball: the crosshair snaps to the nearest x, every series
at that x is highlighted and listed in one tooltip.
Tooltip, crosshair and trackball
Open demoPoint, shared and split tooltips at the nearest point, the pointer or a fixed position, a custom tooltip render, crosshair lines with axis labels and category highlight, a snapping trackball, the tooltip and crosshair API, keyboard focus and touch long press.
Line chart: Website visits, 3 series, x from Jan to Dec. Organic: 12 points, minimum 2,320, maximum 4,098, trending down. Paid: 12 points, minimum 1,800, maximum 3,030, trending up. Referral: 12 points, minimum 700, maximum 1,070, trending up.
| x | Organic | Paid | Referral |
|---|---|---|---|
| Jan | 3,200 | 1,800 | 700 |
| Feb | 3,631 | 2,210 | 870 |
| Mar | 3,957 | 2,620 | 1,040 |
| Apr | 4,098 | 3,030 | 710 |
| May | 4,018 | 2,140 | 880 |
| Jun | 3,739 | 2,550 | 1,050 |
| Jul | 3,327 | 2,960 | 720 |
| Aug | 2,884 | 2,070 | 890 |
| Sep | 2,519 | 2,480 | 1,060 |
| Oct | 2,320 | 2,890 | 730 |
| Nov | 2,337 | 2,000 | 900 |
| Dec | 2,565 | 2,410 | 1,070 |
Zoom and pan
zoom turns on wheel zoom, rectangle selection zoom and pan;
zoom={{ wheel, selection, pan, mode: 'x' | 'y' | 'xy' }} picks them.
Shift + drag (or drag with selection: false) pans a zoomed
chart; the pan frame stays in the store until release. Every
committed step calls onZoomRangeChange(range, event) with
event.reason 'wheel' | 'selection' | 'pan' | 'pinch' | 'keyboard' | 'toolbar' | 'reset'; a controlled chart vetoes by keeping its
zoomRange; +, - and 0 zoom from the keyboard and
api.resetZoom() resets. zoom.wheel and zoom.pinch (two
touches, touch-action: none on the plot) zoom around the pointer or
the midpoint of the fingers; the pinch frame stays in the store until the
fingers lift; zoom.pinch: false turns pinch off. A wheel step on
100,000 points stays within a 16.7 ms frame at p95 (chart-perf.spec.ts).
zoom.deferred moves only the drawn series during
a pan and lays out once on release.
Lazy loading
onVisibleRangeChange({ axisId, range }) fires when a zoom or pan
commits (never per drag frame), so an application fetches the rows of the
visible range. createRangeSource from @salmonui/data does the fetching:
it widens each request by half its span, caches loaded ranges, aborts
superseded loads and exposes a snapshot for useSyncExternalStore:
import { createRangeSource } from '@salmonui/data';
const source = createRangeSource({ load: ([from, to], { signal }) => fetch(`/ticks?from=${from}&to=${to}`, { signal }).then((r) => r.json()) });
function LiveChart() {
const { rows } = useSyncExternalStore(source.subscribe, source.getSnapshot, source.getSnapshot);
return <Chart data={rows} zoom xAxis={{ scale: 'time', min: start, max: end }} onVisibleRangeChange={({ range }) => source.request(range)} series={[{ xField: 't', yField: 'v' }]} />;
}
There is no axis scrollbar; a linked RangeSelector navigator shows and
moves the zoomed window (see
Chart axes, "Axis scrollbar").
The drag, wheel and pinch code is a lazy chunk loaded after hydration
when zoom, a range or lasso selection, or onPointChange is on; the
plot gets data-interactive once it is ready.
import '@salmonui/navigation/toolbar/styles.css';
import '@salmonui/buttons/button/styles.css';
<Chart zoom={{ toolbar: ['zoom', 'pan', 'zoomIn', 'zoomOut', 'reset'], toolbarPosition: 'topEnd' }} {...props} />
zoom.toolbar (true for every tool, or a list) renders the zoom toolbar
after hydration: Navigation's Toolbar with a ToggleButtonGroup for the
drag tool (rubber-band zoom or pan) and buttons for zoom in, zoom out and
reset (disabled while not zoomed). It loads from the public
@salmonui/navigation/toolbar and @salmonui/buttons/button entries in a lazy
chunk, so import their stylesheets; zoom.toolbarPosition is 'topEnd'
(default), 'topStart', 'bottomEnd' or 'bottomStart', and
text.zoomToolbar, zoomTool, zoomIn, zoomOut, pan and
resetZoom localize the names.
Zoom, pan and the zoom toolbar
Open demoA 2,000-point chart with wheel, pinch and rectangle zoom along x, y or both, pan, deferred pan, the zoom toolbar and a controlled zoom range whose changes and committed visible ranges are logged.
Line chart: Sensor temperature, 1 series, Hour from 400 to 900. Temperature: 2000 points, minimum 12, maximum 29.9, trending up.
| Hour | Temperature |
|---|---|
| 0 | 20 °C |
| 1 | 21.1 °C |
| 2 | 22.2 °C |
| 3 | 23.2 °C |
| 4 | 24.1 °C |
| 5 | 24.9 °C |
| 6 | 25.5 °C |
| 7 | 23.6 °C |
| 8 | 24 °C |
| 9 | 24.2 °C |
| 10 | 24.3 °C |
| 11 | 24.3 °C |
| 12 | 24.3 °C |
| 13 | 24.4 °C |
| 14 | 22.1 °C |
| 15 | 22.3 °C |
| 16 | 22.5 °C |
| 17 | 22.9 °C |
| 18 | 23.4 °C |
| 19 | 24.1 °C |
| 20 | 24.9 °C |
| 21 | 23.5 °C |
| 22 | 24.4 °C |
| 23 | 25.4 °C |
| 24 | 26.5 °C |
| 25 | 27.4 °C |
| 26 | 28.3 °C |
| 27 | 29.1 °C |
| 28 | 27.4 °C |
| 29 | 27.9 °C |
| 30 | 28.3 °C |
| 31 | 28.5 °C |
| 32 | 28.6 °C |
| 33 | 28.5 °C |
| 34 | 28.4 °C |
| 35 | 25.9 °C |
| 36 | 25.7 °C |
| 37 | 25.6 °C |
| 38 | 25.5 °C |
| 39 | 25.5 °C |
| 40 | 25.7 °C |
| 41 | 26 °C |
| 42 | 24 °C |
| 43 | 24.6 °C |
| 44 | 25.2 °C |
| 45 | 25.9 °C |
| 46 | 26.7 °C |
| 47 | 27.5 °C |
| 48 | 28.2 °C |
| 49 | 26.6 °C |
| 50 | 27.2 °C |
| 51 | 27.6 °C |
| 52 | 28 °C |
| 53 | 28.1 °C |
| 54 | 28.1 °C |
| 55 | 28 °C |
| 56 | 25.4 °C |
| 57 | 25.1 °C |
| 58 | 24.7 °C |
| 59 | 24.3 °C |
| 60 | 24 °C |
| 61 | 23.6 °C |
| 62 | 23.4 °C |
| 63 | 21 °C |
| 64 | 21.1 °C |
| 65 | 21.3 °C |
| 66 | 21.6 °C |
| 67 | 22 °C |
| 68 | 22.6 °C |
| 69 | 23.2 °C |
| 70 | 21.5 °C |
| 71 | 22.1 °C |
| 72 | 22.7 °C |
| 73 | 23.1 °C |
| 74 | 23.5 °C |
| 75 | 23.7 °C |
| 76 | 23.8 °C |
| 77 | 21.4 °C |
| 78 | 21.3 °C |
| 79 | 21 °C |
| 80 | 20.6 °C |
| 81 | 20.1 °C |
| 82 | 19.7 °C |
| 83 | 19.3 °C |
| 84 | 16.6 °C |
| 85 | 16.3 °C |
| 86 | 16.2 °C |
| 87 | 16.2 °C |
| 88 | 16.4 °C |
| 89 | 16.7 °C |
| 90 | 17.1 °C |
| 91 | 15.3 °C |
| 92 | 16 °C |
| 93 | 16.7 °C |
| 94 | 17.3 °C |
| 95 | 18 °C |
| 96 | 18.6 °C |
| 97 | 19.1 °C |
| 98 | 17.1 °C |
| 99 | 17.3 °C |
| 100 | 17.4 °C |
| 101 | 17.4 °C |
| 102 | 17.3 °C |
| 103 | 17 °C |
| 104 | 16.8 °C |
| 105 | 14.1 °C |
| 106 | 13.9 °C |
| 107 | 13.7 °C |
| 108 | 13.5 °C |
| 109 | 13.6 °C |
| 110 | 13.7 °C |
| 111 | 14 °C |
| 112 | 12.2 °C |
| 113 | 12.8 °C |
| 114 | 13.5 °C |
| 115 | 14.4 °C |
| 116 | 15.2 °C |
| 117 | 16.2 °C |
| 118 | 17 °C |
| 119 | 15.5 °C |
| 120 | 16.3 °C |
| 121 | 16.9 °C |
| 122 | 17.4 °C |
| 123 | 17.8 °C |
| 124 | 18 °C |
| 125 | 18.1 °C |
| 126 | 15.8 °C |
| 127 | 15.8 °C |
| 128 | 15.7 °C |
| 129 | 15.7 °C |
| 130 | 15.7 °C |
| 131 | 15.8 °C |
| 132 | 16 °C |
| 133 | 14 °C |
| 134 | 14.5 °C |
| 135 | 15.1 °C |
| 136 | 15.9 °C |
| 137 | 16.8 °C |
| 138 | 17.8 °C |
| 139 | 18.9 °C |
| 140 | 17.7 °C |
| 141 | 18.7 °C |
| 142 | 19.8 °C |
| 143 | 20.7 °C |
| 144 | 21.5 °C |
| 145 | 22.2 °C |
| 146 | 22.8 °C |
| 147 | 20.8 °C |
| 148 | 21.1 °C |
| 149 | 21.3 °C |
| 150 | 21.4 °C |
| 151 | 21.4 °C |
| 152 | 21.5 °C |
| 153 | 21.6 °C |
| 154 | 19.4 °C |
| 155 | 19.6 °C |
| 156 | 20 °C |
| 157 | 20.5 °C |
| 158 | 21.2 °C |
| 159 | 22 °C |
| 160 | 22.9 °C |
| 161 | 21.6 °C |
| 162 | 22.6 °C |
| 163 | 23.7 °C |
| 164 | 24.8 °C |
| 165 | 25.8 °C |
| 166 | 26.8 °C |
| 167 | 27.6 °C |
| 168 | 25.9 °C |
| 169 | 26.4 °C |
| 170 | 26.8 °C |
| 171 | 27.1 °C |
| 172 | 27.2 °C |
| 173 | 27.2 °C |
| 174 | 27.1 °C |
| 175 | 24.7 °C |
| 176 | 24.7 °C |
| 177 | 24.7 °C |
| 178 | 24.8 °C |
| 179 | 25 °C |
| 180 | 25.3 °C |
| 181 | 25.8 °C |
| 182 | 24 °C |
| 183 | 24.7 °C |
| 184 | 25.5 °C |
| 185 | 26.4 °C |
| 186 | 27.3 °C |
| 187 | 28.2 °C |
| 188 | 29 °C |
| 189 | 27.5 °C |
| 190 | 28.1 °C |
| 191 | 28.6 °C |
| 192 | 28.9 °C |
| 193 | 29.1 °C |
| 194 | 29.2 °C |
| 195 | 29.1 °C |
| 196 | 26.6 °C |
| 197 | 26.3 °C |
| 198 | 26 °C |
| 199 | 25.7 °C |
| 200 | 25.5 °C |
| 201 | 25.3 °C |
| 202 | 25.2 °C |
| 203 | 22.9 °C |
| 204 | 23.1 °C |
| 205 | 23.5 °C |
| 206 | 23.9 °C |
| 207 | 24.5 °C |
| 208 | 25.1 °C |
| 209 | 25.8 °C |
| 210 | 24.2 °C |
| 211 | 24.8 °C |
| 212 | 25.4 °C |
| 213 | 25.8 °C |
| 214 | 26.2 °C |
| 215 | 26.4 °C |
| 216 | 26.4 °C |
| 217 | 24 °C |
| 218 | 23.7 °C |
| 219 | 23.4 °C |
| 220 | 23 °C |
| 221 | 22.5 °C |
| 222 | 22.1 °C |
| 223 | 21.7 °C |
| 224 | 19 °C |
| 225 | 18.8 °C |
| 226 | 18.7 °C |
| 227 | 18.8 °C |
| 228 | 19 °C |
| 229 | 19.4 °C |
| 230 | 19.8 °C |
| 231 | 18 °C |
| 232 | 18.6 °C |
| 233 | 19.3 °C |
| 234 | 19.9 °C |
| 235 | 20.4 °C |
| 236 | 20.9 °C |
| 237 | 21.3 °C |
| 238 | 19.2 °C |
| 239 | 19.2 °C |
| 240 | 19.2 °C |
| 241 | 19 °C |
| 242 | 18.7 °C |
| 243 | 18.4 °C |
| 244 | 18 °C |
| 245 | 15.3 °C |
| 246 | 14.9 °C |
| 247 | 14.7 °C |
| 248 | 14.5 °C |
| 249 | 14.5 °C |
| 250 | 14.6 °C |
| 251 | 14.9 °C |
| 252 | 13 °C |
| 253 | 13.6 °C |
| 254 | 14.3 °C |
| 255 | 15 °C |
| 256 | 15.8 °C |
| 257 | 16.6 °C |
| 258 | 17.3 °C |
| 259 | 15.7 °C |
| 260 | 16.2 °C |
| 261 | 16.7 °C |
| 262 | 17 °C |
| 263 | 17.2 °C |
| 264 | 17.2 °C |
| 265 | 17.2 °C |
| 266 | 14.7 °C |
| 267 | 14.6 °C |
| 268 | 14.4 °C |
| 269 | 14.3 °C |
| 270 | 14.2 °C |
| 271 | 14.3 °C |
| 272 | 14.4 °C |
| 273 | 12.4 °C |
| 274 | 12.9 °C |
| 275 | 13.5 °C |
| 276 | 14.3 °C |
| 277 | 15.2 °C |
| 278 | 16.2 °C |
| 279 | 17.2 °C |
| 280 | 15.8 °C |
| 281 | 16.8 °C |
| 282 | 17.8 °C |
| 283 | 18.6 °C |
| 284 | 19.3 °C |
| 285 | 19.8 °C |
| 286 | 20.3 °C |
| 287 | 18.2 °C |
| 288 | 18.4 °C |
| 289 | 18.5 °C |
| 290 | 18.5 °C |
| 291 | 18.6 °C |
| 292 | 18.6 °C |
| 293 | 18.7 °C |
| 294 | 16.5 °C |
| 295 | 16.8 °C |
| 296 | 17.3 °C |
| 297 | 17.9 °C |
| 298 | 18.6 °C |
| 299 | 19.5 °C |
| 300 | 20.5 °C |
| 301 | 19.2 °C |
| 302 | 20.3 °C |
| 303 | 21.4 °C |
| 304 | 22.5 °C |
| 305 | 23.5 °C |
| 306 | 24.5 °C |
| 307 | 25.3 °C |
| 308 | 23.6 °C |
| 309 | 24.1 °C |
| 310 | 24.4 °C |
| 311 | 24.7 °C |
| 312 | 24.8 °C |
| 313 | 24.9 °C |
| 314 | 24.9 °C |
| 315 | 22.6 °C |
| 316 | 22.6 °C |
| 317 | 22.8 °C |
| 318 | 23 °C |
| 319 | 23.3 °C |
| 320 | 23.8 °C |
| 321 | 24.5 °C |
| 322 | 22.9 °C |
| 323 | 23.8 °C |
| 324 | 24.7 °C |
| 325 | 25.7 °C |
| 326 | 26.7 °C |
| 327 | 27.7 °C |
| 328 | 28.6 °C |
| 329 | 27.1 °C |
| 330 | 27.8 °C |
| 331 | 28.3 °C |
| 332 | 28.7 °C |
| 333 | 28.9 °C |
| 334 | 29 °C |
| 335 | 29 °C |
| 336 | 26.5 °C |
| 337 | 26.4 °C |
| 338 | 26.2 °C |
| 339 | 26 °C |
| 340 | 25.9 °C |
| 341 | 25.9 °C |
| 342 | 26 °C |
| 343 | 23.9 °C |
| 344 | 24.3 °C |
| 345 | 24.8 °C |
| 346 | 25.4 °C |
| 347 | 26.1 °C |
| 348 | 26.9 °C |
| 349 | 27.7 °C |
| 350 | 26.1 °C |
| 351 | 26.8 °C |
| 352 | 27.4 °C |
| 353 | 27.9 °C |
| 354 | 28.2 °C |
| 355 | 28.4 °C |
| 356 | 28.4 °C |
| 357 | 26 °C |
| 358 | 25.8 °C |
| 359 | 25.5 °C |
| 360 | 25.1 °C |
| 361 | 24.7 °C |
| 362 | 24.3 °C |
| 363 | 24 °C |
| 364 | 21.4 °C |
| 365 | 21.3 °C |
| 366 | 21.3 °C |
| 367 | 21.5 °C |
| 368 | 21.8 °C |
| 369 | 22.2 °C |
| 370 | 22.7 °C |
| 371 | 21 °C |
| 372 | 21.6 °C |
| 373 | 22.2 °C |
| 374 | 22.8 °C |
| 375 | 23.3 °C |
| 376 | 23.7 °C |
| 377 | 24 °C |
| 378 | 21.7 °C |
| 379 | 21.7 °C |
| 380 | 21.6 °C |
| 381 | 21.3 °C |
| 382 | 20.9 °C |
| 383 | 20.5 °C |
| 384 | 20.1 °C |
| 385 | 17.3 °C |
| 386 | 16.9 °C |
| 387 | 16.6 °C |
| 388 | 16.5 °C |
| 389 | 16.5 °C |
| 390 | 16.6 °C |
| 391 | 16.9 °C |
| 392 | 15 °C |
| 393 | 15.5 °C |
| 394 | 16.1 °C |
| 395 | 16.8 °C |
| 396 | 17.5 °C |
| 397 | 18.2 °C |
| 398 | 18.8 °C |
| 399 | 16.9 °C |
| 400 | 17.3 °C |
| 401 | 17.6 °C |
| 402 | 17.8 °C |
| 403 | 17.8 °C |
| 404 | 17.6 °C |
| 405 | 17.4 °C |
| 406 | 14.8 °C |
| 407 | 14.6 °C |
| 408 | 14.3 °C |
| 409 | 14.1 °C |
| 410 | 13.9 °C |
| 411 | 13.9 °C |
| 412 | 14.1 °C |
| 413 | 12 °C |
| 414 | 12.5 °C |
| 415 | 13.1 °C |
| 416 | 13.8 °C |
| 417 | 14.6 °C |
| 418 | 15.5 °C |
| 419 | 16.4 °C |
| 420 | 15 °C |
| 421 | 15.8 °C |
| 422 | 16.6 °C |
| 423 | 17.2 °C |
| 424 | 17.8 °C |
| 425 | 18.2 °C |
| 426 | 18.4 °C |
| 427 | 16.3 °C |
| 428 | 16.3 °C |
| 429 | 16.3 °C |
| 430 | 16.2 °C |
| 431 | 16.2 °C |
| 432 | 16.2 °C |
| 433 | 16.2 °C |
| 434 | 14.1 °C |
| 435 | 14.4 °C |
| 436 | 14.9 °C |
| 437 | 15.5 °C |
| 438 | 16.3 °C |
| 439 | 17.2 °C |
| 440 | 18.1 °C |
| 441 | 16.9 °C |
| 442 | 18 °C |
| 443 | 19.1 °C |
| 444 | 20.1 °C |
| 445 | 21.1 °C |
| 446 | 21.9 °C |
| 447 | 22.6 °C |
| 448 | 20.9 °C |
| 449 | 21.3 °C |
| 450 | 21.6 °C |
| 451 | 21.8 °C |
| 452 | 21.9 °C |
| 453 | 22 °C |
| 454 | 22 °C |
| 455 | 19.8 °C |
| 456 | 19.9 °C |
| 457 | 20.1 °C |
| 458 | 20.5 °C |
| 459 | 21 °C |
| 460 | 21.6 °C |
| 461 | 22.4 °C |
| 462 | 20.9 °C |
| 463 | 21.9 °C |
| 464 | 22.9 °C |
| 465 | 24 °C |
| 466 | 25.1 °C |
| 467 | 26.1 °C |
| 468 | 27.1 °C |
| 469 | 25.6 °C |
| 470 | 26.3 °C |
| 471 | 26.9 °C |
| 472 | 27.3 °C |
| 473 | 27.5 °C |
| 474 | 27.7 °C |
| 475 | 27.7 °C |
| 476 | 25.3 °C |
| 477 | 25.2 °C |
| 478 | 25.2 °C |
| 479 | 25.2 °C |
| 480 | 25.2 °C |
| 481 | 25.4 °C |
| 482 | 25.7 °C |
| 483 | 23.8 °C |
| 484 | 24.3 °C |
| 485 | 25 °C |
| 486 | 25.8 °C |
| 487 | 26.6 °C |
| 488 | 27.5 °C |
| 489 | 28.4 °C |
| 490 | 26.9 °C |
| 491 | 27.7 °C |
| 492 | 28.4 °C |
| 493 | 28.9 °C |
| 494 | 29.3 °C |
| 495 | 29.5 °C |
| 496 | 29.5 °C |
| 497 | 27.1 °C |
| 498 | 27 °C |
| 499 | 26.7 °C |
| 1500 more rows not shown | |
zoomRange.x: 400–900
Selection
selection (or selection={{ mode: 'point' | 'series', multiple }})
selects points by click or Enter; the triad is selectedPoints /
defaultSelectedPoints / onSelectedPointsChange(points, event) with
{ seriesId, index } entries, and Ctrl / Cmd adds to the selection.
Selected marks carry data-selected for styling; series under a
legend hover carry data-highlighted and the others data-dimmed.
mode: 'series' selects the whole series and mode: 'cluster'
every series' point at the clicked index.
selection={{ mode: 'range', axis: 'x' | 'y' | 'xy' }} selects the points
inside a dragged rectangle (a band along x or y for one axis) and
mode: 'lasso' the points inside a drawn polygon (point-in-polygon on the
model's anchors, no DOM hit-testing). Both propose the points through
onSelectedPointsChange with reason: 'range' | 'lasso' and call
onRangeSelect({ ranges, points }, event) with the data range per axis.
highlight: 'series' | 'point' | 'cluster' fades everything but the
hovered series, point or index (data-faded, set on the marks without a
React render), and legend.highlight dims the other series while a legend
item is hovered or focused. onPointClick,
onPointDoubleClick and onPointHover receive the point context
{ seriesId, index, datum, x, y, ... }.
Editing points
<Chart
data={rows}
series={[{ xField: 'month', yField: 'units', markers: true, editable: { min: 0, max: 100, step: 1 } }]}
onPointChange={({ index, value }) => setRows((r) => r.map((d, i) => (i === index ? { ...d, units: value } : d)))}
/>
series.editable lets the pointer drag a point's value; the preview is a
store overlay and onPointChange({ seriesId, index, value }, event) fires
once on release with the value clamped to min / max. With the plot
focused, Up / Down (Left / Right in a horizontal chart) step the focused
point by step (default a tenth of the tick interval, Shift for ten
steps). Edits are proposals: the application updates data.
Selection, highlight, point events and editing
Open demoPoint, series and cluster selection with a controlled selectedPoints list, hover highlight, styling hooks, point and plot events, range and lasso selection on a scatter chart, and a line whose points are edited by drag or keyboard.
Column chart: Sales by region, 3 series, x from Q1 to Q6. North: 6 points, minimum 40, maximum 55, trending up. South: 6 points, minimum 30, maximum 55, trending up. West: 6 points, minimum 22, maximum 37, trending up.
| x | North | South | West |
|---|---|---|---|
| Q1 | 40 | 30 | 22 |
| Q2 | 53 | 47 | 29 |
| Q3 | 41 | 34 | 36 |
| Q4 | 54 | 51 | 23 |
| Q5 | 42 | 38 | 30 |
| Q6 | 55 | 55 | 37 |
selectedPoints: none
Scatter chart: Samples, 1 series, x from 0 to 80. Samples: 60 points, minimum 0, maximum 99, trending up.
| x | Samples |
|---|---|
| 0 | 0 |
| 37 | 61 |
| 74 | 22 |
| 11 | 83 |
| 48 | 44 |
| 85 | 5 |
| 22 | 66 |
| 59 | 27 |
| 96 | 88 |
| 33 | 49 |
| 70 | 10 |
| 7 | 71 |
| 44 | 32 |
| 81 | 93 |
| 18 | 54 |
| 55 | 15 |
| 92 | 76 |
| 29 | 37 |
| 66 | 98 |
| 3 | 59 |
| 40 | 20 |
| 77 | 81 |
| 14 | 42 |
| 51 | 3 |
| 88 | 64 |
| 25 | 25 |
| 62 | 86 |
| 99 | 47 |
| 36 | 8 |
| 73 | 69 |
| 10 | 30 |
| 47 | 91 |
| 84 | 52 |
| 21 | 13 |
| 58 | 74 |
| 95 | 35 |
| 32 | 96 |
| 69 | 57 |
| 6 | 18 |
| 43 | 79 |
| 80 | 40 |
| 17 | 1 |
| 54 | 62 |
| 91 | 23 |
| 28 | 84 |
| 65 | 45 |
| 2 | 6 |
| 39 | 67 |
| 76 | 28 |
| 13 | 89 |
| 50 | 50 |
| 87 | 11 |
| 24 | 72 |
| 61 | 33 |
| 98 | 94 |
| 35 | 55 |
| 72 | 16 |
| 9 | 77 |
| 46 | 38 |
| 83 | 99 |
Line chart: Planned units (drag a point, or focus the plot and press Up / Down), 1 series, x from Q1 to Q6. Units: 6 points, minimum 12, maximum 25, trending up.
| x | Units |
|---|---|
| Q1 | 12 |
| Q2 | 18 |
| Q3 | 15 |
| Q4 | 22 |
| Q5 | 19 |
| Q6 | 25 |
Keyboard
The plot is one tab stop. Arrow keys move a virtual focus between points,
Home / End jump to the ends, PageUp / PageDown switch series, Enter
selects, Escape closes the tooltip; the focused point is announced through
a polite live region. Every figure family (PieChart, FunnelChart, HeatMap, TreeMap,
SankeyChart, GeoMap, Gauge, BulletChart) follows the same model:
one tab stop, a virtual focus announced politely, legends as APG
Toolbars; their accessibility trees are pinned as ARIA snapshots.
There are no global shortcuts: a key like Alt+J collides with
screen reader and browser keys, and intercepting Ctrl+P would hijack
browser printing. Each visualization is one tab stop with the full keyboard
model inside. For a shortcut, call api.focus() from your own key handler,
and call api.print() from a button.
Reference
ChartApi (the ref), ChartTooltipOptions, ChartCrosshairOptions,
ChartZoomOptions and ChartSyncGroupProps are in the
API reference; the interactions feature
is in @salmonui/charts/chart/features.