Public
Edited
Apr 11, 2023
Insert cell
Insert cell
children = [{
parent: 'left',
items: ['Identitätspolitik', 'Wege in den Krieg', 'Kultur- und Sprachkonflikt'],
alignment: 'left'
}]
Insert cell
anchors = [{
id: 'left',
positionX: 1,
positionY: 1,
}, {
id: 'right',
positionX: 3,
positionY: 1,
}, {
id: 'center',
positionX: 2,
positionY: 1,
}]
Insert cell
function buildNetwork(anchors, children) {
const edges = [];
const nodes = [...anchors];
children.forEach(({parent, items, alignment}) => {
const node = nodes.find(({id}) => id === parent);
items.forEach((item, i) => {
const id = `${parent}-${i+1}`
nodes.push({ id, positionX: node.positionX, positionY: node.positionY, count: i + 1, total: items.length, alignment})
edges.push({ source: node.id, target: id})
})
})
return [nodes, edges]
}
Insert cell
buildNetwork(anchors, children)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more