# Area chart

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

One series over time: a smoothed curve, a gradient fading from 22% to nothing, a dot on every point and a tooltip per point.

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

## Area chart

Lead with the number: the figure and its delta sit above the plot, which carries no y-axis.

Vue (vue-ecosphere):

```vue
<EcoAreaChart
  :labels="['Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct']"
  :data="[210, 248, 232, 301, 288, 344, 362, 410]"
  :titles="titles"
  unit="requests"
  aria-label="Requests received by month"
  caption="Hover a month for its figure. Cumulative per month, March – October."
>
  <template #head>
    <div class="card__head">
      <div>
        <p class="eyebrow">Requests received</p>
        <div class="stat__value"><span class="stat__n">410</span><span class="stat__delta"><i class="ri-arrow-up-line" aria-hidden="true"></i>13%</span></div>
      </div>
    </div>
  </template>
</EcoAreaChart>
```

React (react-ecosphere):

```tsx
<EcoAreaChart
  labels={["Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct"]}
  data={[210, 248, 232, 301, 288, 344, 362, 410]}
  titles={titles}
  unit="requests"
  ariaLabel="Requests received by month"
  caption="Hover a month for its figure. Cumulative per month, March – October."
  head={
    <div className="card__head">
      <div>
        <p className="eyebrow">Requests received</p>
        <div className="stat__value"><span className="stat__n">410</span><span className="stat__delta"><i className="ri-arrow-up-line" aria-hidden="true"></i>13%</span></div>
      </div>
    </div>
  }
/>
```

## In a card

The same chart, laid out at the card's width.

Vue (vue-ecosphere):

```vue
<div class="card">
  <div class="card__body">
    <EcoAreaChart :labels="months" :data="received" unit="requests" :height="172">
      <template #head>
        <div class="card__head">
          <div>
            <p class="eyebrow">Requests received</p>
            <div class="stat__value"><span class="stat__n">410</span><span class="stat__delta"><i class="ri-arrow-up-line" aria-hidden="true"></i>13%</span></div>
          </div>
        </div>
      </template>
    </EcoAreaChart>
  </div>
</div>
```

React (react-ecosphere):

```tsx
<div className="card">
  <div className="card__body">
    <EcoAreaChart
      labels={months}
      data={received}
      unit="requests"
      height={172}
      head={
        <div className="card__head">
          <div>
            <p className="eyebrow">Requests received</p>
            <div className="stat__value"><span className="stat__n">410</span><span className="stat__delta"><i className="ri-arrow-up-line" aria-hidden="true"></i>13%</span></div>
          </div>
        </div>
      }
    />
  </div>
</div>
```

## Small multiples

To compare, split into small multiples rather than stacking two gradients; drop the labels and the head at this size.

Vue (vue-ecosphere):

```vue
<div style="display:grid;grid-template-columns:1fr 1fr;gap:20px">
  <EcoAreaChart small title="Blocked" :series-slot="5" :labels="months" :data="[22, 19, 17, 18, 15, 13, 12, 11]" unit="blocked" />
  <EcoAreaChart small title="Awaiting review" :series-slot="2" :labels="months" :data="[30, 28, 33, 31, 36, 34, 38, 41]" unit="waiting" />
</div>
```

React (react-ecosphere):

```tsx
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 20 }}>
  <EcoAreaChart small title="Blocked" seriesSlot={5} labels={months} data={[22, 19, 17, 18, 15, 13, 12, 11]} unit="blocked" />
  <EcoAreaChart small title="Awaiting review" seriesSlot={2} labels={months} data={[30, 28, 33, 31, 36, 34, 38, 41]} unit="waiting" />
</div>
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `labels` | `string[]` | — | Period labels under the plot; the current one in accent. |
| `data` | `number[]` | — | One series of volumes (never a rate or an average). |
| `seriesSlot` | `1 \| 2 \| 3 \| 4 \| 5 \| 6 \| "rest"` | 1 | Series slot on plot--slot. |
| `current` | `number \| string` | latest | Label shown as xl on. |
| `unit` | `string` | — | Words after each figure in the tipbox: “requests”. |
| `titles` | `string[]` | — | Long period names for each point's hit label. |
| `valueFormat` | `(v: number) => string` | — | Formats the tipbox figure. |
| `small` | `boolean` | false | Small multiple: no labels, a bare chart__t title. |
| `max` | `number` | — | Shared scale ceiling, so small multiples compare. |
| `height / width` | `number` | 250 (150 small) / measured | viewBox size. |
| `title / subtitle / caption / ariaLabel` | `string` | — | Head, closing chart__sub and the svg label. Slot head replaces the head. |
| `emptyTitle / emptyText` | `string` | — | chart__empty when there is no data. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `labels` | `string[]` | — | Period labels under the plot; the current one in accent. |
| `data` | `number[]` | — | One series of volumes (never a rate or an average). |
| `seriesSlot` | `1 \| 2 \| 3 \| 4 \| 5 \| 6 \| "rest"` | 1 | Series slot on plot--slot. |
| `current` | `number \| string` | latest | Label shown as xl on. |
| `unit` | `string` | — | Words after each figure in the tipbox: “requests”. |
| `titles` | `string[]` | — | Long period names for each point's hit label. |
| `valueFormat` | `(v: number) => string` | — | Formats the tipbox figure. |
| `small` | `boolean` | false | Small multiple: no labels, a bare chart__t title. |
| `max` | `number` | — | Shared scale ceiling, so small multiples compare. |
| `height / width` | `number` | 250 (150 small) / measured | viewBox size. |
| `title / subtitle / caption / ariaLabel` | `string` | — | Head, closing chart__sub and the svg label. The head prop (ReactNode) replaces the head; actions and footer add to it. |
| `emptyTitle / emptyText` | `string` | — | chart__empty when there is no data. |
