Javascript examples for Chart.js:Line Chart
Displaying data with line chart in chart.js
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w .j a v a2s . c om var myDATA = [ { "date":"2018-04-01 00:00:02", "temp":"1.2" }, { "date":"2018-04-01 01:00:50", "temp":"1.0" } ]; var ctx = document.getElementById("myChart").getContext('2d'); var myChart = new Chart(ctx, { type: 'line', data: { labels: [myDATA[0].date, myDATA[1].date], datasets: [{ label: 'TEMPERATURES', data: [myDATA[0].temp, myDATA[1].temp] }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } }); } </script> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script> <canvas id="myChart" width="400" height="400"></canvas> </body> </html>