xxxxxxxxxx
<meta charset="utf-8">
<style>
body {
font-family: Helvetica, sans-serif;
}
svg {
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
.filter-btn.active {
font-weight: bold;
}
</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="d3-grid.js"></script>
<script>
var width = 960,
height = 960
TAU = Math.PI * 2;
var grid = d3.layout.grid()
.size([width, height]);
var color = d3.scale.linear()
.interpolate(d3.interpolateHcl)
.domain([0, 100])
.range(["#F66A96", "#3E6E9C"]);
var data = d3.range(5000).map(function(d) {
return {
id: d,
size: 1 + Math.floor(Math.random() * 5),
r: Math.random() * 50,
color: Math.floor(Math.random() * 100),
f: (Math.random() > 0.5 ? -1 : 1) * (Math.random() * 10000 + 1000)
};
});
var nodes = grid(data);
var scale = window.devicePixelRatio || 1;
var canvas = d3.select("body").append("canvas")
.attr({
width: width * scale,
height: height * scale
})
.style({
width: width + 'px',
height: height + 'px'
});
var context = canvas.node().getContext('2d');
context.scale(scale, scale);
function update(t) {
var i, d, alpha;
context.clearRect(0, 0, width, height);
for (i = 0; i < nodes.length; ++i) {
d = nodes[i];
alpha = TAU / d.f * (t % d.f);
context.beginPath();
context.arc(d.x + Math.cos(alpha) * d.r, d.y + Math.sin(alpha) * d.r, d.size, 0, TAU);
context.fillStyle = color(d.color);
context.fill();
}
}
d3.timer(update);
d3.select(self.frameElement).style("height", height + "px");
</script>
Modified http://d3js.org/d3.v3.min.js to a secure url
https://d3js.org/d3.v3.min.js