Performance issues with JS Client after opening/closing NodeSets multiple times to overlay paths (2) over links
nx.define('Tooltip.Node', nx.ui.Component, {
view: {
content: [{
name: 'topo',
type: 'nx.graphic.Topology',
props: {
...
nodeInstanceClass: 'NTSNode',
nodeSetInstanceClass: 'NTSNodeSet',
linkInstanceClass: "NTSLink",
...
}
}]
...
}
}
In the ’NTSLink‘ class, you can call the ‘addPath‘ function from the ‘update’ function. Because of this every link gets two paths.
Now, the more Nodes and Links are in the topology, the worse will be the performance.
When opening a NodeSet, the application is not opening the nodes fluid.
If you remove the ‘addPath’ function, everything works fine.
nx.define('NTSLink', nx.graphic.Topology.Link, {
methods: {
update: function() {
this.inherited();
this.addPath();
},
addPath : function(){
var pathLayer = this.topology().getLayer("paths")
var links1 = [this];
var path1 = new NTSPath({
pathPadding: [20, '50%'],
pathWidth: 1,
links: links1,
arrow: 'end',
pathStyle : {
stroke: '#6BC7E2',
fill: "#6BC7E2",
cursor: "pointer"
},
isFirstPath : true
});
var path2 = new NTSPath({
pathPadding: [20, '50%'],
pathWidth: 1,
links: links1,
reverse: true,
arrow: 'end',
pathStyle : {
stroke: '#007699',
fill: "#007699",
cursor: "pointer"
},
isFirstPath : false
});
pathLayer.addPath(path1);
pathLayer.addPath(path2);
}
}
});
The performance issues cause by :
when nodeSet opening, it will redraw all the related links and 'update' function will be invoked 60 times/second, so in this case, you add dozens of paths to topology. So you can add a simple logic to detacted if you have attached path or not.
And better way is use general way to add path or just extend 'attach' function in your links instance.
Comments
0 comments
Please sign in to leave a comment.