How to use the @projectstorm/react-diagrams.DefaultLabelModel function in @projectstorm/react-diagrams

To help you get started, we’ve selected a few @projectstorm/react-diagrams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github projectstorm / react-diagrams / packages / diagrams-demo-gallery / demos / demo-smart-routing / index.tsx View on Github external
const port3 = node3.addPort(new DefaultPortModel(true, 'in-1', 'In'));
	node3.setPosition(540, 180);
	const node4 = new DefaultNodeModel('Node D', 'rgb(192,0,255)');
	const port4 = node4.addPort(new DefaultPortModel(true, 'in-1', 'In'));
	node4.setPosition(95, 185);
	const node5 = new DefaultNodeModel('Node E', 'rgb(192,255,0)');
	node5.setPosition(250, 180);

	const pathfinding = engine.getLinkFactories().getFactory(PathFindingLinkFactory.NAME);

	// linking things together (specifically using the pathfinding link)
	const link1 = port1.link(port4, pathfinding);
	const link2 = port2.link(port3, pathfinding);

	link1.addLabel(
		new DefaultLabelModel({
			label: 'I am a label!',
			offsetY: 20
		})
	);

	// add all to the main model
	model.addAll(node1, node2, node3, node4, node5, link1, link2);

	// load model into engine and render
	engine.setModel(model);

	return (
		 {