Skip to content

Instantly share code, notes, and snippets.

@kkabetani
Created March 13, 2015 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkabetani/1b98cffae2414bcb9f37 to your computer and use it in GitHub Desktop.
Save kkabetani/1b98cffae2414bcb9f37 to your computer and use it in GitHub Desktop.
d3.js training(update、enter、exit) By using dotinstall
<!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