Chartjs-Passing data to a chart javascript object and array

0👍

You can use the Array.map() method on the usersList to create the arrays that contain the desired attributes of the users.

Your code would have to be changed as follows:

data: {
  labels: usersList.map(u => u.name),
  datasets: [{
    label: ' Views per channel ',
    data: usersList.map(u => u.social),
    borderWidth: 1
  }]
}

Leave a comment