Highcharts:无法读取AngularJS未定义的属性'parentGroup' [英] Highcharts :Cannot read property 'parentGroup' of undefined with AngularJS
问题描述
我正在使用highChart和angularJS做一个图表。
我遵循这个
从图表海报中,我遇到了这个问题:
Uncaught TypeError:无法在k.setState(App / Template / highcharts / highcharts.js:392:112)处读取未定义
的属性'parentGroup'
at App / Template / highcharts / highcharts.js:207:54
在Array.forEach(native)
at a.each(App / Template / highcharts / highcharts.js:27:360)
at a.Pointer。 $ app $ / $ / $ / $ / $ / $ / $ / $($ / $) Template / highcharts / highcharts.js:380:323)
> 根据 I'm doing a chart using the highChart and angularJS.
I follow this highChart. Here is my code: AngularJS: HTML code: $ scope.Stat
数组对象,您可以分别访问 $ scope.Stat [0] .Validate
$ scope.pieData = [{
名称:'CheckLists Socred',
y:$ scope .Stat [0] .Validate,
color:'#00c853'
},{
name:'CheckLists Not Socred',
y:$ scope.Stat [0]。 NotValidate,
color:'#b71c1c'
}];
app.directive('hcPieChart', function () {
return {
restrict: 'E',
template: '<div></div>',
scope: {
title: '@',
data: '='
},
link: function (scope, element) {
Highcharts.chart(element[0], {
chart: {
type: 'pie'
},
title: {
text: scope.title
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.2f} %'
}
}
},
series: [{
data: scope.data
}]
});
}
};
});
app.controller('ChartsController', function ($scope) {
var ids =location.search;
$scope.Stats=function(){
$http.get(url+"/Stats"+ids)
.success(function(data){
$scope.Stat = data;
}).error(function(err,data){
console.log("error:" +data);
});
};
$scope.Stats();
/*$scope.Stat = [{
"Validate":17.456789,
"NotValidate":2.96296,
"Nb_V":2.96296,
"Nb_Not_v":2.96296
}];
*/
// Sample data for pie chart
$scope.pieData = [{
name: 'CheckLists Socred',
y: $scope.Stat[0].Validate,
color: '#00c853'
},{
name: 'CheckLists Not Socred',
y: $scope.Stat[0].NotValidate,
color: '#b71c1c'
}];
});
<html > <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> </head> <body ng-app="app" ng-controller="ChartsController" > <hc-pie-chart title="Browser usage" data="pieData">Placeholder for pie chart</hc-pie-chart> </body> </html>
What I got this chart
When from the graphic chart poster, I have this problem:
Uncaught TypeError: Cannot read property 'parentGroup' of undefined at k.setState (App/Template/highcharts/highcharts.js:392:112) at App/Template/highcharts/highcharts.js:207:54 at Array.forEach (native) at a.each (App/Template/highcharts/highcharts.js:27:360) at a.Pointer.runPointActions (App/Template/highcharts/highcharts.js:207:32) at k.onMouseOver (App/Template/highcharts/highcharts.js:389:130) at SVGGElement.c (App/Template/highcharts/highcharts.js:380:323)
thank you for helping me,
According to $scope.Stat
array object you have access each as $scope.Stat[0].Validate
$scope.pieData = [{
name: 'CheckLists Socred',
y: $scope.Stat[0].Validate,
color: '#00c853'
},{
name: 'CheckLists Not Socred',
y: $scope.Stat[0].NotValidate,
color: '#b71c1c'
}];
这篇关于Highcharts:无法读取AngularJS未定义的属性'parentGroup'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!