I want to connect this 3-dimensional poltly.js graph with firebase, data from firebase can already be drawn into the website in the form of an array. but the graph doesn't appear, how come thank you
firebase.database().ref('Perangkat1/hujan').on('value', function(snapshot){
data = snapshot.val()
for(key in data){
x.push(data[key].total);
}});
firebase.database().ref('Perangkat2/hujan').on('value', function(snapshot){
data = snapshot.val()
for(key in data){
y.push(data[key].total);
}});
var x = []
var y = []
var z = [0, 0, 0, 0, 1, 1, 1, 1]
var i = [7, 0, 0, 0, 4, 4, 2, 6, 4, 0, 3, 7]
var j = [3, 4, 1, 2, 5, 6, 5, 5, 0, 1, 2, 2]
var k = [0, 7, 2, 3, 6, 7, 1, 2, 5, 5, 7, 6]
var facecolor = [
'rgb(50, 200, 200)',
'rgb(100, 200, 255)',
'rgb(150, 200, 115)',
'rgb(200, 200, 50)',
'rgb(230, 200, 10)',
'rgb(255, 140, 0)'
]
facecolor2 = new Array(facecolor.length * 2);
facecolor.forEach(function(x, i) {
facecolor2[i * 2 + 1] = facecolor2[i * 2] = x;
});
var data = {
x: x,
y: y,
z: z,
i: i,
j: j,
k: k,
facecolor: facecolor2,
type: 'mesh3d'
}
console.log(data);
Plotly.newPlot('myDiv', [data])