Javascript examples for Chart.js:Pie Chart
Setting specific color per label for pie chart in chart.js
<html> <head> <title>custom background color Chart.js</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="Chart.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.bundle.min.js"></script> <script type="text/javascript"> window.onload=function(){/* w w w . j av a 2 s. com*/ (function() { var ctx = document.getElementById("mychart"); var datas = { labels: ['Passed', 'Failed', 'In Progress'], datasets: [{ label: 'Data', data: [0, 5, 80], backgroundColor: [ "green", "red", "yellow" ], }, ] }; var chr = new Chart(ctx, { data: datas, type: 'pie' }); })(); } </script> </head> <body> <div style="width: 500px;height: 300px"> <canvas id="mychart"></canvas> </div> </body> </html>