Skip to content

Skyline ​

Values drawn as the buildings of a city, each as tall as its value. Good for rankings of towns, towers and districts, for a wide audience.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'skyline',
  data: [
    { name: 'Tunis', roof: 'spire', value: 550 },
    { name: 'Sfax', roof: 'flat', value: 440 },
    { name: 'Sousse', roof: 'dome', value: 260 },
    { name: 'Lyon', roof: 'stepped', value: 520 },
    { name: 'Marseille', roof: 'gable', value: 220 },
    { name: 'Nantes', roof: 'flat', value: 220 },
    { name: 'Bizerte', roof: 'spire', value: 630 },
    { name: 'Lille', roof: 'stepped', value: 560 },
  ],
  unit: ' homes',
};

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

/** Values drawn as buildings of a skyline. */
interface SkylineSpec extends Base {
  type: 'skyline';
  data: { name: string; value: number; roof?: 'flat' | 'spire' | 'dome' | 'gable' | 'stepped'; color?: string }[];
  /** Written after each value: ' m'. */
  unit?: string;
  onItemClick?: (name: string) => void;
}

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