Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Chart updates as data arrives
connection.on("newData", function (time, speed, count) {
// This subtract causes the data to be placed
// in the centre of the chart as it arrives,
// which I personally think looks better...
var dateValue = moment(time).subtract(5, 'seconds');
speedValue.innerText = speed;
countValue.innerText = count;
// append the new data to the existing chart data[0].data.push({
x: dateValue,
y: speed
// update chart datasets keeping the current animation
preservation: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment