I am working with a chart.js
graph and I need to assign an array
to the data
property.
Below is my current code snippet:
datasets: [
{
data:[40,56,345,2354],
backgroundColor: "#007BA7",
hoverBackgroundColor: "#00CC99"
}
]
However, I want to use an array
that contains a list
of products
. This is my attempt, but it is not working:
datasets: [
{
data: this.lastSeenDeviceCount.forEach(element => {
element.length
}),
backgroundColor: "#007BA7",
hoverBackgroundColor: "#00CC99"
}
]
This is the information in the data source:
this.lastSeenDeviceCount.push(activeRecords,offlineRecords, pendingRecords);
// array contains this object
{
"DeviceID": "52",
"FriendlyName": "Net RC",
"UserName": "UserNet",
"LastSeen": "07/23/2020 23:18:05",
}