Javascript examples for Chart.js:Chart Data
Add Data to chart.js
<html> <head> <title>chart.js 2.1</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.1.0/Chart.bundle.min.js"></script> <script type="text/javascript"> window.onload=function(){/*from w w w. j av a 2 s .c o m*/ var config = { type: 'line', data: { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset", data: [65, 0, 180, 81, 56, 85, 40], fill: false }] } }; var ctx = document.getElementById("myChart").getContext("2d"); var myChart = new Chart(ctx, config); setTimeout(function(){ config.data.labels.push('Test'); config.data.datasets[0].data.push(3); myChart.update(); }, 1000) } </script> </head> <body> <canvas id="myChart"></canvas> </body> </html>