我在尝试整合从api获得的数据时遇到错误。
我在index.html中包含了以下文件:
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.3.9/d3.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.1/nv.d3.min.js"></script>
<script src="http://cmaurer.github.io/angularjs-nvd3-directives/lib/angularjs-nvd3-directives/dist/angularjs-nvd3-directives.js"></script>
这是我的HTML代码:
<div class="col-md-4 overflow-graph">
<nvd3-line-chart
data="exampleData"
id="exampleId"
xAxisTickFormat="xAxisTickFormatFunction()"
yAxisTickFormat="yAxisTickFormatFunction()"
width="550"
height="350"
showXAxis="true"
showYAxis="true">
<svg></svg>
</nvd3-line-chart>
</div>
这是我从
获取数据的地方$scope.exampleData = function(){
for(var count in $scope.skuproduceCart) {
var forecast = $scope.skuproduceCart[count].forecast;
}
return forecast;
};
预测返回具有结构
的对象数组[Object, Object, Object]
这是我得到的错误:
nv.d3.min.js:5 Uncaught TypeError: Cannot read property 'length' of undefined
at https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.1/nv.d3.min.js:5:56
at Array.filter (native)
at SVGSVGElement.<anonymous> (https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.1/nv.d3.min.js:5:22)
at http://cdnjs.cloudflare.com/ajax/libs/d3/3.3.9/d3.min.js:5:3691
at C (http://cdnjs.cloudflare.com/ajax/libs/d3/3.3.9/d3.min.js:1:3397)
at Array.Cs.each (http://cdnjs.cloudflare.com/ajax/libs/d3/3.3.9/d3.min.js:5:3643)
at Array.b (https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.1/nv.d3.min.js:4:31618)
at Array.ma.call (http://cdnjs.cloudflare.com/ajax/libs/d3/3.3.9/d3.min.js:3:9080)
at checkElementID (http://cmaurer.github.io/angularjs-nvd3-directives/lib/angularjs-nvd3-directives/dist/angularjs-nvd3-directives.js:795:216)
at Scope.$scope.d3Call (http://cmaurer.github.io/angularjs-nvd3-directives/lib/angularjs-nvd3-directives/dist/angularjs-nvd3-directives.js:884:15)
如果需要其他信息,请告知我们,我们很乐意为您提供。
感谢任何帮助或指导。
提前致谢。