I want to open a extension popup on right click of node in visjs. I tried many things but none seem to be helpful. I want popup to be an ordered list
Asked
Active
Viewed 7,085 times
6
-
It doesn't look like vis.js has a feature for a context menu. There is an open feature request, but this doesn't look like a vis.js specific feature. Are you just wanting a context menu? – mwilson Jul 08 '16 at 04:46
-
Yes. I want a context menu. On click of a node I can display a list of all attributes. – Jubin Mehta Jul 08 '16 at 11:25
-
@mwilson Also one more help needed. Inside a node I want to have an image as well as label. Can it be happen for visjs ? I can either have an image or label inside a node. Currently If I have an image then label is coming outside of the node – Jubin Mehta Jul 08 '16 at 11:26
-
var nodes = new vis.DataSet([ {id:0, label:'Hello1', image:'../images/Picture1.jpg', shape:'image', title:'Hello1'}, {id:0, label:'Hello2', image:'../images/Picture2.jpg', shape:'image', title:'Hello2'}]); – Jubin Mehta Jul 08 '16 at 11:30
1 Answers
10
A really good explanation of how to create a context menu can be found here.
Below is the relevant JS code for vis.js using the linked example.
With your vis.Network var, assuming it's called network:
network.on("oncontext", function (params) {
params.event.preventDefault();
$(".custom-menu").finish().toggle(100);
$(".custom-menu").css({
top: params.event.pageY + "px",
left: params.event.pageX + "px"
});
});
Hope this helps.

Ravindra Gupta
- 1,256
- 12
- 42

Jeff
- 101
- 1
- 3
-
1
-
2There is an API for this: `network.getNodeAt(params.poiner.DOM)` – Naeel Maqsudov Mar 28 '19 at 12:44
-
1Sorry for the misprint: params.poiner.DOM -> params.pointer.DOM – Naeel Maqsudov Mar 28 '19 at 12:57