I'd recommend that you take a look at some of the d3 tutorials to gain a better understanding of what's going on. Concerning your specific questions, see below.
- It never loops, it works by binding data to (potentially non-existant) elements and operating on selections (i.e. subsets) of changed, new and deleted elements. See this tutorial for example.
- The
d3.scale.*
methods make graph scales. That is, they map input values to output values (the coordinates within your graph).d3.scale.linear()
creates a linear scale, as the name suggests. - You can format the data any way you want really. Again, have a look at the tutorials for examples.
- See 1.