Flowchart
Boxes and arrows, laid out for you. Good for processes and decisions.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'flowchart',
nodes: [
{ id: 'start', label: 'Order received', shape: 'round' },
{ id: 'stock', label: 'In stock?', shape: 'diamond' },
{ id: 'buy', label: 'Order from supplier' },
{ id: 'pay', label: 'Payment', shape: 'data' },
{ id: 'ok', label: 'Paid?', shape: 'diamond' },
{ id: 'pack', label: 'Pack and send' },
{ id: 'mail', label: 'Remind the client', shape: 'hexagon' },
{ id: 'end', label: 'Delivered', shape: 'round' },
],
links: [
{ from: 'start', to: 'stock' },
{ from: 'stock', to: 'pay', label: 'yes' },
{ from: 'stock', to: 'buy', label: 'no' },
{ from: 'buy', to: 'ok', dashed: true },
{ from: 'pay', to: 'ok' },
{ from: 'ok', to: 'pack', label: 'yes' },
{ from: 'ok', to: 'mail', label: 'no' },
{ from: 'mail', to: 'pay', dashed: true },
{ from: 'pack', to: 'end' },
],
};
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 flowchart takes:
interface FlowchartSpec extends Base {
type: 'flowchart';
nodes: { id: string; label: string; shape?: FlowShape; color?: string }[];
links: { from: string; to: string; label?: string; dashed?: boolean }[];
direction?: 'down' | 'right';
onNodeClick?: (id: string) => void;
}
type FlowShape = 'box' | 'round' | 'diamond' | 'circle' | 'data' | 'hexagon';Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More