Skip to content

Entity relationship diagram ​

Tables, their fields and their links. Good for documenting a database.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'er',
  entities: [
    { name: 'Client', fields: ['id', 'name', 'email'] },
    { name: 'Order', fields: ['id', 'client_id', 'date', 'total'] },
    { name: 'Line', fields: ['order_id', 'product_id', 'quantity'] },
    { name: 'Product', fields: ['id', 'name', 'price'] },
  ],
  relations: [
    { from: 'Client', to: 'Order', label: '1 to n' },
    { from: 'Order', to: 'Line', label: '1 to n' },
    { from: 'Line', to: 'Product', label: 'n to 1' },
  ],
};

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

interface ErSpec extends Base {
  type: 'er';
  entities: { name: string; fields: string[]; color?: string }[];
  relations: { from: string; to: string; label?: 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