Skip to content

Instantly share code, notes, and snippets.

@d3indepth
Last active August 2, 2017 10:22
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 d3indepth/cd21d0522fc6f48e3fb88c7f770eb008 to your computer and use it in GitHub Desktop.
Save d3indepth/cd21d0522fc6f48e3fb88c7f770eb008 to your computer and use it in GitHub Desktop.
Selection remove
license: gpl-3.0
height: 170
border: no
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>selection.remove</title>
</head>
<style>
circle {
fill: orange;
}
</style>
<body>
<svg width="760" height="140">
<g transform="translate(70, 70)">
<circle r="40" />
<circle r="40" cx="120" />
<circle r="40" cx="240" />
<circle r="40" cx="360" />
<circle r="40" cx="480" />
</g>
</svg>
<div>
<button onClick="removeCircles();">Remove circles</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script>
<script>
function removeCircles() {
d3.selectAll('circle')
.remove();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment