Skip to content

Instantly share code, notes, and snippets.

@197291
Created October 26, 2017 13:19
Show Gist options
  • Save 197291/c1bad8d88b4d69011c9278c4ddea3463 to your computer and use it in GitHub Desktop.
Save 197291/c1bad8d88b4d69011c9278c4ddea3463 to your computer and use it in GitHub Desktop.
Example_D3_part2
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