Chart.js to create line chart - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

Chart.js to create line chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.bundle.min.js</title> 
      <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.6/Chart.bundle.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//ww w  .  j  av  a 2 s.  c  o  m
var data = [200, 1100, 100, 250]
var data2 = [214, 0, 223, 240]
var ctx = document.getElementById("myChart");
    var myChart = new Chart(ctx, {
        type: 'line',
        data: {
            labels: ["11/2016", "12/2016", "01/2017", "02/2017"],
            datasets: [{
                            label: 'Info',
                            backgroundColor: "rgba(46, 44, 211, 0.2)",
                            borderColor: "rgba(46, 44, 211, 0.5)",
                            data: data
                        },
                        {
                            label: 'stuff',
                            backgroundColor: "rgba(46, 44, 11, 0.2)",
                            borderColor: "rgba(46, 44, 11, 0.5)",
                            data: data2
                        }
                    ]
        },
        options: {
        responsive:true,
        }
    });
    }

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

Related Tutorials