Chart.js creating a line chart using dates - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

Chart.js creating a line chart using dates

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>chart.js 2.0 bar</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.3/Chart.min.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.0/moment.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from w  w  w  . j  av a 2  s .c  om*/
var canvas = document.getElementById('myChart');
var data = {
    labels: [moment().format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), moment().format("YYYY-MM-DD")],
    type: "line",
    datasets: [
        {
            data: [ 12,21, 32],
        }
    ]
};
var myBarChart = Chart.Line(canvas,{
   data:data,
});
    }

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

Related Tutorials