score:1

Accepted answer

Suggested reading:

https://github.com/raganwald-deprecated/homoiconic/blob/master/2012/01/captain-obvious-on-javascript.md

And also:

http://www.wirfs-brock.com/allen/posts/166

FYI, You just have to check the parameters passed to x remember that doing .attr('width', x) will call x with the datum itself AND the index, if x doesn't do anything with the index then you're good to go :)

score:-1

x is a function that expect an argument an return an scaled result. D3 sends the data item as argument and this is the magic.

score:0

In this example x is a function which is simply passed by reference. By using .attr("width", function(d){return x(d);}) you are just wrapping x into another function, which doesn't add anything to your program.


Related Query