use*_*030 10 javascript highcharts
我正试图将highcharts放入我的角度应用程序中.我从Google表格中获取数据并从调用谷歌返回一个承诺对象.然后我用我的选项对象调用Highcharts.Chart()方法.
拨打电话时我收到以下错误消息.我试图找出发生了什么,但我现在迷路了.我有一个原型,我不使用角度,图表工作得很好.当我去添加新的Highcharts.Chart(选项)行时,我得到以下错误.我删除该行错误消失了.
任何想法/帮助都会很棒!
错误:
TypeError: undefined is not a function
at Object.Chart.init (/highcharts.src.js:11014:4)
at Object.Chart (/highcharts.src.js:10937:12)
at data.then.$scope.sheetdata (/js/controllers/controlChartCtrl.js:11:17)
at wrappedCallback (/angularjs/1.2.6/angular.js:10905:81)
at /angularjs/1.2.6/angular.js:10991:26
at Scope.$eval (/angularjs/1.2.6/angular.js:11906:28)
at Scope.$digest (/angularjs/1.2.6/angular.js:11734:31)
at Scope.$delegate.__proto__.$digest (<anonymous>:844:31)
at /angularjs/1.2.6/angular.js:11945:26
at completeOutstandingRequest (/angularjs/1.2.6/angular.js:4098:10)
Run Code Online (Sandbox Code Playgroud)
部分:
Features:
<div id="feature"></div>
Run Code Online (Sandbox Code Playgroud)
控制器:
angular.module('controlChartCtrl', []).
controller('ControlChartCtrl', ['$scope', 'GoogleService', function($scope, GoogleService) {
var data = GoogleService.getData();
$scope.helloworld = "hello world!";
data.then(function (data) {
// create charts here
var options = getOptionsForChart('Feature', 'feature', data);
var chart = new Highcharts.Chart(options);
}, function (error) {
$scope.sheetdata = error;
});
var getOptionsForChart = function (title, div, data) {
return {
chart: {
renderTo: div,
type: 'line'
},
title: {
text: title + ' Control Chart'
},
xAxis: {
title: {
text: 'End Dates'
},
categories: data.endDates
},
yAxis: {
title: {
text: 'Lead Time'
}
},
series: [{
name: 'Lead Time',
data: data.leadTimes
}]
};
}
}]);
Run Code Online (Sandbox Code Playgroud)
use*_*030 15
我解决了这个问题.解决方案如下.
Highcharts要求jQuery正常运行.当我在highcharts.js文件上面添加jquery.js文件时,角度应用程序开始正常工作.
感谢您的反馈!
mik*_*ana 10
Highcharts 不需要JQuery工作(当前的答案是错误的),但是你需要首先加载'standalone framework'库:
define([
'vnd/highcharts/standalone-framework',
'vnd/highcharts/highcharts',
], function(){
...
}
Run Code Online (Sandbox Code Playgroud)
请参阅@ Sebastian的jsfiddle进行演示:http: //jsfiddle.net/highcharts/aEuGP/
| 归档时间: |
|
| 查看次数: |
15583 次 |
| 最近记录: |