无法访问 Chart.js 集合中的数据
我正在尝试使用 Chart.js 和 MEAN 堆栈访问集合中的数据以在图表中显示。 我正在检索存储在数据库中的数据集合,但是当我尝试显示特定数据变量时,它没有显示任何内容。 这是正在记录的数据集合:
这是关联的组件打字稿代码:
ngOnInit(): void {
this.chartService.noOfEqu().subscribe(res=>{
console.log(res);
let areaCode = res['list'].map(res=>res.areaCode)
let inoperEqu = res['list'].map(res=>res.inoperEqu)
let operEqu = res['list'].map(res=>res.operEqu)
let date = res['list'].map(res=>res.eventDate)
let Dates = []
date.forEach((res) => {
let jsdate = new Date(res *1000)
Dates.push(jsdate.toLocaleTimeString('en', {year: 'numeric', month: 'short', day:'numeric' }))
});
console.log(Dates)
console.log(areaCode)
})
}
}
但是,日期和区号不会显示在控制台中。
I am trying to access data from the collection to display in a chart using chart.js and MEAN stack.
I am retrieving the collection of data stored in the database but when i try displaying a specific data variable it does not show anything.
This is the collection of data being logged:
and this is the component typescript code associated:
ngOnInit(): void {
this.chartService.noOfEqu().subscribe(res=>{
console.log(res);
let areaCode = res['list'].map(res=>res.areaCode)
let inoperEqu = res['list'].map(res=>res.inoperEqu)
let operEqu = res['list'].map(res=>res.operEqu)
let date = res['list'].map(res=>res.eventDate)
let Dates = []
date.forEach((res) => {
let jsdate = new Date(res *1000)
Dates.push(jsdate.toLocaleTimeString('en', {year: 'numeric', month: 'short', day:'numeric' }))
});
console.log(Dates)
console.log(areaCode)
})
}
}
However the Dates and Area Code does not display in the console.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除“列表”并将areaCode替换为area
remove the "list" and replace areaCode with area