|
| 1 | +<script setup> |
| 2 | +import { ref } from 'vue' |
| 3 | +import { MarkerType, VueFlow } from '@vue-flow/core' |
| 4 | +import { Background } from '@vue-flow/background' |
| 5 | +import CustomEdge from './CustomEdge.vue' |
| 6 | +
|
| 7 | +const nodes = ref([ |
| 8 | + { id: '1', position: { x: 0, y: 0 }, data: { label: 'Select me for diamond markers' } }, |
| 9 | + { id: '2', position: { x: 0, y: 150 }, data: { label: 'Select me for circle markers' } }, |
| 10 | + { id: '3', position: { x: 200, y: 0 }, data: { label: 'Node 3' } }, |
| 11 | + { id: '4', position: { x: 200, y: 150 }, data: { label: 'Node 4' } }, |
| 12 | + { id: '5', position: { x: 400, y: 0 }, data: { label: 'Node 5' } }, |
| 13 | + { id: '6', position: { x: 400, y: 150 }, data: { label: 'Node 6' } }, |
| 14 | +]) |
| 15 | +
|
| 16 | +const edges = ref([ |
| 17 | + // This edge uses a custom marker defined in CustomMarker.vue |
| 18 | + { id: '1-2', source: '1', target: '2', type: 'custom' }, |
| 19 | + { |
| 20 | + id: '3-4', |
| 21 | + source: '3', |
| 22 | + target: '4', |
| 23 | + label: 'Marker Arrow', |
| 24 | + // Use MarkerType enum to set the marker |
| 25 | + markerEnd: MarkerType.Arrow, |
| 26 | + markerStart: MarkerType.Arrow, |
| 27 | + }, |
| 28 | + { |
| 29 | + id: '5-6', |
| 30 | + source: '5', |
| 31 | + target: '6', |
| 32 | + label: 'Marker ArrowClosed', |
| 33 | + // EdgeMarker object allows to customize the marker |
| 34 | + markerEnd: { |
| 35 | + type: MarkerType.ArrowClosed, |
| 36 | + color: '#ff0072', |
| 37 | + }, |
| 38 | + markerStart: { |
| 39 | + type: MarkerType.ArrowClosed, |
| 40 | + color: '#ff0072', |
| 41 | + }, |
| 42 | + }, |
| 43 | +]) |
| 44 | +</script> |
| 45 | + |
| 46 | +<template> |
| 47 | + <VueFlow :nodes="nodes" :edges="edges" fit-view-on-init> |
| 48 | + <template #edge-custom="edgeProps"> |
| 49 | + <CustomEdge v-bind="edgeProps" /> |
| 50 | + </template> |
| 51 | + |
| 52 | + <Background /> |
| 53 | + </VueFlow> |
| 54 | +</template> |
0 commit comments