Javascript examples for Chart.js:Line Chart
Chartjs line chart with tooltip settings
<html lang="en"> <head> <title>Chart.js Configuring Time Scale - Seconds</title> </head> <body translate="no"> <div id="canvas-holder" style="width: 50%;"> <canvas id="canvas"></canvas> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script> <script> var chartColors = {//from ww w.j a va2 s .co m red: 'rgb(255, 99, 132)', orange: 'rgb(255, 159, 64)', yellow: 'rgb(255, 205, 86)', green: 'rgb(75, 192, 192)', blue: 'rgb(54, 162, 235)', purple: 'rgb(153, 102, 255)', grey: 'rgb(231,233,237)' }; var config = { type: 'line', data: { datasets: [{ label: "My Dataset", fill: false, lineTension: 0.1, borderColor: "#8CCEC2", backgroundColor: "#8CCEC2", borderCapStyle: 'butt', borderJoinStyle: 'miter', pointRadius:0, data: [ { x:moment((new Date()).toISOString()).subtract(1,"seconds") ,y:9000 }, { x:moment((new Date()).toISOString()).subtract(2,"seconds") ,y:11000 }, { x:moment((new Date()).toISOString()).subtract(3,"seconds") ,y:8000 }, { x:moment((new Date()).toISOString()).subtract(4, "seconds") ,y:10000 }, { x:moment((new Date()).toISOString()).subtract(5, "seconds") ,y:9000 } ], spanGaps: false }] }, options: { responsive: true, title: { display: true, text: 'Chart.js Configuring Time Scale' }, tooltips: { mode: 'index', intersect: false, }, hover: { mode: 'nearest', intersect: true }, scales: { xAxes: [{ gridLines: { display: false, }, type: "time", time: { unit: 'second', } }], yAxes: [{ ticks:{ stepSize: 10000 } }] } } }; var myLine = new Chart($('#canvas'), config); </script> </body> </html>