# SparklineInteractive
The SparklineInteractive is used to display a Sparkline that has multiple time periods
## Import
```tsx
import { SparklineInteractive } from '@coinbase/cds-web-visualization'
```
## Examples
### Default usage
```jsx live
```
### Fill Type
The fill will be added by default with a gradient style. You can set `fillType="dotted"` to get a dotted gradient fill.
```jsx live
```
### Compact
```jsx live
```
### Hide period selector
```jsx live
```
### Scaling Factor
The scaling factor is usually used when you want to show less variance in the chart. An example of this is a stable coin that doesn't change price by more than a few cents.
```jsx live
```
### With header
```jsx live
```
### Custom hover data
```jsx live
```
### Period selector placement
`periodSelectorPlacement` can be used to place the period selector in different positions (`above` or `below`).
```jsx live
```
### Custom styles
You can also provide custom styles, such as to remove any horizontal padding from the header.
```jsx live
```
## Props
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `defaultPeriod` | `string` | Yes | `-` | default period value that the chart will use |
| `formatDate` | `ChartFormatDate` | Yes | `-` | function used to format the date that is shown in the bottom of the chart as the user scrubs |
| `periods` | `{ label: string; value: Period; }[]` | Yes | `-` | A list of periods that the chart will use. label is what is shown in the bottom of the chart and the value is the key. |
| `strokeColor` | `string` | Yes | `-` | Color of the line* |
| `className` | `string` | No | `-` | Custom class name for the root element. |
| `classNames` | `{ header?: string; root?: string \| undefined; } \| undefined` | No | `-` | Custom class names for the component. |
| `compact` | `boolean` | No | `false` | Show the chart in compact height |
| `data` | `Record` | No | `-` | Chart data bucketed by Period. Period is a string key |
| `disableScrubbing` | `boolean` | No | `false` | Disables the scrub user interaction from the chart |
| `fallback` | `null \| string \| number \| false \| true \| ReactElement> \| Iterable \| ReactPortal` | No | `-` | Fallback shown in the chart when data is not available. This is usually a loading state. |
| `fallbackType` | `positive \| negative` | No | `-` | If you use the default fallback then this specifies if the fallback line is decreasing or increasing |
| `fill` | `boolean` | No | `true` | Adds an area fill to the Sparkline |
| `fillType` | `dotted \| gradient` | No | `'gradient'` | Type of fill to use for the area |
| `formatHoverDate` | `((date: Date, period: Period) => string)` | No | `-` | Formats the date above the chart as you scrub. Omit this if you dont want to show the date as the user scrubs |
| `formatHoverPrice` | `((price: number) => string)` | No | `-` | Formats the price above the chart as you scrub. Omit this if you dont want to show the price as the user scrubs |
| `headerNode` | `null \| string \| number \| false \| true \| ReactElement> \| Iterable \| ReactPortal` | No | `-` | Adds a header node above the chart. It will be placed next to the period selector on web. |
| `headerTestID` | `string` | No | `-` | Test ID for the header |
| `hidePeriodSelector` | `boolean` | No | `false` | Hides the period selector at the bottom of the chart |
| `hoverData` | `Record` | No | `-` | Optional data to show on hover/scrub instead of the original sparkline. This allows multiple timeseries lines. Period => timeseries list |
| `onPeriodChanged` | `((period: Period) => void)` | No | `-` | Callback when the user selects a new period. |
| `onScrub` | `((params: ChartScrubParams) => void)` | No | `-` | Callback used when the user is scrubbing. This will be called for every data point change. |
| `onScrubEnd` | `(() => void)` | No | `-` | Callback when a user finishes scrubbing |
| `onScrubStart` | `(() => void)` | No | `-` | Callback when the user starts scrubbing |
| `periodSelectorPlacement` | `above \| below` | No | `-` | Optional placement prop that position the period selector component above or below the chart |
| `style` | `CSSProperties` | No | `-` | Custom styles for the root element. |
| `styles` | `{ header?: CSSProperties; root?: CSSProperties \| undefined; } \| undefined` | No | `-` | Custom styles for the component. |
| `timePeriodGutter` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | Optional gutter to add to the Period selector. This is useful if you choose to use the full screen width for the chart |
| `yAxisScalingFactor` | `number` | No | `-` | Scales the sparkline to show more or less variance. Use a number less than 1 for less variance and a number greater than 1 for more variance. If you use a number greater than 1 it may clip the boundaries of the sparkline. |