Skip to content

Instantly share code, notes, and snippets.

@puzzler10
Last active March 27, 2017 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puzzler10/7c7150d41e9337bfaa70de0b0d917021 to your computer and use it in GitHub Desktop.
Save puzzler10/7c7150d41e9337bfaa70de0b0d917021 to your computer and use it in GitHub Desktop.
Transform example - translate
<!DOCTYPE html>
<meta charset="utf-8">
<style>
</style>
<svg width="500" height="500"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var radius = 20;
var point = {x: 50, y: 50 } ;
for(var i = 1; i <= 10; i++){
svg.append("circle")
.attr("cx", point.x)
.attr("cy", point.y)
.attr("r", radius)
.attr("fill", "blue")
.attr("transform", "translate(" + (i*30) + "," + (i*30) + ")");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment