### Example00
Built with blockbuilder.org
### Example00
Built with blockbuilder.org
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Intro D3js examples</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
.existing {color: blue;} | |
.new {color: green;} | |
</style> | |
</head> | |
<body> | |
<h1>Intro D3 - example00</h1> | |
<!--<p> previous paragraph</p>--> | |
<script type="text/javascript"> | |
test = [1,2,3]; | |
// We make a DOM selection using D3 and link data to it | |
var p = d3.select("body").selectAll("p").data(test); | |
// Update subselection | |
p.attr("class",function(d,i) {return "existing";}); | |
// Enter subselection | |
p.enter() | |
.append("p") | |
.text(function(d,i) {return "The value is "+d;}) | |
.attr("class","new"); | |
// Exit subselection | |
p.exit().remove(); | |
</script> | |
</body> | |
</html> |