There’s a second argument to each function you can use: it specifies the index of the element within its selection. This is a zero-based index, and it’s useful for computing offsets or as a simple way of identifying individual elements. The argument is optional; if you don’t specify it when declaring your function, it will be ignored. For example:
circle.attr("cx", function(d, i) { return i * 100 + 30; });
Here we use the index i to position the elements sequentially only the x-dimension. Each element is separated by 100 pixels, with an offset of 30 pixels from the left side. In SVG, the origin is in the top-left corner.