I have a vue application where I am using Chart.js. I am trying to dynamically populate the chart from data in a table with a row click event. I have the data displaying in the chart, but I am trying to figure out how I could get random colors into it. Any suggestions?
This is what the function looks like:
var ctx = document.getElementById("myDoughnut");
var myDoughnut = new Chart(ctx, {
type: 'doughnut',
data: {
labels: this.getAnalyticRow[0].rowNames,
datasets: [{
data: this.getAnalyticRow[0].rowData,
backgroundColor: [
'rgba(255, 99, 132, 0.6)',
'rgba(54, 162, 235, 0.6)',
'rgba(255, 206, 86, 0.6)',
'rgba(75, 192, 192, 0.6)',
'rgba(153, 102, 255, 0.6)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 2,
}]
},
options: {
responsive: true,
defaultFontColor: '#ffffff',
}
This is the chart: