Skip to content

Instantly share code, notes, and snippets.

@madams1
Last active January 30, 2019 16:45
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 madams1/3d48f26e9bbd6fff7bb81e7e34010a5e to your computer and use it in GitHub Desktop.
Save madams1/3d48f26e9bbd6fff7bb81e7e34010a5e to your computer and use it in GitHub Desktop.
.enter()
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
<div class="chart"></div>
<script>
const svg = d3.select(".chart")
.append("svg")
.attr("width", 100)
.attr("height", 600)
svg.selectAll("rect")
.data([10, 20, 30, 40])
.enter()
.append("rect")
.attr("width", d => d)
.attr("height", 40)
.attr("x", 25)
.attr("y", (d, i) => i * 50)
.attr("fill", "red")
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment