Chartjs-How i can insert string data to diagrams in chart.js

0👍

The code that you show us seems right, the only thing that you need is to shift the data in the dataset before adding the new value, like:

socket.on('temp', function(data) { 
    console.log(data.temp);
    document.getElementById('date').innerHTML = data.date; 
    chart.data.datasets.forEach((dataset) => {
        dataset.data.shift();
        dataset.data.push(data.temp); 
    });
    chart.update();
});

Leave a comment