【发布时间】:2020-04-14 14:25:41
【问题描述】:
我在我的 Angular 项目仪表板中使用了谷歌图表。
通过阅读文档: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);
}
我需要成熟度和年份的值...我如何得到它?我做了什么改变吗??
【问题讨论】:
-
谁能给我一个想法??
-
谁能帮帮我??
标签: angular6 angular5 angular7 react-google-charts