Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Vis JS Edge:显示起点和终点的标签_Javascript_Vis.js Network_Vis.js - Fatal编程技术网

Javascript Vis JS Edge:显示起点和终点的标签

Javascript Vis JS Edge:显示起点和终点的标签,javascript,vis.js-network,vis.js,Javascript,Vis.js Network,Vis.js,我使用VisJS显示网络地图(即路由器和交换机之间的链接),因此每个VisJS的边缘对我来说都是两个设备之间的链接。 单击边缘,我想在边缘的两端显示设备的两个端口,这要归功于它们的连接 对于距离(以非常精确的图形方式!): 有人能帮我吗?好吧,你需要的是使用上的来进行这样的活动: network.on('click',function(ev){ if(ev.nodes.length != 0 || ev.edges.length != 1) return; var

我使用VisJS显示网络地图(即路由器和交换机之间的链接),因此每个VisJS的边缘对我来说都是两个设备之间的链接。 单击边缘,我想在边缘的两端显示设备的两个端口,这要归功于它们的连接

对于距离(以非常精确的图形方式!):


有人能帮我吗?

好吧,你需要的是使用上的
来进行这样的活动:

network.on('click',function(ev){
    if(ev.nodes.length != 0 || ev.edges.length != 1)
        return;
    var edge = ev.edges[0];
    // do what you need for that edge:
    // use edge.from and edge.to to get the corresponding nodes,
    // get the ports from wherever you have them stored,
    // add/show labels
});

与此同时,我发现了一些有趣的事情。无论如何尝试使用它,我都将所有标签折叠并覆盖。
network.on('click',function(ev){
    if(ev.nodes.length != 0 || ev.edges.length != 1)
        return;
    var edge = ev.edges[0];
    // do what you need for that edge:
    // use edge.from and edge.to to get the corresponding nodes,
    // get the ports from wherever you have them stored,
    // add/show labels
});