File size: 1,775 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
title: Sparkline
description:
  A small, simple chart without axes or coordinates that shows the general shape
  of data variation, typically used inline with text or in small spaces
links:
  storybook: charts-sparkline--basic
---

<ExampleTabs name="charts/sparkline-basic" />

## Usage

```tsx
import { Chart, useChart } from "@chakra-ui/charts"
import { Area, AreaChart } from "recharts"
```

```tsx
<Chart.Root>
  <AreaChart>
    <Area />
  </AreaChart>
</Chart.Root>
```

## Examples

### Bar Chart

Sparklines can be made with bar charts.

<ExampleTabs name="charts/sparkline-bar-chart" />

### Line Chart

Sparklines can also be made with line charts.

<ExampleTabs name="charts/sparkline-line-chart" />

### Stock

Here's a composition of a sparkline that shows stock prices.

<ExampleTabs name="charts/sparkline-composition-stock" />

### Stat

Here's a composition of a sparkline that shows a SaaS dashboard stat.

<ExampleTabs name="charts/sparkline-composition-stat" />

### Gradient

Use the `Chart.Gradient` component to create a gradient fill.

```tsx {4-7}
<defs>
  <Chart.Gradient
    id="custom-gradient"
    stops={[
      { offset: "0%", color: "teal.solid", opacity: 1 },
      { offset: "100%", color: "teal.solid", opacity: 0.01 },
    ]}
  />
</defs>
```

<ExampleTabs name="charts/sparkline-with-gradient" />

### Reference

To reference a specific value on the sparkline, use the `Reference` component
from `recharts`.

<ExampleTabs name="charts/sparkline-with-reference" />

### Interaction

Here's an example that mimics the NPM download stats.

<ExampleTabs name="charts/sparkline-with-interaction" />

### Composition

Here's a composition that shows a sparkline for a stock price.

<ExampleTabs name="charts/sparkline-composition-stock" />