当使用Angular-google-chart指令时,如何访问饼图中的选定项目? [英] when using Angular-google-chart directive, how do you access the selected item in the pie chart?
问题描述
我使用角度谷歌图表 [bouil.github .io / angular-google-chart /]指令创建饼图。
我可以用这个方法触发一个方法 $ b
< div google-chart chart =myChartstyle ={{cssStyle}}on-select =seriesSelected()>< / div>
$ scope.seriesSelected = function(){
console.log('item selected');
}
但是,我无法弄清楚如何获得所选的键项目。我可以看到如何在不使用angular指令的情况下使用google图表时执行此操作:如何使用stackoverflow解答一>。但是,在使用角度时,我无法遵循如何获取元素。这家伙似乎有一个答案(这里也有一个相当准确地显示我正在尝试做什么的plunkr),但它似乎比我所寻找的更复杂。
我可以在ng-google-chart.js指令中看到,有一行向所选项添加属性:
var selectEventRetParams = {selectedItems:$ scope.chartWrapper.getChart()。getSelection()};
但我还没有看到如何访问此属性。任何意见非常感谢。
只要将html更改为
< div google-chart chart =myChartstyle ={{cssStyle}}agc-on-select =seriesSelected(selectedItem) >< / div>
I'm using the angular-google-charts [bouil.github.io/angular-google-chart/] directive to create a pie chart.
I can fire a method using this with
<div google-chart chart="myChart" style="{{cssStyle}}" on-select="seriesSelected()"></div>
$scope.seriesSelected = function () {
console.log('item selected');
}
However, I can't work out how to get the key of the selected item. I can see how to do this when using google charts without the angular directive: how to stackoverflow answer. However, I can't follow how to get the element when using angular. This guy seems to have an answer (there is also a plunkr here that fairly accurately shows what I am trying to do), but it seems to be more complex than what I am looking for.
I can see in the ng-google-chart.js directive, there is a line, that adds a property to the selected items:
var selectEventRetParams = {selectedItems:$scope.chartWrapper.getChart().getSelection()};
but I'm not yet able to see how to access this property. Any advice is much appreciated.
Just change the html to the following
<div google-chart chart="myChart" style="{{cssStyle}}" agc-on-select="seriesSelected(selectedItem)"></div>
这篇关于当使用Angular-google-chart指令时,如何访问饼图中的选定项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!