# Line chart

Source: https://ecosphere.dev/docs/charts/line-chart (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

Change over time: a 2px line per series, a dot on the last point and the value beside it.

`import { EcoLineChart } from "vue-ecosphere"`

## Three series

Label the end of each line rather than every point; the axis carries the rest. Focus a month for every series' value.

Vue (vue-ecosphere):

```vue
<EcoLineChart
  :labels="['Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct']"
  :series="[
    { name: 'Replied', values: [42, 48, 45, 58, 62, 71, 69, 78] },
    { name: 'Awaiting review', values: [30, 28, 33, 31, 36, 34, 38, 41] },
    { name: 'Blocked', values: [18, 22, 16, 19, 14, 12, 15, 11] },
  ]"
  title="Requests by outcome"
  subtitle="March – October"
/>
```

React (react-ecosphere):

```tsx
<EcoLineChart
  labels={["Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct"]}
  series={[
    { name: "Replied", values: [42, 48, 45, 58, 62, 71, 69, 78] },
    { name: "Awaiting review", values: [30, 28, 33, 31, 36, 34, 38, 41] },
    { name: "Blocked", values: [18, 22, 16, 19, 14, 12, 15, 11] },
  ]}
  title="Requests by outcome"
  subtitle="March – October"
/>
```

## Emphasis

One line in its slot colour, the rest in --text-disabled: almost always clearer than several colours competing.

Vue (vue-ecosphere):

```vue
<EcoLineChart
  :labels="months"
  :series="series"
  emphasis="Blocked"
  title="Blocked requests"
  subtitle="The one series the story is about; the rest are context"
  caption="Eleven in October, down from twenty-two in April."
/>
```

React (react-ecosphere):

```tsx
<EcoLineChart
  labels={months}
  series={series}
  emphasis="Blocked"
  title="Blocked requests"
  subtitle="The one series the story is about; the rest are context"
  caption="Eleven in October, down from twenty-two in April."
/>
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `labels` | `string[]` | — | x labels, thinned to the width. |
| `series` | `ChartSeries[]` | — | Two to four series in slot order. One y-axis only. |
| `emphasis` | `number \| string` | — | The series the story is about; the rest take --text-disabled and lose their labels. |
| `endLabels` | `boolean` | four series or fewer | The value beside each line's last point. |
| `titles` | `string[]` | — | Long period names for the ChartTooltip. |
| `valueFormat / tickFormat` | `(v: number) => string` | — | Figures and y ticks. |
| `height / width` | `number` | 240 / measured | viewBox size. |
| `title / subtitle / caption / ariaLabel` | `string` | — | Head, closing chart__sub and the svg label. |
| `legend` | `boolean` | true | A line-key legend from two series, with each line's latest value. |
| `@active-change` | `(i: number \| null)` | — | The period under the pointer or focus. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `labels` | `string[]` | — | x labels, thinned to the width. |
| `series` | `ChartSeries[]` | — | Two to four series in slot order. One y-axis only. |
| `emphasis` | `number \| string` | — | The series the story is about; the rest take --text-disabled and lose their labels. |
| `endLabels` | `boolean` | four series or fewer | The value beside each line's last point. |
| `titles` | `string[]` | — | Long period names for the ChartTooltip. |
| `valueFormat / tickFormat` | `(v: number) => string` | — | Figures and y ticks. |
| `height / width` | `number` | 240 / measured | viewBox size. |
| `title / subtitle / caption / ariaLabel` | `string` | — | Head, closing chart__sub and the svg label. |
| `legend` | `boolean` | true | A line-key legend from two series, with each line's latest value. |
| `onActiveChange` | `(i: number \| null)` | — | The period under the pointer or focus. |
