我正在尝试动态地将一个组附加到svg。我正在从svg中选择一个现有的组,如下所示:
var regions = d3.select(document.getElementById('imgMap').contentDocument).select('#cellregionnode').selectAll('circle')[0];
现在我正在尝试动态地将一个组添加到同一个svg中,但由于某种原因我遇到了问题。
var myNewGroup = d3.select(document.getElementById('imgMap').contentDocument).append('g').attr('id','myNewGroup');
但是,尝试此代码会返回以下错误:
Uncaught TypeError: Cannot read property 'apply' of null
at window.onerror (systemjs.js:8)
Uncaught TypeError: Cannot read property 'createElementNS' of null
at XMLDocument.t (d3.v3.min.js:1)
at XMLDocument.<anonymous> (d3.v3.min.js:3)
at Array.Co.select (d3.v3.min.js:3)
at Array.Co.append (d3.v3.min.js:3)
at setGlobals (DataLoader.js:40)
at Object.success (DataLoader.js:17)
at i (app.min.js:2)
at Object.fireWith [as resolveWith] (app.min.js:2)
at A (app.min.js:4)
at XMLHttpRequest.<anonymous> (app.min.js:4)
知道可能导致此错误的原因或解决方法吗?