Chartjs - json data for line chart - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

Chartjs - json data for line chart

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://momentjs.com/downloads/moment.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w w.  ja  v  a 2 s  .  c  o m*/
var data = [{"x":"2017-06-03T13:23:47.129Z","y":1.306},
{"x":"2017-06-03T14:17:24.960Z","y":1.299},
{"x":"2017-06-03T14:17:46.565Z","y":1.306}];
var ctx = document.getElementById('chartJS').getContext('2d');
new Chart(ctx, {
    type: 'line',
    data: {
        datasets: [{
            label: 'label',
            data: data,
            borderColor: "#000066"
        }],
    },
    options: {
        scales: {
            xAxes: [{
                type: "time",
                display: true,
                scaleLabel: {
                    display: true,
                    labelString: 'Date'
                },
            }]
        }
    }
});
    }

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

Related Tutorials