docs: add dagre layout example

This commit is contained in:
braks
2024-02-05 07:51:12 +01:00
committed by Braks
parent 0bfb5f4046
commit 3220e20c0e
13 changed files with 192 additions and 40 deletions
+3 -8
View File
@@ -13,23 +13,19 @@ const edges = ref(initialEdges)
const { dimensions, fitView } = useVueFlow()
function toggleClass() {
nodes.value = nodes.value.map((node) => ({ ...node, class: node.class === 'light' ? 'dark' : 'light' }))
}
function updatePos() {
nodes.value = nodes.value.map((node) => {
return {
...node,
position: {
x: Math.random() * 10 * dimensions.value.width,
y: Math.random() * 10 * dimensions.value.height,
x: Math.random() * dimensions.value.width,
y: Math.random() * dimensions.value.height,
},
}
})
nextTick(() => {
fitView({ duration: 1000, padding: 0.5 })
fitView({ padding: 0.5 })
})
}
</script>
@@ -42,7 +38,6 @@ function updatePos() {
<Panel position="top-right">
<button style="margin-right: 5px" @click="updatePos">update positions</button>
<button @click="toggleClass">toggle class</button>
</Panel>
</VueFlow>
</template>