在使用 MetricsGraphics.js 时获取 TypeError
Getting TypeError while useing MetricsGraphics.js
我正在尝试使用 MetricsGraphics 绘制一些时间序列数据.js,但似乎无法让它工作,我在网上任何地方都找不到答案。 指标构建在 D3 之上.js
错误是:
TypeError: Cannot read property '0' of undefined
at process_line (http://localhost:9000/bower_components/metrics-graphics/dist/metricsgraphics.js:4211:50)
at Object.charts.line.init (http://localhost:9000/bower_components/metrics-graphics/dist/metricsgraphics.js:2333:13)
at Object.charts.line (http://localhost:9000/bower_components/metrics-graphics/dist/metricsgraphics.js:2973:14)
at Object.MG.data_graphic (http://localhost:9000/bower_components/metrics-graphics/dist/metricsgraphics.js:216:20)
at init (http://localhost:9000/pages/home/home-controller.js:46:12)
at new <anonymous> (http://localhost:9000/pages/home/home-controller.js:59:5)
at invoke (http://localhost:9000/bower_components/angular/angular.js:4182:17)
at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4190:27)
at http://localhost:9000/bower_components/angular/angular.js:8453:28
at link (http://localhost:9000/bower_components/angular-route/angular-route.js:981:26) <div class="container ng-scope" ng-view="">
以下是使图表对象的代码:
MG.data_graphic({
title: "Projector Usage",
description: "Projector Usage in Folsom.",
data: chartData,
width: 800,
height: 450,
target: "#chart",
x_accessor: "date",
y_accessor: "value"
});
这段代码正在生成 JSON 对象数组:
for(var x=0; x < data.length; x++){
chartData.push({
date : new Date(data[x]['timestamp']),
value : data[x]['result']['projectorsOn']
})
}
所以.....这是一个愚蠢的错误。 在我调用填充对象的异步数据调用之前,MG.data_graphics正在尝试访问 chartData。
为了解决这个问题,我只是将该函数添加到 $http.post().success() 回调中。
相关文章:
- 尝试使用.ninnerHTMLlog打印数据,获取错误Uncaught TypeError:undefined不是函数
- TypeError: 使用 Jquery JSON 获取数据时无效的 'in' 操作数 obj
- *简单*解析云代码查询失败”;TypeError:无法调用方法'获取'未定义的“检索该信息”;
- 使用Jquery rateIt插件获取未捕获的TypeError
- 在使用 MetricsGraphics.js 时获取 TypeError
- 使用 $().trigger() 并获取 TypeError: Object [object Object] 没有方法“
- 如何在javascript中声明成员函数?获取“TypeError: Object.function is not a
- 在 Javascript 中执行不区分大小写的排序并获取 TypeError: a.toLowerCase 不是一个函数
- javascript:不能遍历数组:获取:TypeError:对象不是函数
- 使用Angular.js和PHP获取TypeError
- 获取&;TypeError: undefined不是一个函数&;用函数式编程
- 获取TypeError: this.props在ReactJs上没有定义
- 获取"TypeError: document.getElementById(..)是null"当re
- 获取TypeError: Cannot set property '0'尝试向数组添加时未定义的
- 获取"TypeError: invalid 'in'操作数a"在WordPress
- 获取TypeError: undefined不是handsontable.validateCells()上的函数
- 加载jQuery脚本并获取TypeError:$.fn.appear.run不是一个函数
- 在angular.forEach上获取TypeError
- 获取TypeError:对象函数Lodash (value)
- 获取TypeError: Cannot read property 'data'当试图包含我用Angul