Navigation

v2.1.0
Change over time

Slope chart

What rose, what fell and what crossed between two moments, read from the slopes.

On this page

A slope chart sets two moments side by side and draws a straight line for each series from one to the other. What rose, what fell and what overtook what is read from the slopes alone. There is no scale to read: each line's value is written at its first end and its value and name at its last, so the chart needs no legend.

Slope chart

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Browsers</h3>    <p class="card-description">Share of sessions, 2019 and 2024</p>  </div>  <figure class="chart" id="share"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('share'), {  type: 'slope',  label: 'Share of sessions by browser in 2019 and 2024, in percent',  labels: ['2019', '2024'],  series: [    { name: 'Chrome', values: [58, 65] },    { name: 'Safari', values: [17, 18] },    { name: 'Firefox', values: [9, 3] },    { name: 'Edge', values: [4, 5] }  ],  format: function (value) { return value + '%' }})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto">  <div className="card-header">    <h3 className="card-title">Browsers</h3>    <p className="card-description">Share of sessions, 2019 and 2024</p>  </div>  <Chart    id="share"    type="slope"    label="Share of sessions by browser in 2019 and 2024, in percent"    labels={['2019', '2024']}    series={[      { name: 'Chrome', values: [58, 65] },      { name: 'Safari', values: [17, 18] },      { name: 'Firefox', values: [9, 3] },      { name: 'Edge', values: [4, 5] }    ]}    format={function (value) { return value + '%' }}  /></div>
<script>  import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Browsers</h3>    <p class="card-description">Share of sessions, 2019 and 2024</p>  </div>  <Chart    id="share"    type="slope"    label="Share of sessions by browser in 2019 and 2024, in percent"    labels={['2019', '2024']}    series={[      { name: 'Chrome', values: [58, 65] },      { name: 'Safari', values: [17, 18] },      { name: 'Firefox', values: [9, 3] },      { name: 'Edge', values: [4, 5] }    ]}    format={function (value) { return value + '%' }}  /></div>
<script setup>import Chart from './ui/Chart.vue'</script><template>  <div class="card max-w(560) mx-auto">    <div class="card-header">      <h3 class="card-title">Browsers</h3>      <p class="card-description">Share of sessions, 2019 and 2024</p>    </div>    <Chart      id="share"      type="slope"      label="Share of sessions by browser in 2019 and 2024, in percent"      :labels="['2019', '2024']"      :series="[        { name: 'Chrome', values: [58, 65] },        { name: 'Safari', values: [17, 18] },        { name: 'Firefox', values: [9, 3] },        { name: 'Edge', values: [4, 5] }      ]"      :format="function (value) { return value + '%' }"    />  </div></template>
Point at a line: the others step back and the readout lists its values.

A series is one point of the chart, not a step of the scale: under the pointer, or with the arrow keys, a whole line is chosen and the others step back. Labels that would meet at an end are nudged apart, each staying as near its line as the ones above it allow. Past six or seven series the ends crowd; fold the rest into one line or draw a line chart with a legend.

More than two labels are allowed, and each line then turns at every one of them. With many labels a line chart reads better, since a slope's strength is the single stroke from one moment to the other.

#Options

OptionDefault
labelnoneWhat the chart shows and in what unit: the plot's accessible name
labels[]The names along the scale, around a radar or over a heatmap's columns
series[]Each with a name and what its form reads: values, a value, points, ranges or children; optionally a category, a type, low and high, and a ring's max
min, max, ticksfit, 4The ends of the scale and about how many steps mark it; xMin, xMax and xTicks for a scatter's scale across
format, tickFormatthe locale'sHow a value and a tick are written; xFormat for a scatter's scale across
currentnoneThe index of the point marked aria-current

The readout, the keys, the legend, the colors and the scale are the same in every form: Chart holds them, with every option, class and custom property.