【发布时间】:2019-12-18 08:14:47
【问题描述】:
我正在使用 c3.js 显示一个图表,该图表具有按位置区分的部分。单击零件后,我从中获取位置并过滤我的主数据。然后我需要在下面显示一个表格,显示过滤后的记录。
我的部分代码如下:
resultData;
filteredData;
constructor(private appService: AppService) { }
ngOnInit(){
this.apiService.getData('/reportees').subscribe((res)=>{
this.resultData=JSON.parse(res._body);
let value=JSON.parse(JSON.stringify(this.resultData));
this.chart = c3.generate({
data: {
onclick:function(d,element){
this.filteredData=value.filter((record)=>record.location==d.id);
console.log(this.filteredData);
}
当我执行点击操作时,我可以看到过滤数据正在登录浏览器控制台。但在表中,我没有看到填充的行。众所周知,由于没有填充哪些行,所以在页面加载时未定义过滤数据。在这种情况下,请帮助在点击区域时动态显示表格中的记录。
【问题讨论】:
标签: javascript angular c3.js