下午好
我有一个角度控制器,其中包含我在图表中显示的数据
<nvd3-multi-bar-horizontal-chart
ng-model="Data"
data="Data"
id="exampleId"
xAxisTickFormat="xAxisTickFormatFunction()"
yAxisTickFormat="yAxisTickFormatFunction()"
height={{height}}
showValues="true"
color="colorFunction()"
showXAxis="true"
margin="{left:100}"
interactive="true"
>
<svg></svg>
</nvd3-multi-bar-horizontal-chart>
编辑:
应用程序需要做的是显示数组中的所有数据,用户可以调整该数组中的1个元素
我现在尝试使用ng-click页面上的一个按钮来对此进行模拟,该按钮执行以下方法来调整数组中的1个元素
$scope.buttonClick = function(){
$scope.Data[0].values[0][1] = 2345; //this changes the data but does not update the chart
$scope.Data = [
{
key: "timeData",
values: [
["test", 1234]
]
}
] //this completely overrides the array and replaces it (which i dont want)
};
控制器更新数据,但图表不更新
我通过在正确更新的段落中显示数据的第一个条目进行了测试
有谁知道如何解决这个问题
(链接到角度chart directive中使用的指令)
提前致谢
最佳答案
通过查看源,您需要设置objectequality="false".
它设置了$scope.$watch(data, objectequality).
我不是该指令的专家,但可以尝试:
<nvd3-multi-bar-horizontal-chart
...
objectequality="false"
...
>
<svg></svg>
</nvd3-multi-bar-horizontal-chart>