我在我的角度项目仪表板中使用了谷歌图表。
通过阅读文档:https ://github.com/FERNman/angular-google-charts ,我使用下面的代码来获取事件(它应该包含我选择的图表元素)
根据文档,当图表中的元素被选中时,会发出 select 事件。
<google-chart (select)="onSelect($event)"></google-chart>
我在我的代码中使用了相同的方法。
html:`
<google-chart #chart [title]="Bartitle" [type]="Bartype" [data]="Bardata" [columnNames]="BarcolumnNames"
[options]="Baroptions" [width]="Barwidth" [height]="Barheight"
(select)="onSelect($event)">
</google-chart>`
组件.Ts
this.Bartitle = 'Current and Target';
this.Bartype = 'BarChart';
this.Bardata = [
["2012", 900, 390],
["2013", 1000, 400],
["2014", 1170, 440],
["2015", 1250, 480],
["2016", 1530, 540]
];
this.BarcolumnNames = ["Year", "Current", "Target"];
this.Baroptions = {
hAxis: {
title: 'Maturity'
},
vAxis: {
title: 'Month'
},
};
this.Barwidth = 200;
this.Barheight = 200;
onSelect(event) {
console.log(event);
}
我需要成熟度和年份的值......我怎么得到它?我做了什么改变吗??