Javascript examples for Chart.js:Line Chart
Growing chart value in line chart chart.js
<html> <head> <title>ChartJS Line Chart</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.3.0/Chart.js"></script> <script type="text/javascript"> window.onload=function(){/*w w w . ja v a 2 s.c om*/ var options = { type: 'line', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [ { label: 'Crash line', data: [0, 1], borderWidth: 1 } ] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] } } } var ctx = document.getElementById('chartJSContainer').getContext('2d'); var chart = new Chart(ctx, options); var somefunc = function(chart){ var chartDatasetLength = chart.data.datasets[0].data.length; for(var i = 0; i < chartDatasetLength; i++){ chart.data.datasets[0].data[i] += 1; } chart.update(); } setInterval(somefunc, 1000, chart); } </script> </head> <body> <canvas id="chartJSContainer" width="600" height="400"></canvas> </body> </html>