How to make Chart JS responsive? - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

How to make Chart JS responsive?

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> 
   </head> 
   <body translate="no"> 
      <div class="container-fluid"> 
         <div class="row"> 
            <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"> 
               <canvas id="bar" width="390" height="225"></canvas> 
            </div> 
         </div> 
      </div> 
      <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.min.js"></script> 
      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
      <script>
      var barData = {//from ww w  .  j  av  a 2 s.co m
    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, {
  responsive: true
});
      //# sourceURL=pen.js
    
      </script>  
   </body>
</html>

Related Tutorials