http://bl.ocks.org/mbostock/1134768
Hey guys, I'm pretty new to JavaScript, and basically study it to use d3 to render data. I am trying to understand what is happening in the code above, in particular in the fragment:
// Add a rect for each date var rect = cause.selectAll("rect") .data(Object) // THIS IS WEIRD TO ME.... .enter().append("svg:rect") .attr("x", function(d) { return x(dx); }) .attr("y", function(d) { return -y(d.y0) - y(dy); }) .attr("height", function(d) { return y(dy); }) .attr("width", x.rangeBand());
What does the constructor of an object do in .data() ? I think that data() will force the function to be evaluated, so is the object actually being created? Why insert a rectangle for each element of each array into causes ?
source share