|
1 | 1 | --- |
2 | | -title: Chart |
3 | | -description: A customizable chart component to visualize your data. 📊 |
4 | | -lastUpdated: 11 Aug, 2025 |
| 2 | +title: Area Chart |
| 3 | +description: A customizable area chart component to visualize your data with gradient fills and smooth curves. 📈 |
| 4 | +lastUpdated: 12 Aug, 2025 |
5 | 5 | --- |
6 | 6 |
|
7 | 7 | <ComponentShowcase name="area-chart-style-default" /> |
8 | 8 | <br /> |
9 | 9 | <br /> |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +<ComponentInstall> |
| 14 | + <ComponentInstall.Cli npmCommand="npx shadcn@latest add 'https://retroui.dev/r/area-chart.json'" /> |
| 15 | + <ComponentInstall.Manual> |
| 16 | + |
| 17 | +#### 1. Install dependencies: |
| 18 | + |
| 19 | +```sh |
| 20 | +npm install recharts |
| 21 | +``` |
| 22 | + |
| 23 | +<br /> |
| 24 | + |
| 25 | +#### 2. Copy the code 👇 into your project: |
| 26 | + |
| 27 | +## <ComponentSource name="areaChart" /> |
| 28 | + |
| 29 | +</ComponentInstall.Manual> |
| 30 | +</ComponentInstall> |
| 31 | + |
| 32 | +<br /> |
| 33 | +<br /> |
| 34 | + |
| 35 | +## Examples |
| 36 | + |
| 37 | +### Default |
| 38 | + |
| 39 | +<ComponentShowcase name="area-chart-style-default" /> |
| 40 | +<br /> |
| 41 | +<br /> |
| 42 | + |
| 43 | +### Multiple Categories |
| 44 | + |
10 | 45 | <ComponentShowcase name="area-chart-style-multiple" /> |
| 46 | +<br /> |
| 47 | +<br /> |
| 48 | + |
| 49 | +### Stacked Areas |
| 50 | + |
| 51 | +<ComponentShowcase name="area-chart-style-stacked" /> |
| 52 | +<br /> |
| 53 | +<br /> |
| 54 | + |
| 55 | +## API Reference |
11 | 56 |
|
| 57 | +<Table> |
| 58 | + <Table.Header> |
| 59 | + <Table.Row> |
| 60 | + <Table.Head>Prop</Table.Head> |
| 61 | + <Table.Head>Type</Table.Head> |
| 62 | + <Table.Head>Default</Table.Head> |
| 63 | + <Table.Head>Description</Table.Head> |
| 64 | + </Table.Row> |
| 65 | + </Table.Header> |
| 66 | + <Table.Body> |
| 67 | + <Table.Row> |
| 68 | + <Table.Cell className="font-medium">data</Table.Cell> |
| 69 | + <Table.Cell className="*:text-xs">`Record<string, any>[]`</Table.Cell> |
| 70 | + <Table.Cell className="*:text-xs">`[]`</Table.Cell> |
| 71 | + <Table.Cell>Array of data objects to display</Table.Cell> |
| 72 | + </Table.Row> |
| 73 | + <Table.Row> |
| 74 | + <Table.Cell className="font-medium">index</Table.Cell> |
| 75 | + <Table.Cell className="*:text-xs">`string`</Table.Cell> |
| 76 | + <Table.Cell className="*:text-xs">-</Table.Cell> |
| 77 | + <Table.Cell>Key for the x-axis (category) data</Table.Cell> |
| 78 | + </Table.Row> |
| 79 | + <Table.Row> |
| 80 | + <Table.Cell className="font-medium">categories</Table.Cell> |
| 81 | + <Table.Cell className="*:text-xs">`string[]`</Table.Cell> |
| 82 | + <Table.Cell className="*:text-xs">`[]`</Table.Cell> |
| 83 | + <Table.Cell>Array of keys for the data values to display as areas</Table.Cell> |
| 84 | + </Table.Row> |
| 85 | + <Table.Row> |
| 86 | + <Table.Cell className="font-medium">fill</Table.Cell> |
| 87 | + <Table.Cell className="*:text-xs">`"gradient" | "solid"`</Table.Cell> |
| 88 | + <Table.Cell className="*:text-xs">`"gradient"`</Table.Cell> |
| 89 | + <Table.Cell>Fill style for the areas</Table.Cell> |
| 90 | + </Table.Row> |
| 91 | + <Table.Row> |
| 92 | + <Table.Cell className="font-medium">strokeColors</Table.Cell> |
| 93 | + <Table.Cell className="*:text-xs">`string[]`</Table.Cell> |
| 94 | + <Table.Cell className="*:text-xs">`["var(--foreground)"]`</Table.Cell> |
| 95 | + <Table.Cell>Array of stroke colors for the areas</Table.Cell> |
| 96 | + </Table.Row> |
| 97 | + <Table.Row> |
| 98 | + <Table.Cell className="font-medium">fillColors</Table.Cell> |
| 99 | + <Table.Cell className="*:text-xs">`string[]`</Table.Cell> |
| 100 | + <Table.Cell className="*:text-xs">`["var(--primary)"]`</Table.Cell> |
| 101 | + <Table.Cell>Array of fill colors for the areas</Table.Cell> |
| 102 | + </Table.Row> |
| 103 | + <Table.Row> |
| 104 | + <Table.Cell className="font-medium">tooltipBgColor</Table.Cell> |
| 105 | + <Table.Cell className="*:text-xs">`string`</Table.Cell> |
| 106 | + <Table.Cell className="*:text-xs">`"var(--background)"`</Table.Cell> |
| 107 | + <Table.Cell>Background color for tooltips</Table.Cell> |
| 108 | + </Table.Row> |
| 109 | + <Table.Row> |
| 110 | + <Table.Cell className="font-medium">tooltipBorderColor</Table.Cell> |
| 111 | + <Table.Cell className="*:text-xs">`string`</Table.Cell> |
| 112 | + <Table.Cell className="*:text-xs">`"var(--border)"`</Table.Cell> |
| 113 | + <Table.Cell>Border color for tooltips</Table.Cell> |
| 114 | + </Table.Row> |
| 115 | + <Table.Row> |
| 116 | + <Table.Cell className="font-medium">gridColor</Table.Cell> |
| 117 | + <Table.Cell className="*:text-xs">`string`</Table.Cell> |
| 118 | + <Table.Cell className="*:text-xs">`"var(--muted)"`</Table.Cell> |
| 119 | + <Table.Cell>Color for the grid lines</Table.Cell> |
| 120 | + </Table.Row> |
| 121 | + <Table.Row> |
| 122 | + <Table.Cell className="font-medium">valueFormatter</Table.Cell> |
| 123 | + <Table.Cell className="*:text-xs">`(value: number) => string`</Table.Cell> |
| 124 | + <Table.Cell className="*:text-xs">`(value) => value.toString()`</Table.Cell> |
| 125 | + <Table.Cell>Function to format values</Table.Cell> |
| 126 | + </Table.Row> |
| 127 | + <Table.Row> |
| 128 | + <Table.Cell className="font-medium">showGrid</Table.Cell> |
| 129 | + <Table.Cell className="*:text-xs">`boolean`</Table.Cell> |
| 130 | + <Table.Cell className="*:text-xs">`true`</Table.Cell> |
| 131 | + <Table.Cell>Whether to show grid lines</Table.Cell> |
| 132 | + </Table.Row> |
| 133 | + <Table.Row> |
| 134 | + <Table.Cell className="font-medium">showTooltip</Table.Cell> |
| 135 | + <Table.Cell className="*:text-xs">`boolean`</Table.Cell> |
| 136 | + <Table.Cell className="*:text-xs">`true`</Table.Cell> |
| 137 | + <Table.Cell>Whether to show tooltips on hover</Table.Cell> |
| 138 | + </Table.Row> |
| 139 | + <Table.Row> |
| 140 | + <Table.Cell className="font-medium">className</Table.Cell> |
| 141 | + <Table.Cell className="*:text-xs">`string`</Table.Cell> |
| 142 | + <Table.Cell className="*:text-xs">-</Table.Cell> |
| 143 | + <Table.Cell>Additional CSS classes</Table.Cell> |
| 144 | + </Table.Row> |
| 145 | + </Table.Body> |
| 146 | +</Table> |
0 commit comments