Skip to content

Instantly share code, notes, and snippets.

@lnmunhoz
Last active February 21, 2019 06:08
Show Gist options
  • Save lnmunhoz/c147a595feae10c649439c5b2d8720e8 to your computer and use it in GitHub Desktop.
Save lnmunhoz/c147a595feae10c649439c5b2d8720e8 to your computer and use it in GitHub Desktop.
learning d3: connected circles
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>
<div id="chart-area"></div>
<script>
const svg = d3.select("#chart-area")
.append("svg")
.attr("width", 400)
.attr("height", 400)
.style("border", "1px solid black")
const line = svg.append("line")
.attr("x1", 60)
.attr("y1", 60)
.attr("x2", 340)
.attr("y2", 340)
.attr("stroke", "blue")
const circle1 = svg.append("circle")
.attr("cx", 60)
.attr("cy", 60)
.attr("r", 50)
.attr("fill", "red")
const circle2 = svg.append("circle")
.attr("cx", 340)
.attr("cy", 340)
.attr("r", 50)
.attr("fill", "green")
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment