i using d3 version 5 and react.js and d3-context-menu plugin. i showing an external svg with object tag and i want add a context menu but after right click d3-context-menu not fired.
import * as d3 from 'd3';
import contextMenuFactory from 'd3-context-menu';
.
.
.
let svg = document.querySelector('#svgobject');
let svgDoc = svg.contentDocument;
svg.onload = () => {
let g = d3.select(svgDoc);
var menu = [
{
title: 'Item #1',
action: function(d, i) {
console.log('Item #1 clicked!');
console.log('The data for this circle is: ' + d);
},
disabled: false, // optional, defaults to false
},
{
title: 'Item #2',
action: function(d, i) {
console.log('You have clicked the second item!');
console.log('The data for this circle is: ' + d);
},
},
];
g.selectAll('g').on('contextmenu', contextMenuFactory(menu));
};