Having a serious problem here, I have an array structured like this:
[[0,50],[0,68],[1,26],[2,9],[2,32]]
I am looking to split this array into two separate arrays like so:
array1 = [[0,50][1,0][2,9]]
array2 = [[0,68][1,26][2,32]]
Yes, you are correct guys, I need this in order to create a flot chart.
If anyone is curious about the source of data, this is how it appears in Firebase:
{
"1433203200000" : {
"-JpgJnANTpQFprRieImv" : {
"events" : 5,
"name" : "Home office",
"returningVisitors" : 9,
"totalVisitors" : 50
},
"-JqsQjFTjHpzKqWgE_KJ" : {
"events" : 10,
"name" : "Samin Place",
"returningVisitors" : 32,
"totalVisitors" : 68
}
},
"1433289600000" : {
"-JqsQjFTjHpzKqWgE_KJ" : {
"name" : "Samin Place",
"newVisitors" : 1,
"returningVisitors" : 25,
"totalVisitors" : 26
}
},
"1433376000000" : {
"-JpgJnANTpQFprRieImv" : {
"events" : 5,
"name" : "Home office",
"returningVisitors" : 9,
"totalVisitors" : 9
},
"-JqsQjFTjHpzKqWgE_KJ" : {
"events" : 10,
"name" : "Samin Place",
"returningVisitors" : 32,
"totalVisitors" : 32
}
}
}
The goal is to iterate through each timestamp and each child entry. Within each child entry, there is a "totalVisitors" value that I require for my chart.
BONUS
As noted, the first timestamp has two child entries, which is fine. However, the second timestamp only has one child entry - "-JqsQjFTjHpzKqWgE_KJ." Therefore, I need to add a null value for the missing entry into the new array (in our example, it's the second position in array1).
This is what I refer to as the CHALLENGE :)
Any assistance is greatly appreciated, thank you for your attention.
Edit:
If it helps someone, this is the type of chart that I need
X-axis - timestamps
Y-axis - totalVisitors value
Lines - each unique timestamp child