I want to see my firestore field on loading but it passed as 1 value with 2 params.
I dont know how to solve this plz help :)
[firestore] : https://i.stack.imgur.com/Vhww8.png
[chart + some console.log] : https://i.stack.imgur.com/yY1o6.png
var dataArray = [];
const pH = {};
async function GetDocument() {
var ref = doc(db,"pHvalue", "pH");
const docSnap = await getDoc(ref);
if(docSnap.exists()){
pH.value = docSnap.data().pH;
dataArray.value = dataArray.push(pH.value);
console.log(pH);
console.log(pH.value);
console.log(dataArray);
};
Chart.defaults.font.size = 20;
Chart.defaults.font.color = '#000';
const ctx = document.getElementById('myChartpH').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['pH'],
datasets: [{
label: 'pH value',
data: dataArray,
fill: true,
backgroundColor: 'rgb(120, 16, 126)',
borderWidth: 1,
pointStyle: 'circle',
pointRadius: 5,
pointBackgroundColor: "yellow",
pointBorderColor: 'rgb(0, 0, 0)'
}]
},
options: {
scales: {
y: {
beginAtZero: true,
}
}
},
});
}
window.onload = GetDocument;