未捕获的类型错误:无法读取未定义的属性“createElementNS”
Uncaught TypeError: Cannot read property 'createElementNS' of undefined
我正在使用nvd3绘制折线图,当我将div传递给nvd3
绘制图表时,它给了我此错误
未捕获的类型错误: 无法读取属性"createElementNS" 的 定义
这是代码:
var chartDiv = 'line-chart'+ counter++;
tmpl = $($('#charts-panel-template').clone().html());
tmpl.find('.feature-line-chart').attr('id', chartDiv);
var div=tmpl.find('.feature-line-chart#'+chartDiv);
chartsPanel.append(tmpl);
nv.addGraph(function() {
var chart;
var width = 1024, height = 500;
chart = nv.models.lineChart()
// .color(sparkChart.colors)
.width(width).height(height);
//modify the x.axes
chart.x(function(d,i) {
return d.x;
});
//giving chart margin
chart.margin({right: 40});
$(div).empty();
//create chart
var svg = d3.select(div).append('svg')
.datum(data)
.transition()
.duration(500)
.call(chart)
.attr('width', width)
.attr('height', height);
我的问题,
- 我做错的地方
- 是我错过了什么
我刚刚遇到了同样的问题。
不能将 jquery 引用传递给 d3.select():
d3.select($element) //no bueno
你必须传递实际的 DOM 节点,或者像你最终发现的那样传递 id。
d3.select($element[0])
或
d3.select("#id")
我已经得到了解决方案,尽管 NVD3 olny 需要 id
var div=tmpl.find('.feature-line-chart#'+chartDiv);
成为
var div='#'+chartDiv;
相关文章:
- TypeError:无法读取属性'推'未定义的JavaScript
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 未捕获的类型错误:无法读取属性'删除'的未定义
- AngularJS指令出错-无法读取属性'编译'的未定义
- 看到“;未捕获的类型错误:无法读取属性'weight'未定义的“;尽管按照字面上的指示
- angularjs无法读取未定义的属性then
- 无法读取属性'材料'未定义的Three.js
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- JavaScript承诺-无法读取属性'那么'的未定义
- 未捕获的类型错误:无法读取属性'中止'的未定义
- 角度推入数组给出:TypeError:无法读取属性'推'的未定义
- Javascript未捕获类型错误:无法读取属性'0'的未定义
- jQuery控制台错误:无法读取属性'top'的未定义
- TypeError:无法读取属性'findAll'的未定义
- 无法读取属性'errcap'未定义的jqgrid
- 无法读取未定义的属性“rid”
- 未捕获的类型错误: 无法读取未定义的属性“图像”
- 可以't读取'getHTML'未定义的Liferay CK Editor内容
- 在node.js中未定义读取属性错误