Created
July 31, 2019 21:45
-
-
Save macloo/c380d25d3b6d63d6be019cf308172042 to your computer and use it in GitHub Desktop.
From FCC D3 lessons, No. 8: Update the Height of an Element Dynamically
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> | |
.bar { | |
width: 25px; | |
height: 100px; | |
display: inline-block; | |
background-color: blue; | |
/* extra style */ | |
margin-right: 5px; | |
} | |
</style> | |
<body> | |
<script> | |
const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9]; | |
d3.select("body").selectAll("div") | |
.data(dataset) | |
.enter() | |
.append("div") | |
.attr("class", "bar") | |
// Add your code below this line - the * 10 is extra | |
.style("height", (d) => d * 10); | |
// Add your code above this line | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment