Last active
December 19, 2017 11:28
-
-
Save joao-parana/cfda303d8d2c22bdd35a016e785cb7b9 to your computer and use it in GitHub Desktop.
SOMA 02 - data binding
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> | |
<meta name="description" content="data-binding"> | |
</head> | |
<body> | |
<script src="https://d3js.org/d3.v4.min.js" charset=" utf-8"></script> | |
<script> | |
var selector = d3.select('body') | |
.selectAll('span') | |
.data([10, 20, 30, 40]); | |
selector.enter() | |
.append('div') | |
.text(function(d) { return 2 * d; }); | |
</script> | |
</body> | |
</html> |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="description" content="SOMA 02 - data binding"> | |
<title>SOMA 02 - data binding</title> | |
</head> | |
<body> | |
<!-- div id="page"> | |
<div id="div1">A</div> | |
<div id="div2">B</div> | |
<div id="div3">C</div> | |
<div id="div4">D</div> | |
</div --> | |
<script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script> | |
<script> | |
var selector = d3.select("body"); | |
console.log(selector) | |
// selector = selector.selectAll('div') | |
// console.log(selector) | |
selector = selector.data([10, 20, 30, 40]); | |
console.log(selector) | |
var entering = selector.enter(); | |
entering.append('div').text(function(d) { return d; }); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment