Javascript examples for Chart.js:Chart Date Date
Chart.js - scaleType='date'
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.bundle.min.js"></script> <script type="text/javascript"> window.onload=function(){/* w ww.j a v a 2 s. c o m*/ var chartData = { datasets: [{ borderColor: 'red', label: 'Capital R in borderColor, tooltips now work', data: [{ x: new Date('2011-04-11T11:45:00'), y: 25 }, { x: new Date('2011-04-11T12:51:00'), y: 28 }, { x: new Date('2011-04-11T14:10:00'), y: 22 }, { x: new Date('2011-04-11T15:15:00'), y: 18 }] }, { borderColor: 'green', label: 'borderColor all lower case, tooltips now work', data: [{ x: new Date('2011-04-11T11:45:00'), y: 15 }, { x: new Date('2011-04-11T12:51:00'), y: 18 }, { x: new Date('2011-04-11T14:10:00'), y: 12 }, { x: new Date('2011-04-11T15:15:00'), y: 8 }] }, ] }; var ctx = document.getElementById("canvas").getContext("2d"); window.myScatterxx = Chart.Scatter(ctx, { data: chartData, options: { title: { display: true, text: "it is now working", fontSize: 36 }, scales: { xAxes: [{ type: "time", }] } }, }); } </script> </head> <body> <canvas id="canvas"></canvas> </body> </html>