javascript - 动态添加对象属性到现有对象

标签 javascript angularjs highcharts

所以我有一个 json 对象,例如:

"highChart":{
            "xAxis":{  
               "categories":[  
                  "SYN 13 ",
                  "Settlement",
                  "Service Interaction",
                  "FNOL",
                  "Repair Process",
                  "Rental Experience",
                  "Appraisal",
                  "SYN 14 "
               ],
               "title":{  
                  "text":""
               },
               "labels":{  
                  "enabled":true,
                  "maxStaggerLines":1
               },
               "tickWidth":1
            }}

让我们将其定义为$scope.chartConfig = highChart

现在我想向 ChartConfig 添加另一个属性,如下所示:

"highChart":{
         "options":{
            "chart":{  
               "height":null,
               "type":"waterfall"
            }},
            "xAxis":{  
               "categories":[  
                  "SYN 13 ",
                  "Settlement",
                  "Service Interaction",
                  "FNOL",
                  "Repair Process",
                  "Rental Experience",
                  "Appraisal",
                  "SYN 14 "
               ],
               "title":{  
                  "text":""
               },
               "labels":{  
                  "enabled":true,
                  "maxStaggerLines":1
               },
               "tickWidth":1
            }}

因此,在初始化 $scope.chartConfig = highChart 之后,我想添加选项属性以及图表属性,如上所示。我该怎么做?

最佳答案

就像这样...

$scope.chartConfig.options = {
  "chart":{  
    "height":null,
    "type":"waterfall"
 }
};

关于javascript - 动态添加对象属性到现有对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31618301/

相关文章:

javascript - 网页中的 Excel 数据透视表

javascript - Angular : How can I transclude an element into a template that uses ng-repeat?

javascript - 以编程方式为 Highcharts 散点图上的某个点触发点击事件

javascript - Highcharts:从 CSV 加载数据时默认禁用系列

javascript - iGoogle 小工具检查器在 for 循环中抛出错误

javascript - 文本按字长对齐

javascript - 滚动条问题 x2

javascript - ng-disabled 是否在 div 标签中起作用?如果没有,那为什么?

javascript - AngularJS angular-ui-calendar TypeError : this. $compile 不是函数; this.$compile 在 $onInit() 内部有值,但在外部未定义

javascript - polymer 模板在多个图表上重复