Created
March 13, 2015 15:39
-
-
Save kkabetani/1b98cffae2414bcb9f37 to your computer and use it in GitHub Desktop.
d3.js training(update、enter、exit) By using dotinstall
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 charset="utf-8"> | |
<title>D3.js の練習</title> | |
</head> | |
<body> | |
<p>Hello 1</p> | |
<p>Hello 2</p> | |
<p>Hello 3</p> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<script> | |
//var dataset = [12, 24, 36, 48]; | |
var dataset = [12, 24]; | |
var p = d3.select("body").selectAll("p"); | |
var update = p.data(dataset); | |
var exit = update.exit(); | |
update.text(function(d) { | |
return "update: " + d; | |
}); | |
//exit.style("color", "red").remove(); | |
/* | |
var enter = update.enter(); | |
update.text(function(d) { | |
return "update: " + d; | |
}); | |
enter.append("p").text(function(d){ | |
return "enter: " + d; | |
}); | |
*/ | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment