Components · Data Display
Chart Zoom
BetaAdded v6.6.0
Zoom any chart to part of its range with a two-thumb slider.
import { ChartZoom } from '@nexub/react';Playground
Props
| month | Revenue |
|---|---|
| Apr | 162 |
| May | 185 |
| Jun | 208 |
| Jul | 204 |
| Aug | 227 |
| Sep | 250 |
<ChartZoom data={data} index="month" defaultRange={[3, 8]} className="w-full">…</ChartZoom>Examples
Zoom a year of revenue
States
Revenue ($k) month Revenue Apr 162 May 185 Jun 208 Jul 204 Aug 227 Sep 250 defaultRevenue ($k) month Revenue Apr 162 May 185 Jun 208 Jul 204 Aug 227 Sep 250 loading
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| datarequired | T[] | — | The full data. |
| indexrequired | keyof T | — | The category key; its values label the range. |
| childrenrequired | (slice: T[], state: DataStateProps) => React.ReactNode | — | Render the chart for the visible slice. |
| defaultRange | [number, number] | the whole range | Starting indexes; the whole range by default. |
| minSpan | number | 2 | Fewest categories shown. |
| className | string | — | |
| emptyState | React.ReactNode | — | Shown when there is no data. Defaults to the "no data" message. |
| errorState | React.ReactNode | — | Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty. |
| loading | boolean | — | Shows a skeleton in place of the data and sets aria-busy. |
Accessibility
Keyboard
- Arrow keys / Home / End
Move the focused thumb.
Notes
Thumbs read "Zoom start: Mar" and "Zoom end: Sep". Charts themselves stay server components; only this wrapper runs on the client.
On iOS & Android
Web only
Chart Zoom has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.