Tuesday, 25 March 2014

Playing with Arrays in D3 - Youtube lesson 9

Vienno

Some of these are general javascript functions rather than D3 functions.

data.shift();
  -  Give you the first value in the array "data"

Can add items to the array
Probably .append

Remove items from the array

Sort the array
data.sort(d3.decending);

Find max of the array
d3.max(data);

Find min of the array
d3.min(data);

d3.extend(data);
Returns the min and the maximum.

d3.sum(data);
Add up all the elements.

Some statistical functions
d3.mean(data)
d3.median(data)

Lots more in the API reference

One last:
d3.shuffle(data);
moves them in a random order....



No comments:

Post a Comment