Closed leo2505 closed 2 years ago
Hi @leo2505,
EventHandlers
are interface types in TS, not functions.
Since you are writing in JS and not TS, please ignore EventHandlers
and write the following:
const eventHandlers = {
"node:click": ({ node }) => {
console.log('inside');
// toggle
nodes[node].active = !nodes[node].active
},
}
Hi @leo2505,
EventHandlers
are interface types in TS, not functions. Since you are writing in JS and not TS, please ignoreEventHandlers
and write the following:const eventHandlers = { "node:click": ({ node }) => { console.log('inside'); // toggle nodes[node].active = !nodes[node].active }, }
Hi, thanks for the answer. But still don't works. I used this.configs = VNetworkGraph.defineConfigs({}) to configure and works fine in mounted() cycle, only eventHandlers don't works and I can't see where's the problem.
my code is like this:
Template:
js:
<template>
<v-network-graph :nodes="nodes" :edges="edges" :layouts="layouts" :configs="configs" :event-handlers="eventHandlers"/>
</template>
<script>
import * as VNetworkGraph from 'v-network-graph';
name: 'projectName',
data () {
return {
getLigacao: null,
collectionData: null,
nodes: [],
edges: [],
configs: {}
};
},
async created(){
//here's my methods from repositories that get from API.
},
mounted () {
const eventHandlers = {
'node:click': ({ node }) => {
console.log('inside');
// toggle
this.nodes[node].active = !this.nodes[node].active;
}
};
this.configs = VNetworkGraph.defineConfigs({
view: {
layoutHandler: new ForceLayout({
positionFixedByDrag: false,
positionFixedByClickWithAltKey: true
})
},
node: {
selectable: true,
normal: {
type: 'circle',
// radius: node => node.size, // Use the value of each node object
color: node => node.color
},
hover: {
radius: 22
},
focus: {
color: 'black'
}
},
edge: {
normal: {
width: edge => edge.width, // Use the value of each edge object
color: edge => edge.color,
dasharray: edge => (edge.dashed ? '4' : '0')
}
}
});
}
</script>
@dash14 I found the error... the declaration of const was in wrong line. I'm new in VUE, so some things I'm still understanding. Basically I have changed the const eventHandlers to data(), before return. Thanks so much for your help.
I close this issue for now. If you have any other questions, please open a new issue.
Hello everybody, I have an issue relative to use "EventHandlers" in my project.
Importing VNetworkGraph from 'v-network-graph' , the import don't have this function mencioned at doc "vNG.EventHandlers".
The VNetworkGraph have only these exports at dependency (version 0.5.8), and I can't access the "EventHandlers":
I'm using VUE 3 with JS (not TS) and I trying do this in mounted() cycle: