Created
October 26, 2017 13:19
-
-
Save 197291/c1bad8d88b4d69011c9278c4ddea3463 to your computer and use it in GitHub Desktop.
Example_D3_part2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.prototype.calculateCoords = function (rowNumber, currentShape) { | |
var max_y = 20; | |
d3.selectAll('g.group').each(function (d) { | |
var coords = d3.transform(d3.select(this).attr("transform")); | |
var grpX = coords.translate[0]; | |
var grpY = coords.translate[1]; | |
if (grpY > max_y) { | |
max_y = grpY; | |
} | |
}); | |
var y; | |
if (rowNumber == 0 ) { | |
y = max_y + currentShape.h + 20; | |
y = currentShape.type == 'rect' ? y : y + 20; | |
} else { | |
y = max_y + currentShape.h; | |
} | |
var x = currentShape.type == 'rect' ? 20 : 40; | |
return { x: x, y: y}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment