Skip to content

Bus line strip ​

The stops of one line in a row, the load on board between them, and where the bus is. Good for bus and tram lines, school runs and deliveries.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'busline',
  line: '12',
  at: 3.1,
  stops: [
    { name: 'Bab Jedid', minutes: 0, on: 9, off: 0, connections: ['2', '7'] },
    { name: 'Medina', minutes: 3, on: 5, off: 8 },
    { name: 'Boujaafar', minutes: 5, on: 11, off: 6 },
    { name: 'Khezama', minutes: 8, on: 6, off: 5 },
    { name: 'Sahloul', minutes: 11, on: 3, off: 12, connections: ['Train'] },
    { name: 'Hammam Sousse', minutes: 15, on: 9, off: 2 },
    { name: 'Kantaoui', minutes: 18, on: 14, off: 5 },
    { name: 'Chott Meriem', minutes: 20, on: 0, off: 19 },
  ],
};

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 busline takes:

/** One bus or tram line as a strip: its stops, the load on board between them, and where the vehicle is. */
interface BusLineSpec extends Base {
  type: 'busline';
  /** Name of the line, in its badge. */
  line?: string;
  color?: string;
  stops: BusStop[];
  /** Where the vehicle is: 2.5 is halfway between the third and the fourth stop. */
  at?: number;
  onItemClick?: (name: string) => void;
}

interface BusStop {
  name: 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