Last active
July 31, 2019 22:38
-
-
Save macloo/bc950d2209e2c9025a6051b246f6c802 to your computer and use it in GitHub Desktop.
D3 lesson from FCC No. 10: Learn About SVG in D3 and No. 11: Display Shapes with SVG
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
<style> | |
svg { | |
background-color: pink; | |
} | |
</style> | |
<body> | |
<script> | |
const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9]; | |
const w = 500; | |
const h = 100; | |
const svg = d3.select("body") | |
// Add your code below this line | |
.append("svg") | |
.attr("width", w) | |
.attr("height", h); | |
// Add your code above this line | |
</script> | |
</body> |
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
// add a rectangle to the SVG - rect has 4 attributes, w, h, x, y | |
const w = 500; | |
const h = 100; | |
const svg = d3.select("body") | |
.append("svg") | |
.attr("width", w) | |
.attr("height", h) | |
// Add your code below this line | |
.append("rect") | |
.attr("width", 25) | |
.attr("height", 100) | |
.attr("x", 0) | |
.attr("y", 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment