Last active
July 4, 2017 15:26
-
-
Save curran/ea3bdf88768570280fe20b10134588a7 to your computer and use it in GitHub Desktop.
[unlisted] Logo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
country | population | |
---|---|---|
China | 1376048943 | |
India | 1311050527 | |
USA | 321773631 | |
Indonesia | 257563815 | |
Brazil | 207847528 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Rendering Rectangles</title> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
</head> | |
<body> | |
<svg width="960" height="500"></svg> | |
<script> | |
const svg = d3.select("svg"); | |
function render(data){ | |
svg.selectAll("rect").data(data) | |
.enter().append("rect") | |
.attr("x", (d, i) => i * 30) | |
.attr("y", (d, i) => i * 30) | |
.attr("width", (d, i) => i * 30) | |
.attr("height", (d, i) => i * 30) | |
} | |
function type(d){ | |
d.population = +d.population; | |
return d; | |
} | |
d3.csv("data.csv", type, render); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment