Set background in Chartjs - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

Set background in Chartjs

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://code.jquery.com/jquery-1.11.0.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   w  w w.j a v  a2s.  c o m*/
var barData = {
    labels: ["John W", "Ben T", "Jenny H", "Samantha D", "Anothony P"],
    datasets: [
        {
            fillColor: "rgba(153, 153, 155, 0.4)",
            highlightFill: "#7C7C7C",
            strokeColor: "#7C7C7C",
            pointColor: "#7C7C7C",
            pointStrokeColor: "#7C7C7C",
            pointHighlightFill: "#fff",
            data: [25, 94, 68, 175, 66]
        },
        {
            fillColor: "rgba(236,166,166,0.4)",
            highlightFill: "#C3090A",
            strokeColor: "#f9090a",
            pointColor: "#fff",
            pointStrokeColor: "#C3090A",
            pointHighlightFill: "#f9090a",
            data: [134, 112, 92, 160, 52]
        }
    ]
};
var ctx = $("#bar").get(0).getContext("2d");
var myChart = new Chart(ctx).Bar(barData);
    });

      </script> 
   </head> 
   <body> 
      <canvas id="bar" width="390" height="225"></canvas>  
   </body>
</html>

Related Tutorials