2011-05-02 03:15:09 +04:00
|
|
|
<!DOCTYPE html>
|
2012-10-12 03:34:17 +04:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Hello, world!</title>
|
|
|
|
Your lucky numbers are:<br>
|
|
|
|
<span></span>
|
|
|
|
<script src="../../d3.js"></script>
|
|
|
|
<script>
|
2010-09-28 22:34:52 +04:00
|
|
|
|
|
|
|
var data = [4, 8, 15, 16, 23, 42];
|
|
|
|
|
2012-10-12 03:34:17 +04:00
|
|
|
d3.select("span").selectAll("svg")
|
2010-09-28 22:34:52 +04:00
|
|
|
.data(data)
|
2011-11-24 02:46:37 +04:00
|
|
|
.enter().append("svg")
|
2010-09-28 22:34:52 +04:00
|
|
|
.attr("width", 100)
|
|
|
|
.attr("height", 100)
|
2011-11-24 02:46:37 +04:00
|
|
|
.append("text")
|
2010-09-28 22:34:52 +04:00
|
|
|
.attr("x", "50%")
|
|
|
|
.attr("y", "50%")
|
|
|
|
.attr("dy", ".35em")
|
|
|
|
.attr("text-anchor", "middle")
|
|
|
|
.attr("fill", "white")
|
|
|
|
.attr("stroke", "black")
|
|
|
|
.attr("stroke-width", 1.5)
|
|
|
|
.attr("cursor", "pointer")
|
|
|
|
.style("font", "36pt Comic Sans MS")
|
|
|
|
.style("text-shadow", "3px 3px 3px rgba(0,0,0,.4)")
|
|
|
|
.text(function(d) { return d; })
|
2010-10-24 21:56:29 +04:00
|
|
|
.on("click", click)
|
|
|
|
.on("mouseover", mouseover)
|
|
|
|
.on("mouseout", mouseout);
|
|
|
|
|
|
|
|
function click(d, i) {
|
|
|
|
console.log("click", d, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
function mouseover(d, i) {
|
|
|
|
d3.select(this)
|
|
|
|
.attr("fill", "brown")
|
|
|
|
.attr("stroke", "grey");
|
|
|
|
}
|
|
|
|
|
|
|
|
function mouseout(d, i) {
|
|
|
|
d3.select(this)
|
|
|
|
.attr("fill", "orange");
|
|
|
|
}
|
2010-09-28 22:34:52 +04:00
|
|
|
|
2012-10-12 03:34:17 +04:00
|
|
|
</script>
|