# Area

> Fill the space under a line to show how a quantity builds over time, then add reference lines and compare overlapping series from a shared zero baseline.

An area chart is a line with the space beneath it filled, so the reader sees the size of the quantity as well as its direction. It suits a running total or a magnitude that starts at zero, such as a fleet size or a cumulative count.

Use a [line chart](/docs/change-over-time/line/) when you compare several series and the slopes are what matter. Use a [stacked area](/docs/change-over-time/stacked-area/) when the series add up to a total and the parts are the point.

## A basic area chart

Set `mark` to `"area"` with the same `x` and `y` channels a line uses. Passing the mark as an object lets you set `stroke` and `strokeWidth` for the outline. A `text` annotation with a connector marks the milestone.

```json
{
  "mark": {
    "type": "area",
    "stroke": "#0e7490",
    "strokeWidth": 2
  },
  "data": [
    {
      "year": "2015-01-01",
      "fleet": 1.3
    },
    {
      "year": "2016-01-01",
      "fleet": 2.1
    },
    {
      "year": "2017-01-01",
      "fleet": 3.2
    },
    {
      "year": "2018-01-01",
      "fleet": 5.4
    },
    {
      "year": "2019-01-01",
      "fleet": 7.5
    },
    {
      "year": "2020-01-01",
      "fleet": 10.5
    },
    {
      "year": "2021-01-01",
      "fleet": 17.1
    },
    {
      "year": "2022-01-01",
      "fleet": 27
    },
    {
      "year": "2023-01-01",
      "fleet": 41
    },
    {
      "year": "2024-01-01",
      "fleet": 58
    }
  ],
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "tickCount": 5
      }
    },
    "y": {
      "field": "fleet",
      "type": "quantitative",
      "axis": {
        "title": "Cumulative EV fleet (millions)",
        "format": ",.0f",
        "grid": true
      }
    }
  },
  "annotations": [
    {
      "type": "text",
      "x": "2020-01-01",
      "y": 10.5,
      "text": "10M milestone",
      "anchor": "top",
      "offset": {
        "dx": 0,
        "dy": -22
      },
      "connector": true
    }
  ],
  "chrome": {
    "title": "The world's electric car fleet reached 58 million in 2024",
    "subtitle": "Cumulative global electric car fleet, 2015-2024 (BEV + PHEV)"
  }
}
```

## Reference values

A `refline` annotation draws a horizontal rule at a value in data units, and its `label` names it. Here a dashed rule at $100 shows when the price crossed that level. The y axis starts at zero, so the filled height is proportional to the value.

```json
{
  "mark": {
    "type": "area",
    "stroke": "#0e7490",
    "strokeWidth": 2
  },
  "data": [
    {
      "date": "2023-01-01",
      "price": 19.52
    },
    {
      "date": "2023-02-01",
      "price": 23.19
    },
    {
      "date": "2023-03-01",
      "price": 27.75
    },
    {
      "date": "2023-04-01",
      "price": 27.73
    },
    {
      "date": "2023-05-01",
      "price": 37.8
    },
    {
      "date": "2023-06-01",
      "price": 42.27
    },
    {
      "date": "2023-07-01",
      "price": 46.7
    },
    {
      "date": "2023-08-01",
      "price": 49.32
    },
    {
      "date": "2023-09-01",
      "price": 43.47
    },
    {
      "date": "2023-10-01",
      "price": 40.75
    },
    {
      "date": "2023-11-01",
      "price": 46.74
    },
    {
      "date": "2023-12-01",
      "price": 49.49
    },
    {
      "date": "2024-01-01",
      "price": 61.49
    },
    {
      "date": "2024-02-01",
      "price": 79.07
    },
    {
      "date": "2024-03-01",
      "price": 90.31
    },
    {
      "date": "2024-04-01",
      "price": 86.36
    },
    {
      "date": "2024-05-01",
      "price": 109.58
    },
    {
      "date": "2024-06-01",
      "price": 123.49
    },
    {
      "date": "2024-07-01",
      "price": 116.97
    },
    {
      "date": "2024-08-01",
      "price": 119.32
    },
    {
      "date": "2024-09-01",
      "price": 121.4
    },
    {
      "date": "2024-10-01",
      "price": 132.72
    },
    {
      "date": "2024-11-01",
      "price": 138.2
    },
    {
      "date": "2024-12-01",
      "price": 134.25
    },
    {
      "date": "2025-01-01",
      "price": 120.04
    },
    {
      "date": "2025-02-01",
      "price": 124.89
    },
    {
      "date": "2025-03-01",
      "price": 108.36
    },
    {
      "date": "2025-04-01",
      "price": 108.9
    },
    {
      "date": "2025-05-01",
      "price": 135.11
    },
    {
      "date": "2025-06-01",
      "price": 157.97
    },
    {
      "date": "2025-07-01",
      "price": 177.85
    },
    {
      "date": "2025-08-01",
      "price": 174.16
    },
    {
      "date": "2025-09-01",
      "price": 186.57
    },
    {
      "date": "2025-10-01",
      "price": 202.48
    },
    {
      "date": "2025-11-01",
      "price": 176.99
    },
    {
      "date": "2025-12-01",
      "price": 186.5
    }
  ],
  "encoding": {
    "x": {
      "field": "date",
      "type": "temporal",
      "axis": {
        "tickCount": 6
      }
    },
    "y": {
      "field": "price",
      "type": "quantitative",
      "axis": {
        "title": "Closing price ($)",
        "format": ",.0f",
        "grid": true
      }
    }
  },
  "annotations": [
    {
      "type": "refline",
      "y": 100,
      "label": "$100",
      "style": "dashed",
      "stroke": "#64748b",
      "strokeWidth": 1
    }
  ],
  "chrome": {
    "title": "Nvidia's price crossed $100 in 2024",
    "subtitle": "Split-adjusted monthly close, January 2023 to December 2025"
  }
}
```

