Skip to content
nexubDesign System
v11.9.0

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';
View as Markdown

Playground

Props

Revenue ($k)
monthRevenue
Apr162
May185
Jun208
Jul204
Aug227
Sep250
TSX
<ChartZoom data={data} index="month" defaultRange={[3, 8]} className="w-full">…</ChartZoom>

Examples

Zoom a year of revenue

Revenue ($k)
monthRevenue
Apr162
May185
Jun208
Jul204
Aug227
Sep250

States

  • Revenue ($k)
    monthRevenue
    Apr162
    May185
    Jun208
    Jul204
    Aug227
    Sep250
    default
  • Revenue ($k)
    monthRevenue
    Apr162
    May185
    Jun208
    Jul204
    Aug227
    Sep250
    loading

Props

Props
PropTypeDefaultDescription
datarequiredT[]—The full data.
indexrequiredkeyof 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 rangeStarting indexes; the whole range by default.
minSpannumber2Fewest categories shown.
classNamestring—
emptyStateReact.ReactNode—Shown when there is no data. Defaults to the "no data" message.
errorStateReact.ReactNode—Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty.
loadingboolean—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