# Line chart

> Values per category drawn as lines over a light wash, several series sharing the axis, with a tooltip, keyboard navigation and an optional details modal.

Source: https://eunomia-ds.com/charts/line-chart/

A line chart follows a measure from one category to the next, most often over time: revenue per day, sessions per week. A single series is drawn over a light wash down to zero. Several series share the same axis, and a secondary one, such as a target or what an amount will reach, can be drawn faded or dashed. Hovering a category, or moving along them with the arrow keys, marks it with a hairline and shows its values in a tooltip.

Dependencies

- [eun-skeleton · while loading](https://eunomia-ds.com/components/skeleton/)
- [eun-modal · if details is set](https://eunomia-ds.com/components/modal/)

## Overview

### When to use

Reach for a line chart to show how a measure evolves over many intervals, where the trend, the peaks and the dips matter more than each value: revenue over a month, traffic over a year, a balance going up and down. Prefer a [bar chart](https://eunomia-ds.com/charts/bar-chart/) to compare a handful of distinct categories, or counts where each value stands on its own.

The data follows the contract shared by every chart, see [Charts](https://eunomia-ds.com/charts/) for its fields and for `timeCategories`, which builds the categories of a period.

### Install & usage

**HTML / any framework:**

```bash
npm install @eunomia/elements @eunomia/charts
```

```js
import "@eunomia/charts/line-chart.js";
```

```html
<eun-line-chart
  label="Revenue per day"
  format='{"style":"currency","currency":"EUR"}'
></eun-line-chart>

<script type="module">
  const chart = document.querySelector("eun-line-chart");
  chart.data = {
    categories: [
      { key: "2026-11-03", label: "Tuesday, November 3", tick: "Nov 3" },
      { key: "2026-11-04", label: "Wednesday, November 4", tick: "Nov 4" },
      { key: "2026-11-05", label: "Thursday, November 5", tick: "Nov 5" },
    ],
    series: [{ key: "revenue", label: "Revenue", values: [420, 610, 380] }],
  };
</script>
```

Importing the file registers `<eun-line-chart>` as a custom element, with no further setup needed. It draws at its own width, so give it room the way you would an image: in a card, a grid cell, a flex item with `min-width: 0`. Import `@eunomia/elements/skeleton.js` too to show a placeholder while `loading`, and `@eunomia/elements/modal.js` to use `details`.

**JavaScript:**

```bash
npm install @eunomia/elements @eunomia/charts
```

```html
<script type="module">
  import "@eunomia/charts/line-chart.js";
  import { timeCategories } from "@eunomia/charts/chart-utils.js";

  const categories = timeCategories("2026-11-01", "2026-11-30", "day");
  const chart = document.querySelector("eun-line-chart");
  chart.data = {
    categories,
    series: [
      {
        key: "revenue",
        label: "Revenue",
        values: categories.map(({ key }) => revenueByDay.get(key) ?? 0),
      },
    ],
  };
</script>

<eun-line-chart label="Revenue per day"></eun-line-chart>
```

**React:**

```bash
npm install @eunomia/elements @eunomia/charts
```

```jsx
import { useMemo } from "react";
import "@eunomia/charts/line-chart.js";

const EUROS = { style: "currency", currency: "EUR" };

function RevenueChart({ days, loading }) {
  const data = useMemo(
    () => ({
      categories: days.map((day) => ({
        key: day.date,
        label: day.label,
        tick: day.tick,
      })),
      series: [
        {
          key: "revenue",
          label: "Revenue",
          values: days.map((day) => day.revenue),
        },
      ],
    }),
    [days],
  );

  return (
    <eun-line-chart
      label="Revenue per day"
      data={data}
      format={EUROS}
      loading={loading}
    />
  );
}
```

React 19 sets `data` and `format` as properties. On React 18, set them through a ref, or with `eunProps` from `@eunomia/elements/react`.

**Next.js:**

```bash
npm install @eunomia/elements @eunomia/charts
```

```jsx
"use client";
import "@eunomia/charts/line-chart.js";

const EUROS = { style: "currency", currency: "EUR" };

export function RevenueChart({ data }) {
  return <eun-line-chart label="Revenue per day" data={data} format={EUROS} />;
}
```

Build the data on the server with `timeCategories` from `@eunomia/charts/chart-utils.js`, which registers no component, and import `chart-ssr.css` to reserve the chart's height before it upgrades (see Server rendering below).

**Vue:**

```bash
npm install @eunomia/elements @eunomia/charts
```

```html
<script setup>
  import "@eunomia/charts/line-chart.js";

  defineProps({ data: Object });
  const euros = { style: "currency", currency: "EUR" };
</script>

<template>
  <eun-line-chart label="Revenue per day" :data="data" :format="euros" />
</template>
```

**Angular:**

```bash
npm install @eunomia/elements @eunomia/charts
```

```ts
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input } from "@angular/core";
import type { EunomiaLineChartData } from "@eunomia/charts";
import "@eunomia/charts/line-chart.js";

@Component({
  selector: "app-revenue-chart",
  template: `
    <eun-line-chart
      label="Revenue per day"
      [data]="data"
      [format]="euros"
    ></eun-line-chart>
  `,
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class RevenueChartComponent {
  @Input() data!: EunomiaLineChartData;
  euros = { style: "currency", currency: "EUR" };
}
```

#### Server rendering

Before it upgrades, a chart is an empty tag. Import `chart-ssr.css` with the page's other styles to reserve its room from the first paint: `--chart-height`, plus a row for the legend once `legend="visible"`, or 100% of its parent's height with `fill`.

```css
@import "@eunomia/charts/chart-ssr.css";
```

Without a bundler, link `node_modules/@eunomia/charts/dist/ssr/chart-ssr.css` in the page's `<head>`. Two cases still shift the page on upgrade: a legend left to `legend="auto"`, which only shows with the data, and a legend that wraps onto more than one row. See [Size: Before it upgrades](https://eunomia-ds.com/charts/size/#before-it-upgrades).

### Alternatives

| You want… | Prefers |
| --- | --- |
| To compare a handful of distinct categories, or counts where each value stands on its own | `eun-bar-chart` |
| A line over amounts drawn as bars, such as a rate over revenue | `eun-combo-chart` |
| To list exact values, to be read, sorted or compared one by one | `eun-table` |

### Guidance

> **Recommended**
>
> - Give every chart a `label`: it names the plot for assistive technology and captions its data table
> - Build the categories of a period with `timeCategories`, so every interval keeps its place on the axis
> - Draw a secondary figure, such as a target or a forecast, `faded` or `dashed`, so the main one stands out
> - Write a missing value as `null`, not as zero, so the line breaks instead of diving
> - Keep to a few series: past three or four lines, the chart becomes hard to read

> **Avoid**
>
> - Mixing measures of different units on one axis: read the second one against the secondary axis
> - Joining categories that have no order between them, such as products or teams: a line suggests a progression
> - Mutating `data` in place: replace the object, the chart only redraws when it changes

## API

### Properties

`data` and `label` are the two you'll always set. The data's own fields, shared with the bar chart, are listed on [Charts: The data contract](https://eunomia-ds.com/charts/#the-data-contract).

### Line chart `<eun-line-chart>`

#### Attributes

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| data | EunomiaChartData<S> | EMPTY_DATA | What the chart draws, as JSON: its categories and its series |
| legend-position | EunomiaChartLegendPosition | 'start' | How the legend's entries line up under the plot |
| hide-tooltip | boolean | false | Shows no tooltip on hover or keyboard moves |
| hide-grid | boolean | false | Draws no gridlines |
| hide-value-axis | boolean | false | Hides the labels of the value axes |
| hide-category-axis | boolean | false | Hides the labels of the categories under the plot |
| empty-label | string \| undefined | — | The text shown in place of the marks while there are no categories |
| hide-empty-label | boolean | false | Shows no text while there are no categories |
| hide-empty-grid | boolean | false | Draws no gridlines and no value labels while there are no categories |
| axis-min | number \| undefined | — | A value the value axis reaches at least, below zero |
| axis-max | number \| undefined | — | A value the value axis reaches at least, above zero, such as 100 for percentages |
| min | number \| undefined | — | The exact lower end of the value axis, anything below it cut off |
| max | number \| undefined | — | The exact upper end of the value axis, anything above it cut off |
| secondary-min | number \| undefined | — | The exact lower end of the secondary value axis |
| secondary-max | number \| undefined | — | The exact upper end of the secondary value axis |
| decimation | EunomiaChartDecimation | 'lttb' | How the series drawn as lines or points thin out their values once there are too many |
| decimation-samples | number \| undefined | — | How many values a line keeps once thinned out, across the whole plot |
| format | Intl.NumberFormatOptions \| undefined | — | The Intl.NumberFormat options the values are written with, as JSON |
| secondary-format | Intl.NumberFormatOptions \| undefined | — | The Intl.NumberFormat options of the series on the secondary axis, as JSON |
| curve | EunomiaChartCurve | 'linear' | How the lines join their values: straight, a smooth curve that never overshoots them, or steps |
| points | EunomiaChartPoints | 'auto' | When the values of the lines get a point |
| point-shape | EunomiaChartPointShape | 'circle' | The shape of the points |
| point-size | number \| undefined | 6 | The size of the points, in pixels across |
| select-hint | string \| undefined | — | The hint at the bottom of the tooltip while categories are clickable. Defaults to the localized string when details is set (English: "Click to see the details"), to none otherwise |
| non-interactive | boolean | false | Draws the chart as a plain picture: no focus stop, no hover, no tooltip, no selection |
| integer | boolean | false | Whether values are counts: the primary value axis then never steps below 1. |
| locale | string \| undefined | — | The locale used to resolve dictionary and `Intl` formatting. Defaults to the shared default set via `setDefaultLocale()`, itself defaulting to `"en"`. |
| label | string \| undefined | — | The chart's accessible name, also the caption of its data table. |
| legend | EunomiaChartLegend | "auto" | When the legend is shown — see EunomiaChartLegend. |
| fill | boolean | false | Takes the whole height of the chart, rather than `--chart-height`: the plot stretches to what's left once the legend is laid out, and redraws whenever that changes. The chart takes 100% of its parent's height by default; size it like any block otherwise (`height`, `flex: 1`, a grid cell). |
| loading | boolean | false | Shows a placeholder in place of the plot while the data loads. |
| refreshing | boolean | false | Keeps the plot shown as a placeholder while new data loads, such as after a change of period: the marks faded, their colors kept, under a shimmer, the axes kept, the tooltip off. |
| animated | boolean | false | Draws the marks in once the chart is first seen. |
| selectable | boolean | false | Makes every category clickable, firing `eunchartselect`. |
| details | boolean | false | Opens a modal listing a category's values once it's clicked. Implies selectable. |

Import the exact TypeScript type behind any property above, see [Types](https://eunomia-ds.com/guides/types/).

#### Properties

JS-only — no matching HTML attribute, set these from a script or a template binding.

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| valueFormatter | EunomiaChartValueFormatter \| undefined | — | Writes a value in the tooltip, the details and the data table, in place of format. Property only |
| tickFormatter | EunomiaChartTickFormatter \| undefined | — | Writes a value of a value axis, in place of format. Receives the value and the axis, primary or secondary. Property only |
| tooltipRenderer | EunomiaChartTooltipRenderer<S> \| undefined | — | Writes the content of the tooltip in place of the values and the category's label. Receives the category, the values of every series written and colored, and the total; returns a DOM node, a string shown as text or a Lit template, null keeping the default content. Property only |
| resolvedLocale | string | — | This instance's own `locale` when set, the shared default locale otherwise. |
| dictionary | ChartDictionary | — | This instance's locale-resolved chart strings. |

#### Methods

| Name | Returns | Description |
| --- | --- | --- |
| replayAnimation() | Promise<void> | Plays the entrance animation again, such as once new data is shown. Does nothing while the person asked to reduce motion. |

#### Slots

| Name | Description |
| --- | --- |
| details | Extra content shown in the details modal, below the category's values, such as the records behind them. Update it from eunchartselect. A <template slot="details"> is filled for the clicked category instead, as the tooltip's: data-field, data-each and data-bind-* attributes such as data-bind-href="/orders?day={key}" |
| tooltip | A <template> writing the content of the tooltip in plain HTML, in place of the values and the category's label: data-each="values" (or "drawn") repeats an element per series, data-field writes category, key, tick, total, and per series series, text, value or color. tooltipRenderer takes over when set. data-bind-<attr> writes an attribute, {category}, {key}, {tick} and {index} replaced |

#### Events

| Name | Type | Description |
| --- | --- | --- |
| eunchartselect | ChartSelectEvent | Fired when a category is clicked, or activated with Enter or Space, while selectable or details is set. Cancelable to keep the details modal from opening |

Every event above follows the same naming convention, covered in [Events](https://eunomia-ds.com/guides/events/).

#### CSS custom properties

| Name | Description |
| --- | --- |
| --chart-height | Sets the height of the plot, axis labels included, ignored with fill. 220px by default |
| --chart-min-height | Sets the least height of the plot with fill. 80px by default |
| --chart-color-1 | Sets the color of the first series, and of every eighth one after it. The primary color by default |
| --chart-color-2 | Sets the color of the second series. The secondary color by default |
| --chart-color-3 | Sets the color of the third series |
| --chart-color-4 | Sets the color of the fourth series |
| --chart-color-5 | Sets the color of the fifth series |
| --chart-color-6 | Sets the color of the sixth series |
| --chart-color-7 | Sets the color of the seventh series |
| --chart-color-8 | Sets the color of the eighth series |
| --chart-surface-color | Sets the color of the surface the chart sits on, ringing the markers |
| --chart-grid-color | Sets the color of the gridlines |
| --chart-axis-color | Sets the color of the axis labels, of the hovered category's hairline and of the legend |
| --chart-axis-font-size | Sets the font size of the axis labels |
| --chart-line-width | Sets the width of the lines. 2px by default |
| --chart-area-opacity | Sets the opacity of the wash under a line. 0.1 by default |
| --chart-tooltip-background | Sets the background color of the tooltip |
| --chart-tooltip-color | Sets the text color of the tooltip |
| --chart-focus-outline-color | Sets the color of the plot's focus ring |
| --chart-animation-duration | Sets the duration of the entrance animation |
| --chart-refresh-opacity | Sets the opacity the marks take while refreshing, their colors kept. 0.4 by default |
| --chart-refresh-highlight-color | Sets the color of the shimmer sweeping the plot while refreshing |

#### CSS shadow parts

| Name | Description |
| --- | --- |
| plot | The svg the chart is drawn in |
| tooltip | The tooltip |
| legend | The legend |
| legend-item | An entry of the legend, its swatch and its name |
| legend-swatch | The swatch of an entry of the legend |
| details | The details modal |

### Types

```ts
import type {
  EunomiaLineChartData,
  EunomiaLineChartSeries,
  EunomiaChartCategory,
  EunomiaChartLegend,
  EunomiaChartLegendPosition,
  EunomiaChartAxis,
  EunomiaChartDisplay,
  EunomiaChartValueFormatter,
  EunomiaChartTickFormatter,
  EunomiaChartCurve,
  EunomiaChartPoints,
  EunomiaChartPointShape,
  EunomiaChartTooltipRenderer,
  EunomiaChartTooltipContext,
} from "@eunomia/charts";
import { ChartSelectEvent } from "@eunomia/charts";
```

`ChartSelectEvent` carries the selected `category`, its `index` in `data.categories`, and `values`: every series with its value on that category, `null` for none.

## Examples

### Series

#### Single series

A single series is drawn over a light wash down to zero, its last value marked.

```js
import { timeCategories } from "@eunomia/charts/chart-utils.js";

chart.data = {
  categories: timeCategories("2026-11-03", "2026-11-16", "day"),
  series: [{ key: "revenue", label: "Revenue", values: revenue }],
};
```

#### Several series

Each series gets its own line and color, the legend appearing on its own from two series on. Several series have no wash unless one asks for it with `area`.

```js
chart.data = {
  categories: timeCategories("2026-01", "2026-12", "month"),
  series: [
    { key: "web", label: "Website", values: web },
    { key: "app", label: "App", values: app },
    { key: "store", label: "Store", values: store },
  ],
};
```

#### Three series and more

Any number of series share the axis, each in the next color of the palette. Here four channels and a target: past three or four lines, tell the secondary ones apart by their style too, `faded` or `dashed`, and keep the legend shown.

```js
series: [
  { key: "web", label: "Website", values: web },
  { key: "app", label: "App", values: app },
  { key: "store", label: "Store", values: store },
  { key: "marketplace", label: "Marketplace", values: marketplace },
  { key: "target", label: "Target", values: target, faded: true, dashed: true },
],
```

#### Secondary series

`faded` draws a series semi-transparent and `dashed` draws it dashed: here the revenue paid so far, over what it will reach once every order is paid, both in the primary color.

```js
series: [
  { key: "paid", label: "Paid", values: paid, area: true },
  { key: "expected", label: "Once every order is paid", values: expected, faded: true, color: "var(--eun-color-primary-500)" },
],
```

A forecast can pick up where the actual figures stop, dashed, beside a faded target.

```js
series: [
  { key: "actual", label: "Actual", values: [32, 35, /* … */ 55, null, null, null], area: true },
  { key: "forecast", label: "Forecast", values: [null, /* … */ null, 55, 60, 64, 70], dashed: true },
  { key: "target", label: "Target", values: target, faded: true },
],
```

#### Missing values

A `null` value breaks the line, and a value standing alone between two missing ones is drawn as a dot. The tooltip and the data table write it as "No value", distinct from a zero.

#### Negative values

The axis extends below zero to fit negative values, the wash filling the space between the line and zero.

#### Categories that aren't periods

A line reads best along an order, time being the most common one, but any ordered categories fit: stages of a funnel, criteria of a survey. Give each a `key` and a `label`.

```js
chart.data = {
  categories: [
    { key: "speed", label: "Speed" },
    { key: "support", label: "Support" },
    { key: "price", label: "Price" },
  ],
  series: [{ key: "us", label: "Our product", values: [8.2, 7.4, 6.1] }],
};
```

### Axes and displays

#### Secondary axis and points

A series with `axis: "secondary"` is read against a value axis of its own on the right, for a measure of another unit or magnitude, here a margin rate next to revenue. `secondary-format` writes its values and its labels.

`display: "points"` draws a dot on each value with no line between them, and `display: "none"` leaves a series undrawn, out of the legend, its values still in the tooltip, the details and the data table (here the orders).

```js
series: [
  { key: "revenue", label: "Revenue", values: revenue, area: true },
  { key: "margin", label: "Margin", values: margin, axis: "secondary", display: "points" },
  { key: "orders", label: "Orders", values: orders, display: "none" },
],
```

#### Curves and points

`curve` chooses how the lines join their values: `linear` (default) draws straight segments, `smooth` softens them into a curve that passes through every value without ever overshooting it, so it never shows a peak or a dip the data doesn't have, and `step` holds each value over its interval. The wash follows the same curve.

`points` chooses when the values get a point: `auto` (default) on the hovered category and on the last value, `all` on every value, `hover` on the hovered category only, `none` never. `point-shape` draws them as a `circle`, a `square`, a `diamond` or a `triangle`, and `point-size` sets their size in pixels across, the hovered one 2 pixels larger.

```html
<eun-line-chart curve="smooth" points="all" point-size="7"></eun-line-chart>
```

```html
<eun-line-chart curve="step" points="hover"></eun-line-chart>
```

Each series can set its own `curve`, `points`, `pointShape` and `pointSize`, over the chart's: here a smooth line marked with diamonds next to a target in plain steps.

```js
series: [
  { key: "web", label: "Website", values: web, curve: "smooth", points: "all", pointShape: "diamond" },
  { key: "target", label: "Target", values: target, faded: true, curve: "step", points: "none" },
],
```

A series drawn as `points` always shows its dots, in its shape and its size, its swatch in the legend taking the same shape.

#### Hiding the grid and the axes

`hide-grid` draws no gridlines, `hide-value-axis` and `hide-category-axis` drop the labels on the side and under the plot, the line taking their room: a sparkline for a card or a table cell, its values still in the tooltip.

```html
<eun-line-chart
  label="Revenue per day"
  hide-grid
  hide-value-axis
  hide-category-axis
  style="--chart-height: 64px"
></eun-line-chart>
```

### Values

#### Formatting

`format` takes `Intl.NumberFormat` options, applied in the chart's `locale`: values are written in full in the tooltip, the details and the data table, and in compact notation along the axis (€1.2K). When a format isn't enough, `valueFormatter` writes the values and `tickFormatter` the axis, both set as properties.

```js
chart.format = { style: "currency", currency: "EUR" };
chart.valueFormatter = (value, series) =>
  series?.key === "expected" ? `${euros(value)} expected` : euros(value);
```

#### Value axis

The axis always includes zero and steps on round values. `axis-max` and `axis-min` extend it to at least a given value, such as 100% for a rate, and `integer` keeps it on whole steps for counts.

```html
<eun-line-chart axis-max="1" format='{"style":"percent"}'></eun-line-chart>
```

`min` and `max` hold the axis between fixed bounds instead: it ends exactly on them, no longer reaches for zero, and what lies past them is cut off. Set one alone to fix that end only, the other one fitting the values. `secondary-min` and `secondary-max` do the same for the secondary axis.

```html
<eun-line-chart
  min="16"
  max="24"
  format='{"style":"unit","unit":"celsius"}'
></eun-line-chart>
```

#### Many values

Past about one value per pixel of the plot, the lines thin out their values before drawing them, here 5,760 readings: the line keeps its shape and draws quickly, while the tooltip, the details and the data table keep every value. `decimation` picks how:

- `lttb` (default) keeps the values that best preserve the line's shape.
- `min-max` keeps the lowest and highest value of each slice of the plot, so no peak or dip is lost.
- `none` draws every value.

Switch between them on the same 5,760 readings: `lttb` and `min-max` draw about as many values as the plot has pixels across, `none` all of them. Hover the line: the tooltip still reads every minute.

```html
<eun-line-chart decimation="min-max"></eun-line-chart>
```

`decimation-samples` sets how many values a line keeps across the plot, its width in pixels by default. Fewer samples draw a coarser line, more quickly: here 80 values for four days, about one every 70 minutes, `min-max` keeping every peak of the day.

```html
<eun-line-chart decimation="min-max" decimation-samples="80"></eun-line-chart>
```

Thinning applies to series drawn as lines or points, also on a bar or combo chart; bars are never thinned.

### Legend and colors

`legend="auto"`, the default, shows the legend from two series on, `visible` always and `hidden` never, and `legend-position` lines it up from the `start`, in the `center` or against the `end`. `hide-tooltip` shows no tooltip, the hovered category still being marked. Series take the palette's colors in order, `--chart-color-1` (the primary color) first, and a series' own `color` takes over.

```html
<eun-line-chart
  label="Sessions per month"
  legend-position="end"
  hide-tooltip
></eun-line-chart>
```

```js
series: [
  { key: "actual", label: "Actual", values: actual, color: "#0f766e" },
  { key: "target", label: "Target", values: target, color: "var(--eun-color-grey-500)", dashed: true },
],
```

The legend and the tooltip work the same on every chart: see [Legend](https://eunomia-ds.com/charts/legend/) for its swatches, its appearance and how to build your own, and [Tooltip](https://eunomia-ds.com/charts/tooltip/) for its hint, its appearance and writing its content in HTML or JavaScript.

### States

#### Loading and refreshing

`loading` shows a placeholder the height of the chart while its first data loads. `refreshing` turns the current lines into a placeholder while new data loads, such as after a change of period: they're faded, their colors kept, under a shimmer, as rows are in a syncing table, the axes stay, and the tooltip is off until the new data comes in.

```js
chart.refreshing = true;
chart.data = await fetchPeriod(period);
chart.refreshing = false;
```

#### Empty

A chart without categories keeps its axis and writes "No data". `empty-label` writes your own message, `hide-empty-label` none, and `hide-empty-grid` drops the gridlines and the value labels, which mean nothing without data.

```html
<eun-line-chart
  label="Revenue per day"
  hide-empty-label
  hide-empty-grid
></eun-line-chart>
```

#### Entrance animation

By default, a chart is drawn at once, with no motion: the right choice for a dashboard refreshed often, or for one chart among many on a page.

`animated` draws the lines from left to right once the chart is first seen. `replayAnimation()` plays it again. It's skipped when the person asked their system to reduce motion.

```html
<!-- No animation, the default -->
<eun-line-chart label="Sessions per month, in thousands"></eun-line-chart>

<!-- Animated when first seen -->
<eun-line-chart
  label="Sessions per month, in thousands"
  animated
></eun-line-chart>
```

### Selection

#### Selectable categories

`selectable` makes every category clickable, and activatable with Enter or Space once the plot is focused, firing `eunchartselect` with the category and its values. `select-hint` adds a hint to the tooltip.

```js
chart.addEventListener("eunchartselect", (event) => {
  showOrders(event.category.key);
});
```

#### Details modal

`details` opens a modal on click, headed by the category's label and listing the value of every series. It needs `eun-modal` to be registered. The `details` slot adds content below the values, filled from `eunchartselect`, which fires before the modal opens; canceling it keeps the modal closed, to open your own instead.

```html
<eun-line-chart label="Revenue per day" details>
  <ul slot="details" id="orders"></ul>
</eun-line-chart>
```

The modal works the same on every chart: see [Details modal](https://eunomia-ds.com/charts/details/) for what it lists, content of your own in HTML or from JavaScript, opening your own modal instead, and its appearance.

#### Non-interactive

`non-interactive` draws the chart as a plain picture: no focus stop, no hover, no tooltip and no selection, even with `selectable` or `details`. It fits a small chart in a table cell or a card, where the row or the card already takes the click. The plot keeps its accessible name and its data table. See [Size: Small charts](https://eunomia-ds.com/charts/size/#small-charts).

```html
<eun-line-chart label="Revenue per day" non-interactive></eun-line-chart>
```

### Customization

#### Custom appearance

The custom properties below restyle the chart, and its parts (`plot`, `tooltip`, `legend`, `details`) take any other rule. Here a taller chart in teal, with a thicker line, a deeper wash, dashed gridlines and a rounded tooltip.

```css
.revenue-chart {
  --chart-height: 280px;
  --chart-color-1: #0f766e;
  --chart-line-width: 3px;
  --chart-area-opacity: 0.2;
  --chart-grid-color: #5eead4;
  --chart-axis-color: #115e59;
  --chart-tooltip-background: #134e4a;
  --chart-tooltip-color: #f0fdfa;
}

.revenue-chart::part(tooltip) {
  border-radius: 12px;
  padding: 8px 12px;
}
```

The custom properties that change colors and sizes, at a glance. The API tab lists every property of the component.

| Variable | Sets |
| --- | --- |
| `--chart-height` | Sets the height of the plot, axis labels included. 220px by default |
| `--chart-color-1` … `-8` | Sets the palette the series take their color from, in order |
| `--chart-line-width` | Sets the width of the lines. 2px by default |
| `--chart-area-opacity` | Sets the opacity of the wash under a line. 0.1 by default |
| `--chart-surface-color` | Sets the color of the surface the chart sits on, ringing the markers |
| `--chart-grid-color` | Sets the color of the gridlines |
| `--chart-axis-color` | Sets the color of the axis labels, of the hovered hairline and of the legend |
| `--chart-axis-font-size` | Sets the font size of the axis labels |
| `--chart-tooltip-background` | Sets the background color of the tooltip |
| `--chart-tooltip-color` | Sets the text color of the tooltip |
| `--chart-focus-outline-color` | Sets the color of the plot's focus ring |
| `--chart-animation-duration` | Sets the duration of the entrance animation |
| `--chart-refresh-opacity` | Sets the opacity the lines take while refreshing, their colors kept. 0.4 by default |

#### Custom tooltip

To write the tooltip's content yourself, in HTML with a `<template slot="tooltip">` or in JavaScript with `tooltipRenderer`, see [Tooltip](https://eunomia-ds.com/charts/tooltip/).

## Accessibility

### Keyboard interactions

The plot is a single focus stop. Once focused, it shows the last category, the most recent one on a chart over time, and the arrow keys move along the others.

| Key | Action |
| --- | --- |
| `Tab` / `Shift+Tab` | Moves focus to or away from the plot |
| `ArrowLeft` | Shows the previous category |
| `ArrowRight` | Shows the next category |
| `Home` / `End` | Shows the first or the last category |
| `Enter` / `Space` | Selects the shown category, while `selectable` or `details` is set |

### Aria attributes and rules

- The plot is an `svg` with `role="img"`, named by `label`. Give every chart one.
- Every value stays reachable in a visually hidden table, captioned by `label`, a row per category and a column per series. Screen reader users read the data there rather than through the drawing.
- Moving along the categories with the keyboard announces each one through a polite live region, its label followed by its values.
- The tooltip and the legend are `aria-hidden`: they repeat what the table already holds.
- `hide-tooltip`, `hide-grid` and the hidden axes only change the drawing: the data table and the keyboard announcements keep every value, a `display: "none"` series included.
- While `refreshing`, the plot is marked `aria-busy`.
- A missing value is written "No value", never left blank, so it can't be mistaken for a zero.
- The details modal is an `eun-modal`, with its own focus trap, Escape to close and return of focus to the plot.
- `animated` is skipped when the person asked their system to reduce motion.
- With `non-interactive`, the plot is no focus stop and reacts to neither the pointer nor the keyboard; its accessible name and its data table are still read by screen readers.

### Color and contrast

Lines are told apart by color, so keep the legend shown for several series, and tell a secondary series apart by its style too (`faded`, `dashed`), not by its color alone. Lines should keep a 3:1 contrast with the surface around them (WCAG 1.4.11); a faded line is meant to recede, so never put the main figure on one.

### Reference links

- [WAI Web Accessibility Tutorials: Complex images](https://www.w3.org/WAI/tutorials/images/complex/)
- [Understanding WCAG 2.2: Non-text contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html)
