Chartjs-How to realtime plotting firebase data to ChartJS

0👍

You should use onSnapshot method for subscribe to changes:

db.collection("your collection")
     //.where("field", "==", "value")    <--   you can use condition
     //.doc("some document")             <--   or one document
     .onSnapshot(function(snapshot) {
        snapshot.docChanges().forEach(function(change) { 
            if (change.type === "added") {
                console.log("New item: ", change.doc.data());
            }
            if (change.type === "modified") {
                console.log("Modified item: ", change.doc.data());
            }
            if (change.type === "removed") {
                console.log("Removed item: ", change.doc.data());
            }
        });
    });

see more examples in docs

Leave a comment