# Line & area

> Two-series session trend, line + soft area fill under the primary series.

- Group: Charts
- HTML page: https://design.ipmnx.com/charts/line-area/
- Spec: https://design.ipmnx.com/design/#charts

## Usage

Load tokens.css, kit.css and behavior/charts.js (after behavior/util.js), then draw into an empty element. The chart is an inline SVG that re-themes with data-theme, dir and data-nx-product.

```js
NXCharts.renderLine(el, dataset, a11y);
NXCharts.tableForLine(el, dataset, a11y.tableSummary);
```

## Dataset

```json
{
  "labels": [
    "W1",
    "W2",
    "W3",
    "W4",
    "W5",
    "W6",
    "W7"
  ],
  "series": [
    {
      "name": "This year",
      "color": "--nx-chart-1",
      "values": [
        20,
        34,
        28,
        45,
        40,
        58,
        63
      ]
    },
    {
      "name": "Last year",
      "color": "--nx-chart-2",
      "values": [
        12,
        18,
        26,
        22,
        30,
        28,
        38
      ]
    }
  ]
}
```

## Classes

| Class | Description |
| --- | --- |
| `.nx-legend` | Series key, required when >=2 series |

## Accessibility

- Accessible name (role="img" with aria-label): Sessions, two-series line chart comparing this year to last year over 7 weeks
- Data table summary (visually hidden table for screen readers): Sessions by week: This year 20, 34, 28, 45, 40, 58, 63; Last year 12, 18, 26, 22, 30, 28, 38.

## Do / Don't

- Do: Always add a legend when there are 2+ series.
- Don't use a second y-axis. One axis only.

---

Source: registry.js (NX Design System)
