1👍
✅
Have you tried this ? this.lastSeenDeviceCount.map(element => element.length)
1👍
You can do this;
let devices = []; // array to store all devices
this.lastSeenDeviceCount.forEach(element => {
devices.push(element.length)
})
datasets: [
{
data: devices,
backgroundColor: "#007BA7",
hoverBackgroundColor: "#00CC99"
}
]
What’s happening here is that;
- You created an array
- You populated the array from the loop logic
- Then you pass the value of the array to the chartJs data property to populate the chart
Source:stackexchange.com