## Overlapping series

Multi-series areas stack by default. Setting `stack: null` on the y channel draws each series from the same zero baseline instead, with translucent fills, so you can compare the series with each other. The mode is for comparison rather than composition.

```json
{
  "mark": "area",
  "data": [
    {
      "year": "2019-01-01",
      "revenue": 280,
      "company": "Amazon"
    },
    {
      "year": "2020-01-01",
      "revenue": 386,
      "company": "Amazon"
    },
    {
      "year": "2021-01-01",
      "revenue": 470,
      "company": "Amazon"
    },
    {
      "year": "2022-01-01",
      "revenue": 514,
      "company": "Amazon"
    },
    {
      "year": "2023-01-01",
      "revenue": 574,
      "company": "Amazon"
    },
    {
      "year": "2024-01-01",
      "revenue": 638,
      "company": "Amazon"
    },
    {
      "year": "2019-01-01",
      "revenue": 161,
      "company": "Alphabet"
    },
    {
      "year": "2020-01-01",
      "revenue": 182,
      "company": "Alphabet"
    },
    {
      "year": "2021-01-01",
      "revenue": 257,
      "company": "Alphabet"
    },
    {
      "year": "2022-01-01",
      "revenue": 283,
      "company": "Alphabet"
    },
    {
      "year": "2023-01-01",
      "revenue": 307,
      "company": "Alphabet"
    },
    {
      "year": "2024-01-01",
      "revenue": 350,
      "company": "Alphabet"
    },
    {
      "year": "2019-01-01",
      "revenue": 71,
      "company": "Meta"
    },
    {
      "year": "2020-01-01",
      "revenue": 86,
      "company": "Meta"
    },
    {
      "year": "2021-01-01",
      "revenue": 118,
      "company": "Meta"
    },
    {
      "year": "2022-01-01",
      "revenue": 117,
      "company": "Meta"
    },
    {
      "year": "2023-01-01",
      "revenue": 135,
      "company": "Meta"
    },
    {
      "year": "2024-01-01",
      "revenue": 164,
      "company": "Meta"
    }
  ],
  "encoding": {
    "x": {
      "field": "year",
      "type": "temporal",
      "axis": {
        "tickCount": 6
      }
    },
    "y": {
      "field": "revenue",
      "type": "quantitative",
      "stack": null,
      "axis": {
        "title": "Annual revenue ($B)",
        "format": ",.0f",
        "grid": true
      }
    },
    "color": {
      "field": "company",
      "type": "nominal"
    }
  },
  "chrome": {
    "title": "Each company's revenue is drawn from the same zero line",
    "subtitle": "Annual revenue by company, 2019-2024 (billions USD)"
  }
}
```

## Fields that matter

| Field | What it does |
| --- | --- |
| `mark` | `"area"`, or an object such as `{ type: "area", stroke: "#0e7490", strokeWidth: 2 }` to style the outline. |
| `encoding.x` | The horizontal position, usually `type: "temporal"`. |
| `encoding.y` | The value that sets the height of the fill. |
| `encoding.y.stack` | `null` overlaps series on a shared baseline. Without it, multiple series stack. |
| `encoding.color` | One area per value of this field. |
| `annotations` | `text` and `refline` marks placed in data coordinates. |

## Related

- [Line](/docs/change-over-time/line/) for slopes and several series.
- [Stacked area](/docs/change-over-time/stacked-area/) for parts of a total over time.
- [Sparkline](/docs/change-over-time/sparkline/) for an area drawn small.
- [Histogram](/docs/distribution/histogram/) for the shape of a distribution rather than change over time.
- [Marks reference](/docs/spec/marks/) lists the channels and options each mark type takes.
