Chartjs-Chart.js scatter chart plot data joins start and finish points together

1👍

Ah! Figured out the answer by mistake! Accidently commented out a section of code and it now works. All you have to do is remove the section which was meant to add the historic data. As it turns out, both:

dataRefTenMin.once("value").then(function(snapshot)
{
    snapshot.forEach(function(childSnapshot)
    {
        var childData = childSnapshot.val()
        var decTime = childData.decTime
        
        addDataScatter(mouseChart, decTime, childData.mouse)
        addDataScatter(scrollChart, decTime, childData.scroll)
        addDataScatter(keysChart, decTime, childData.keys)
    })
})

and

dataRefTenMin.on("child_added", function(data)
{
    var newData = data.val()
    var decTime = newData.decTime
    
    addDataScatter(mouseChart,newData.decTime, newData.mouse)
    addDataScatter(scrollChart,newData.decTime, newData.scroll)
    addDataScatter(keysChart,newData.decTime, newData.keys)
})

add historic data to the chart. Hence the error comes as they plot the data over each other (I think).

If any one else has a similar problem, remove the first one of the two portions of code above! Then the chart will both plot the historic data and update live.

Leave a comment