Background colour of line charts in chart.js - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

Background colour of line charts in 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.1.2/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w  w.  ja  v  a  2  s  . com*/
var ctx = document.getElementById("myChart");
Chart.defaults.global.defaultFontColor= '#fff';
var myChart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
      label: '# of Votes',
      data: [12, 19, 3, 5, 2, 3],
      backgroundColor: 'rgba(185, 214, 200, 0.75)',
      borderColor: 'rgba(255, 255, 255, 0.5)'
    }]
  },
  options: {
    scales: {
       xAxes: [{
         gridLines: {
           display: false
        }
      }],
      yAxes: [{
        ticks: {
           beginAtZero:true
        }
      }]
    }
  }
});
    }

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

Related Tutorials