I would like to have custom context menu appearing when I right click on an svg circle. For now I have found this answer that helps me to handle the right click with the following code:
.on("contextmenu", function(data, index) {
//handle right click
//stop showing browser menu
d3.event.preventDefault()
});
Now I would like to know how I can show a box containing some HTML.
Thanks in advance.
d3.select('#stock_details .sym').on("contextmenu", function(data, index) {
var position = d3.mouse(this);
d3.select('#my_custom_menu')
.style('position', 'absolute')
.style('left', position[0] + "px")
.style('top', position[1] + "px")
.style('display', 'block');
d3.event.preventDefault();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With