首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将多个HighChart放入不同图表中具有不同序列值的页面中

如何将多个HighChart放入不同图表中具有不同序列值的页面中
EN

Stack Overflow用户
提问于 2016-05-24 20:07:44
回答 2查看 237关注 0票数 0

代码语言:javascript
复制
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.
代码语言:javascript
复制
<div ng-repeat="perspective in perspectives">
          <highcharts-pie class="hc-pie" items="processed" title="perspective.title"></highcharts-pie>
      </div>

这是我的html页面,处理的是我的函数名,它有硬编码的参数,所以我只得到了所有折线图中的第一个数组对象,希望graphData数组可以放入不同的折线图中。

提前致谢

EN

回答 2

Stack Overflow用户

发布于 2016-05-24 20:37:49

“已处理”对象定义在“透视”对象的第零个元素上。

代码语言:javascript
复制
$scope.perspectives[0]

您应该创建一个函数,并将索引/透视对象传递给该函数,然后获取特定于该函数的项目列表。

函数在您的控制器中:

代码语言:javascript
复制
$scope.getItems=function(perspective){
   return perspective.graphData.map(function(elem,i){
      return [i,elem];
     });
}

在您的视图中:

代码语言:javascript
复制
<div ng-repeat="perspective in perspectives">
      <highcharts-pie class="hc-pie" items="getItems(perspective)" title="perspective.title"></highcharts-pie>
</div>

还要确保你的指令‘highcharts pie’中的项目绑定是'=‘。

票数 2
EN

Stack Overflow用户

发布于 2016-05-25 17:51:47

不需要创建函数getItems(),

items="perspective.graphData“//在body.html中也可以

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37413107

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档