Chartjs-How to solve ERROR TypeError: labels.slice is not a function?

0👍

chart.js expects the labels property to be an array.
But your labels is a Set object, which can’t use slice.

One way to fix this, would be to use an array instead of a set.

Another way would be getting an array from the set like this:

this.datosGrafico = {
  labels: Array.from(labels),
  datasets: datasets,
};

But I would suggest to just use an array instead of a set.

Leave a comment