# Step line chart

Source: https://ecosphere.dev/docs/charts/step-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.

A value that holds until it changes — a price, a rate, a tier — drawn step-after with a hollow marker and its value at each change.

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

## By effective date

x is proportional to time, so a long gap between changes reads as a long flat. A fall puts its label below the marker.

Vue (vue-ecosphere):

```vue
<EcoStepLineChart
  :points="[
    { date: '2021-03-01', value: 10.8 },
    { date: '2022-01-01', value: 11.4 },
    { date: '2023-04-01', value: 12.1 },
    { date: '2023-11-01', value: 11.6 },
    { date: '2024-07-01', value: 12.4 },
    { date: '2025-02-01', value: 13.2 },
    { date: '2026-01-01', value: 12.9 },
  ]"
  :value-format="(v) => '$' + v.toFixed(2)"
  unit="per unit"
  axis-label="USD per unit"
  title="Price per unit"
  subtitle="Every agreed change, placed by effective date"
/>
```

React (react-ecosphere):

```tsx
<EcoStepLineChart
  points={[
    { date: "2021-03-01", value: 10.8 },
    { date: "2022-01-01", value: 11.4 },
    { date: "2023-04-01", value: 12.1 },
    { date: "2023-11-01", value: 11.6 },
    { date: "2024-07-01", value: 12.4 },
    { date: "2025-02-01", value: 13.2 },
    { date: "2026-01-01", value: 12.9 },
  ]}
  valueFormat={(v) => "$" + v.toFixed(2)}
  unit="per unit"
  axisLabel="USD per unit"
  title="Price per unit"
  subtitle="Every agreed change, placed by effective date"
/>
```

## By version

When the dates cannot be trusted, space by version, title the axis “Version” and say so in the sub-title.

Vue (vue-ecosphere):

```vue
<EcoStepLineChart
  :points="[8, 8.5, 8.25, 9.1, 9.6, 9.4].map((value) => ({ value }))"
  :value-format="(v) => '$' + v.toFixed(2)"
  unit="per seat"
  axis-label="USD per seat"
  title="Price per seat"
  subtitle="By contract version, evenly spaced: the dates are not known"
/>
```

React (react-ecosphere):

```tsx
<EcoStepLineChart
  points={[8, 8.5, 8.25, 9.1, 9.6, 9.4].map((value) => ({ value }))}
  valueFormat={(v) => "$" + v.toFixed(2)}
  unit="per seat"
  axisLabel="USD per seat"
  title="Price per seat"
  subtitle="By contract version, evenly spaced: the dates are not known"
/>
```

## One point, narrow and empty

A single marker and its value with no line; at 360px the labels thin and the markers stay.

Vue (vue-ecosphere):

```vue
<EcoStepLineChart :points="[{ date: '2026-01-01', value: 12.9 }]" … />
<EcoStepLineChart :points="[]" empty-text="The line starts when the first price takes effect." />
```

React (react-ecosphere):

```tsx
<EcoStepLineChart points={[{ date: "2026-01-01", value: 12.9 }]} … />
<EcoStepLineChart points={[]} emptyText="The line starts when the first price takes effect." />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `points` | `StepPoint[]` | — | Each an effective date (or a version) and the value from then on. |
| `unit` | `string` | — | Words after the value: “per unit”. |
| `axisLabel` | `string` | — | The unit at the top left: “USD per unit”. |
| `xTitle` | `string` | "Effective date" / "Version" | Axis title at the bottom left. |
| `valueFormat` | `(v: number) => string` | — | Value labels, ticks, tooltip and hit labels. |
| `height / width` | `number` | 228 / measured | viewBox size. Labels thin to the measured width. |
| `title / subtitle / caption / ariaLabel` | `string` | — | Head, closing chart__sub and the svg label. |
| `emptyTitle / emptyText` | `string` | — | chart__empty when there are no points. |
| `tooltip` | `(i: number) => ChartTooltipData` | — | Override the card for a point. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `points` | `StepPoint[]` | — | Each an effective date (or a version) and the value from then on. |
| `unit` | `string` | — | Words after the value: “per unit”. |
| `axisLabel` | `string` | — | The unit at the top left: “USD per unit”. |
| `xTitle` | `string` | "Effective date" / "Version" | Axis title at the bottom left. |
| `valueFormat` | `(v: number) => string` | — | Value labels, ticks, tooltip and hit labels. |
| `height / width` | `number` | 228 / measured | viewBox size. Labels thin to the measured width. |
| `title / subtitle / caption / ariaLabel` | `string` | — | Head, closing chart__sub and the svg label. |
| `emptyTitle / emptyText` | `string` | — | chart__empty when there are no points. |
| `tooltip` | `(i: number) => ChartTooltipData` | — | Override the card for a point. |
