I'm currently working on a project that involves printing a specific number of rectangles per line using d3.js
var rectangle = svgContainer.selectAll("rect").data(data).enter().append("rect")
.attr("x", function(d,i){ return i*5})
.attr("y", function(d,i){ return i+1})
.attr("width", 50)
.attr("height", 50)
While I understand that I need to adjust the y attribute, I find myself guessing the values until the rectangles align as I envision them, like
[][][][][][]
[][][][][][]
[][][][][][]
instead of
[[][[][[[][[][[][[]
or
[]
[]
[]
[]
Could someone provide guidance on how to create a formula to achieve the desired layout?
Thank you in advance