jquery - Populate colors on a Chart.js chart dynamically -


i have vue application using chart.js. trying dynamically populate chart data in table row click event. have data displaying in chart, trying figure out how random colors it. suggestions?

this 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 chart:

chart


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

vue.js - Create hooks for automated testing -