Estoy revisando las últimas 100000 medidas de humedad y haciendo un gráfico, pero en el gráfico quiero mostrar cada 100 medidas, ¿cómo puedo modificar este código para hacer esto?
firebase.database().ref("Humidity").ref.orderByChild("time").limitToLast(100000).on("child_added",snapshot => { var a = snapshot.val().wartosc; var b = (new Date(snapshot.val().time *1000)).toLocaleString("pl-PL"); addData(myChart, b, a);Esto debería funcionar:
firebase.database().ref("Humidity") // 👈 Remove the extra ref here .orderByChild("time") .limitToLast(100000) .on("value", snapshot => { // 👈 use value instead of child_added let index = 0; snapshot.forEach((child) => { if (index++ % 1000 === 0) { // 👈 check for every 1000th child var a = child.val().wartosc; var b = (new Date(child.val().time * 1000)).toLocaleString("pl-PL"); } addData(myChart, b, a); }) })He marcado los cambios principales, pero es posible que también se necesiten algunos cambios más pequeños.