chartjs-plugin-streaming ts
by Akihiko Kusanagi
TypeScript
var chart = new Chart(document.getElementById('chart'), {
type: 'line',
data: {
datasets: [{
data: [],
label: 'Dataset 1',
borderColor: 'rgb(255, 99, 132)',
backgroundColor: 'rgba(255, 99, 132, 0.5)',
borderDash: [8, 4]
}, {
data: [],
label: 'Dataset 2',
borderColor: 'rgb(54, 162, 235)',
backgroundColor: 'rgba(54, 162, 235, 0.5)',
cubicInterpolationMode: 'monotone'
}]
},
options: {
scales: {
x: {
type: 'realtime',
realtime: {
onRefresh: function(chart) {
chart.data.datasets.forEach(function(dataset) {
dataset.data.push({
x: Date.now(),
y: Math.random()
});
});
},
delay: 2000
}
}
}
}
});