Change background color of label Chart.js - Javascript Chart.js

Javascript examples for Chart.js:Chart Color

Description

Change background color of label Chart.js

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//from   www  . jav a  2 s.c  o  m
var ctx = document.getElementById("myChart").getContext('2d');
Chart.defaults.global.defaultFontColor = 'rgba(255, 255, 255, 0.7)';
var myChart = new Chart(ctx, {
      type: 'polarArea',
    data: data = {
        datasets: [{
            data: [25, 10, 20],
            backgroundColor: [
                'yellow',
                'blue',
                'red',
            ],
            borderColor: [
                'yellow',
                'blue',
                'red',
            ],
        }],
        labels: [
            'Yellow',
             'Blue',
             'Red',
        ]
    },
    options: {
        scale: {
            ticks: {
              backdropColor: 'black'
            }
        }
    }
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="myChart" width="400" height="400"></canvas> 
      <script>
</body>
</html>
      </script>
   </body>
</html>

Related Tutorials