【发布时间】:2020-04-06 21:44:57
【问题描述】:
我对 Anguler ngx-charts 有疑问。我正在尝试绘制数据但仍然出现错误:ERROR TypeError: data is not iterable.
如果我使用 ts 文件中定义的这些数据,绘图显示正确。
public data = [
{
"name": "Požadovaný prùtok vzduchu",
"series": [
{
"value": " 923",
"name": "0"
},
{
"value": " 923",
"name": "0"
},
{
"value": " 924",
"name": "1"
},
{
"value": " 916",
"name": "5"
},
{
"value": " 916",
"name": "8"
}
]
}
];
但我需要从 https 请求中绘制数据。我的代码是:
this.loadedFile.getContent(email,this.nazev).subscribe(res => {
console.log(this.data);
this.data = res.data;
});
getContent(folder:any, filename:any) {
return this.httpClient.post<any>(apiUrl + 'loginApi/contentApi/file.php', {folder,filename});
}
结果 res.data 应该是格式正确的 JSON。
"data": {
"name": "Požadovaný prùtok vzduchu",
"series": [
{
"value": " 923",
"name": "0"
},
{
"value": " 923",
"name": "0"
},
etc...
这是我的代码,由于可迭代错误,我无法从请求中绘制数据。我尝试将其转换为字符串并返回 JSON 格式,用作字符串,创建数组,但没有任何效果。
谢谢! :)
【问题讨论】:
标签: angular ngx-charts