Hi community,
I have been playing around with vis.js for a while now and have landed up in a problem.
Background: I am trying to use vis.js (v: 4.21.0) with Angular4 (v: 4.2.4).
Issue:
I want to call a custom method before deleting the node, so I added a method to delete node in manipulation, But I am unable to call my custom method from this, Refer code I have added comments to explain myself .
Code: My-component.ts
export class MyComponentComponent implements OnInit {
private graphData: any;
private options: any;
constructor() { }
ngOnInit() {
let nodeList = new Vis.DataSet([
{id: 1, label: 'Node 1'},
{id: 2, label: 'Node 2'},
{id: 3, label: 'Node 3'},
{id: 4, label: 'Node 4'},
{id: 5, label: 'Node 5'}
]);
// create an array with edges
let edgeList = new Vis.DataSet([
{from: 1, to: 3},
{from: 1, to: 2},
{from: 2, to: 4},
{from: 2, to: 5}
]);
this.graphData = {nodes: nodeList, edges: edgeList};
this.options = {
manipulation: {
enabled: true,
initiallyActive: false,
addNode: true,
addEdge: true,
editEdge: true,
deleteNode: function(nodeData,callback) {
debugger
this.deleteNodeFunction(nodeData); // defined below
`here getting issue ''this'' is not defined.`
},
deleteEdge: true,
}
};
let network;
try {
const container = document.getElementById('test');
debugger;
network = new Vis.Network(container, this.graphData, this.options);
}catch (e) {
console.log(e.message)
}
}
deleteNodeFunction(nodeData){
// do something here
// may be call some other other method.
debugger
}
}
@fdambrosio No i have not. but I had a work around playing with groups for my Issue. But still kept the issue open if in case some one has a proper solution.
Hi community, I have been playing around with vis.js for a while now and have landed up in a problem. Background: I am trying to use vis.js (v: 4.21.0) with Angular4 (v: 4.2.4). Issue: I want to call a custom method before deleting the node, so I added a method to delete node in manipulation, But I am unable to call my custom method from this, Refer code I have added comments to explain myself .
Code: My-component.ts
Any help or suggestions how can this be achieved.