views:

26

answers:

1

I am using flot to do some graphing and I am trying to animate the graph into steps. I want to take a multi-dimensional array with say 3 objects where each of those objects has 3 objects. So I have this:

array1[0][0] = 30
array1[0][1] = 30
array1[0][2] = 10
array1[1][0] = 35
array1[1][1] = 35
array1[1][2] = 15
array1[2][0] = 40
array1[2][1] = 40
array1[2][2] = 20

Array1[1] is the second step of my graph (in this case drawing a circle starting at midpoint 35,35 with a radius of 15). My problem is I only want to send flot the current step. So I want to pull out the object stored in array1[1] and put it into another, blank array so I end up with array2 like this:

array2[0][0] = 35
array2[0][1] = 35
array2[0][2] = 15

I keep seeing a lot of information about copying whole arrays but I really just need the one part and I just can't figure it out. I'm sure I've just gotten too much in my own head but any help would be appreciated.

+2  A: 

Javascript does not support true multi-dimensional arrays; you're using an array of arrays.

You can assign the inner array like this:

array2[0] = array1[0];
SLaks
This got me to the answer, thanks!The real problem was trying to pull the 2nd or 3rd element of the big array and always populate the only second level element in the small array. I ended up having to define the smaller array out. So this is what I ended up with:var array1 = [];var array2 = new Array(1);array2[0] = new Array(3);<After filling the big array>array2[0][0] = array1[1][0];
DDayDawg