# Area Chart

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/area-chart
- **Markdown:** https://refast.fastapicloud.dev/docs/components/area-chart.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/charts/area_chart.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

Area charts are like line charts but with the region below the line filled in,
making them useful for showing volume, cumulative totals, or part-to-whole relationships.

```python
from refast.components.shadcn.charts import (
    ChartContainer, AreaChart, Area,
    CartesianGrid, XAxis,
    ChartTooltip, ChartTooltipContent,
    ChartLegend, ChartLegendContent,
)

data = [
    {"month": "January",  "desktop": 186, "mobile": 80},
    {"month": "February", "desktop": 305, "mobile": 200},
    {"month": "March",    "desktop": 237, "mobile": 120},
]

ChartContainer(class_name="h-64", children=[
    AreaChart(data=data, children=[
        CartesianGrid(vertical=False),
        XAxis(data_key="month", tick_line=False, axis_line=False),
        ChartTooltip(content=ChartTooltipContent()),
        ChartLegend(content=ChartLegendContent()),
        Area(data_key="desktop", label="Desktop", fill_opacity=0.4, type="monotone"),
        Area(data_key="mobile",  label="Mobile",  fill_opacity=0.4, type="monotone"),
    ]),
])
```

### Stacked Area Chart

Pass the same `stacked_id` to multiple `Area` components to stack them:

```python
Area(data_key="desktop", label="Desktop", stacked_id="areas", ...)
Area(data_key="mobile",  label="Mobile",  stacked_id="areas", ...)
```

## AreaChart Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `data` | `list[dict]` | *(required)* | Array of data objects |
| `layout` | `"horizontal" \| "vertical"` | `"horizontal"` | Chart orientation |
| `margin` | `dict` | `{top:10, right:10, left:10, bottom:0}` | Chart margins |
| `stack_offset` | `str \| None` | `None` | `"expand"`, `"wiggle"`, `"silhouette"` for stacked areas |
| `base_value` | `int \| str \| None` | `None` | Baseline value for areas |
| `on_click` | `Callback \| None` | `None` | Click on the chart |
| `children` | `list` | `[]` | Axes, areas, tooltip, legend |

## Area Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `data_key` | `str` | *(required)* | Key from data objects |
| `type` | `str` | `"natural"` | Interpolation: `"linear"`, `"monotone"`, `"step"`, `"natural"` |
| `fill` | `str` | *(auto from `data_key`)* | Area fill color; defaults to `var(--color-{data_key})` |
| `fill_opacity` | `float` | `0.4` | Fill opacity (0–1). Use `0.8` for solid, `0.3` for gradient-like |
| `stroke` | `str \| None` | *(same as fill)* | Line stroke color |
| `stroke_width` | `int` | `2` | Stroke width in pixels |
| `stacked_id` | `str \| None` | `None` | Areas sharing the same `stacked_id` are stacked |
| `dot` | `bool \| dict` | `False` | Show data-point dots |
| `connect_nulls` | `bool` | `False` | Connect across null values |
| `base_value` | `int \| str \| None` | `None` | Override baseline for this area |
| `label` | `bool \| dict \| None` | `None` | Show value labels |
| `hide` | `bool` | `False` | Hide this area series |

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
