app.controller("myCtrl", function($scope) {
$scope.perspectives = [{
title : 'Depression Remission at 12 Months CMS159v4',
graphData: [34,2,5,5,2,1,10]
},
{
title : 'Comprehensive Diabetes Care: HbA1c Poor Control (>9.0%)',
graphData: [2,7,9,25,55,20]
},
{
title : 'Screening for Clinical Depression and follow-up',
graphData: [2,7,9,25,55,20]
},
{
title : 'Tobacco Assessment and Counseling',
graphData: [2,7,9,25,55,20]
},
{
title : 'Alcohal AND Drug Misuse(SBIRT)',
graphData4: [2,7,9,25,55,20]
}];
$scope.processed = $scope.perspectives[0].graphData.map(function(elem,i){
return [i,elem];
});
})
This is My controller from where i am passing array for title and value for different linechart. i have directive where i have Highchart.chart constructor where i putting all chart object.<div ng-repeat="perspective in perspectives">
<highcharts-pie class="hc-pie" items="processed" title="perspective.title"></highcharts-pie>
</div>
这是我的html页面,处理的是我的函数名,它有硬编码的参数,所以我只得到了所有折线图中的第一个数组对象,希望graphData数组可以放入不同的折线图中。
提前致谢
发布于 2016-05-24 20:37:49
“已处理”对象定义在“透视”对象的第零个元素上。
$scope.perspectives[0]您应该创建一个函数,并将索引/透视对象传递给该函数,然后获取特定于该函数的项目列表。
函数在您的控制器中:
$scope.getItems=function(perspective){
return perspective.graphData.map(function(elem,i){
return [i,elem];
});
}在您的视图中:
<div ng-repeat="perspective in perspectives">
<highcharts-pie class="hc-pie" items="getItems(perspective)" title="perspective.title"></highcharts-pie>
</div>还要确保你的指令‘highcharts pie’中的项目绑定是'=‘。
发布于 2016-05-25 17:51:47
不需要创建函数getItems(),
items="perspective.graphData“//在body.html中也可以
https://stackoverflow.com/questions/37413107
复制相似问题