# Scrubber
An interactive scrubber component for exploring individual data points in charts. Displays values on hover or drag and supports custom labels and formatting.
## Import
```tsx
import { Scrubber } from '@coinbase/cds-web-visualization'
```
## Examples
### Basic Example
Scrubber can be used to provide horizontal interaction with a chart. As your mouse hovers over the chart, you will see a reference line and scrubber head following your cursor.
```jsx live
```
### Multiple Series
All series will be scrubbed by default. You can set the `seriesIds` prop to restrict the scrubbing to specific series.
```jsx live
(
),
},
{
id: 'bottom',
data: [4, 8, 11, 15, 16, 14, 16, 10, 12, 14],
color: '#800080',
curve: 'step',
AreaComponent: DottedArea,
showArea: true,
},
]}
>
```
### Labels
Setting the `label` prop for a series will display a label above the scrubber head.
```jsx live
```
### Pulsing
Setting the `idlePulse` prop will cause the scrubber heads to pulse when the user is not actively scrubbing.
```jsx live
```
#### With Imperative Handle
You can also use the imperative handle to pulse the scrubber heads programmatically.
```jsx live
function ImperativeHandle() {
const scrubberRef = useRef(null);
return (
({ min, max: max - 32 }),
}}
showYAxis
yAxis={{
domain: {
min: 0,
},
showGrid: true,
tickLabelFormatter: (value) => value.toLocaleString(),
}}
>
);
}
```
### Disable Overlay When Scrubbing
By default, the scrubber will show an overlay to de-emphasize future data. You can hide this by setting the `hideOverlay` prop to `true`.
```jsx live
```
## Props
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `BeaconComponent` | `ComponentClass \| FunctionComponent` | No | `-` | Custom component for the scrubber beacon. |
| `BeaconLabelComponent` | `ComponentClass \| FunctionComponent` | No | `-` | Custom component for the scrubber beacon label. |
| `LineComponent` | `FunctionComponent \| ComponentClass` | No | `-` | Custom component for the scrubber line. |
| `classNames` | `{ overlay?: string; beacon?: string \| undefined; line?: string \| undefined; beaconLabel?: string \| undefined; } \| undefined` | No | `-` | Custom class names for scrubber elements. |
| `hideLine` | `boolean` | No | `-` | Hides the scrubber line |
| `hideOverlay` | `boolean` | No | `-` | Whether to hide the overlay rect which obscures future data. |
| `idlePulse` | `boolean` | No | `-` | Pulse the scrubber beacon while it is at rest. |
| `key` | `Key \| null` | No | `-` | - |
| `label` | `ChartTextChildren \| ((dataIndex: number) => ChartTextChildren)` | No | `-` | Label text displayed above the scrubber line. |
| `labelProps` | `ReferenceLineLabelProps` | No | `-` | Props passed to the scrubber lines label. |
| `lineStroke` | `string` | No | `-` | Stroke color for the scrubber line. |
| `overlayOffset` | `number` | No | `2` | Offset of the overlay rect relative to the drawing area. Useful for when scrubbing over lines, where the stroke width would cause part of the line to be visible. |
| `ref` | `((instance: ScrubberBeaconRef \| null) => void) \| RefObject \| null` | No | `-` | - |
| `seriesIds` | `string[]` | No | `-` | An array of series IDs that will receive visual emphasis as the user scrubs through the chart. Use this prop to restrict the scrubbing visual behavior to specific series. By default, all series will be highlighted by the Scrubber. |
| `styles` | `{ overlay?: CSSProperties; beacon?: CSSProperties \| undefined; line?: CSSProperties \| undefined; beaconLabel?: CSSProperties \| undefined; } \| undefined` | No | `-` | Custom styles for scrubber elements. |
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |