Skip to content

Slope chart ​

Two columns joined by straight lines. Good for what rose and what fell between two dates.

The smallest code that works. change the code, then press Run

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'slope',
  columns: ['2025', '2026'],
  data: [
    { name: 'Kairouan', from: 34, to: 34 },
    { name: 'Gabes', from: 87, to: 22 },
    { name: 'Sousse', from: 63, to: 20 },
    { name: 'Mahdia', from: 49, to: 36 },
    { name: 'Djerba', from: 37, to: 71 },
    { name: 'Sfax', from: 21, to: 50 },
  ],
};

export default function Example() {
  return <Chart spec={spec} style={{ height: 340 }} />;
}

Or import this chart alone: what each import weighs.

Options

Beside the fields shared by every chart (title, format, heading, export…), type slope takes:

interface SlopeSpec extends Base {
  type: 'slope';
  columns: [string, string];
  data: { name: string; from: number; to: number; color?: string }[];
}

Style it

  • Colours: theme.palette, chart.setColor(name, colour), or --nervure-palette in your CSS. More
  • Marks: [data-series="name"], parts: [data-part="axes"], legend, series. What you change is kept in exports.
  • Movement: animation: false draws at once. More
  • Files: chart.download('png'), svg, csv. More

Close to it