Create elements helper function.
Array of elements to create.
Array of elements. (Nodes)
without custom data
const elements = createElements([ { id: '1', type: 'rect', x: 10, y: 10, width: 100, height: 100 }, { id: '2', type: 'circle', x: 200, y: 200, width: 100, height: 100 },]); Copy
const elements = createElements([ { id: '1', type: 'rect', x: 10, y: 10, width: 100, height: 100 }, { id: '2', type: 'circle', x: 200, y: 200, width: 100, height: 100 },]);
with custom data
const elements = createElements([{ id: '1', type: 'rect', x: 10, y: 10 ,data : { label: 'Node 1' }, width: 100, height: 100 },{ id: '2', type: 'circle', x: 200, y: 200, data : { label: 'Node 2' }, width: 100, height: 100 },]); Copy
const elements = createElements([{ id: '1', type: 'rect', x: 10, y: 10 ,data : { label: 'Node 1' }, width: 100, height: 100 },{ id: '2', type: 'circle', x: 200, y: 200, data : { label: 'Node 2' }, width: 100, height: 100 },]);
Create elements helper function.