[英]Angular with D3 js
我已经通过在D3中使用eval函数动态创建了比例尺,但是当我将d3与angular一起使用时,eval函数无法正常工作,并且在我称比例尺时出现了错误。
TypeError: e.copy is not a function
at SVGGElement.<anonymous> (http://localhost:3000/app/d3.v3.min.js:5:13917)
at http://localhost:3000/app/d3.v3.min.js:3:15103
at Y (http://localhost:3000/app/d3.v3.min.js:1:4505)
at Array.Co.each (http://localhost:3000/app/d3.v3.min.js:3:15078)
at Array.n (http://localhost:3000/app/d3.v3.min.js:5:13838)
at Array.Co.call (http://localhost:3000/app/d3.v3.min.js:3:15178)
at Scope.HistoricalGraph.$scope.draw (http://localhost:3000/app/beanstalk/yhgraph/historicalgraph/historicalgraph.controller.js:418:26)
at fn (eval at <anonymous> `enter code here`(http://localhost:3000/bower_components/angular/angular.js:14432:15), <anonymous>:2:203)
at expensiveCheckFn (http://localhost:3000/bower_components/angular/angular.js:15485:18)
at ngEventDirectives.(anonymous function).compile.element.on.callback (http://localhost:3000/bower_components/angular/angular.js:25018:17)
您可以创建一个动态对象,例如:
var channelsObject = {};
for(var i = 0;i <channel.length; i++){
channelsObject[channel[i]] = {};
}
这样,您将获得如下对象:
{
x:{},
y:{},
z:{}
}
人们应该始终避免使用eval。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.