waitAndEval
with loopA simple mechanism for step by step illustrations.
See waitAndEval.
See also playButton.
xxxxxxxxxx
<meta charset="utf-8">
<title>waitAndEval II</title>
<style>
#messageText{
font-size: 60px;
text-anchor: middle;
}
</style>
<body>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
// ----------------------------------------------------------------------
var width = 960,
height = 500;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var messageText = svg.append("text")
.attr("id", "messageText")
.attr("x", width/2)
.attr("y", height/2);
var waitAndEval = newWaitAndEval();
d3.range(100).forEach(function(i) {
waitAndEval(function() { write(i); }, 1000);
})
function write (text) { messageText.attr("class", text).text(text) }
function newWaitAndEval () {
var t = 0;
return function (foo, dur) {
t += dur
setTimeout(foo, t)
};
}
</script>
Modified http://d3js.org/d3.v3.min.js to a secure url
https://d3js.org/d3.v3.min.js