Skip to content

Instantly share code, notes, and snippets.

@yanhann10
Last active January 3, 2020 03: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 yanhann10/aa162f7d187ddd250ff7b0daeac22043 to your computer and use it in GitHub Desktop.
Save yanhann10/aa162f7d187ddd250ff7b0daeac22043 to your computer and use it in GitHub Desktop.
fresh block
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
var svg = d3.select("body") // select the 'body' element
.append("svg") // append an SVG element to the body
.attr("width", 449) // make the SVG element 449 pixels wide
.attr("height", 249); // make the SVG element 249 pixels high
var shape=svg.selectAll('rects')
.data(d3.range(3)).enter()
.append("g")
shape.append("clipPath")
.attr('id', function(d) { return "clip" + d.index })
.append('circle')
.attr("cx", (d,i)=>175*i) // position the x-centre
.attr("cy", 100) // position the y-centre
.attr("rx", 50) // set the x radius
.attr("ry", 50);
shape.append("rect")
.attr("clip-path", function(d) { return "url(#clip" + d.index + ")"})
.attr("x",(d,i)=>175*i)
.attr("y",100)
.attr("fill","SteelBlue")
.attr("stroke","Black")
.attr("height",100)
.attr("width",100)
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment