Built with blockbuilder.org
forked from sandravizmad's block: Basic scatter plot
license: mit |
Built with blockbuilder.org
forked from sandravizmad's block: Basic scatter plot
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>D3 Example</title> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
</head> | |
<style> | |
circle{fill: #40E0D0} | |
</style> | |
<body> | |
<script> | |
var svg = d3.select("body").append("svg") | |
.attr("width", 550) | |
.attr("height", 550); | |
function a_name (d){ | |
// Bind data | |
var circles = svg.selectAll("circle").data(d); | |
// Enter | |
circles.enter().append("circle") | |
.attr("r", 5); | |
// Update | |
circles | |
.attr("cx", function (d){ return d.x; }) | |
.attr("cy", function (d){ return d.y; }); | |
// Exit | |
circles.exit().remove(); | |
} | |
d3.csv("https://gist.githubusercontent.com/rramvil/c83a0cca33de20dae8a8a55a4230793a/raw/91c3c6335eb2c01dc561d32765133bb23935ee76/var%2520data", | |
function (d){a_name(d);}); | |
</script> | |
</body> | |
</html> |