update Map view to query text tree on the fly & add show id option
This commit is contained in:
+27
-18
@@ -3,24 +3,30 @@
|
||||
width="100%" height="100%"
|
||||
ref="svg" :id="id"
|
||||
>
|
||||
<path
|
||||
v-for="(item, index) in links"
|
||||
:key="`link_${index}`"
|
||||
:d="lineGenerator([item.source, item.target])"
|
||||
stroke="black"
|
||||
/>
|
||||
<template v-if="ready">
|
||||
<path
|
||||
v-for="(item, index) in links"
|
||||
:key="`link_${index}`"
|
||||
:d="lineGenerator([item.source, item.target])"
|
||||
stroke="black"
|
||||
/>
|
||||
|
||||
<template v-for="(node, index) in nodes">
|
||||
<circle
|
||||
:key="'circle' + index"
|
||||
:cx="node.x"
|
||||
:cy="node.y"
|
||||
:class="node.data.class + (node.data.first ? ' first' : '')"
|
||||
:r="node.children ? 7 : 5"
|
||||
>
|
||||
<title>{{ node.data.title }}</title>
|
||||
</circle>
|
||||
<text :key="'text' + index" :x="node.x + 7" :y="node.y-7">{{ node.data.id }}</text>
|
||||
<template v-for="(node, index) in nodes">
|
||||
<circle
|
||||
:key="'circle' + index"
|
||||
:cx="node.x"
|
||||
:cy="node.y"
|
||||
:class="node.data.class + (node.data.first ? ' first' : '')"
|
||||
:r="node.children ? 7 : 5"
|
||||
>
|
||||
<title>{{ node.data.title }}</title>
|
||||
</circle>
|
||||
|
||||
<text
|
||||
v-if="showId"
|
||||
:key="'text' + index" :x="node.x + 7" :y="node.y-7"
|
||||
>{{ node.data.id }}</text>
|
||||
</template>
|
||||
</template>
|
||||
</svg>
|
||||
</template>
|
||||
@@ -45,11 +51,13 @@ export default {
|
||||
props: {
|
||||
nodes: { type: Array, required: true },
|
||||
links: { type: Array, required: true },
|
||||
id: { type: String, default: 'map' }
|
||||
id: { type: String, default: 'node-map' },
|
||||
showId: { type: Boolean, default: true }
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
ready: false,
|
||||
width: 100,
|
||||
height: 100,
|
||||
simulation: forceSimulation(),
|
||||
@@ -74,6 +82,7 @@ export default {
|
||||
this.setupForces()
|
||||
// Wait for DOM update so d3 can select
|
||||
this.$nextTick(this.initListeners)
|
||||
this.ready = true
|
||||
},
|
||||
|
||||
initListeners () {
|
||||
|
||||
Reference in New Issue
Block a user