The VisDock toolkit has been integrated into this Rotating Voronoi example built with D3.js (found here) by Mike Bostock. Selection tools can be used to query path elements in the diagram. Annotations, Pan & Zoom tools and VisDock lenses can be used for exploration of the rotating elements. For more information about VisDock, cick on the link.
xxxxxxxxxx
<meta charset="utf-8">
<style>
body {
background: #000;
}
path {
fill: #fff;
stroke: #000;
stroke-width: 1.5px;
}
</style>
<body>
<link href="https://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.css" rel="stylesheet" type="text/css"/>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/visdock.js"></script>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/2d.js"></script>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/intersectionutilities.js"></script>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/visdock.utils.js"></script>
<script>
var width = 960,
height = 500;
VisDock.init('body', {width: 960, height: 700});
AnnotatedByData.layerTypes = ["path"];
var viewport = VisDock.getViewport();
var points = [];
var bounds = d3.geom.polygon([
[-width / 2, -height / 2],
[-width / 2, +height / 2],
[+width / 2, +height / 2],
[+width / 2, -height / 2]
]);
circle(0, 0, 120, 96, -.001);
circle(0, 0, 30, 10, .03);
circle(0, 0, 60, 3, -.05);
circle(0, 0, 15, 4, -.02);
circle(0, 0, 0, 1, -.02);
circle(240, -120, 80, 4, -.02);
circle(240, -120, 0, 1, -.02);
circle(280, +120, 40, 8, .02);
circle(280, +120, 20, 8, -.02);
circle(280, +120, 0, 1, .02);
var line = d3.svg.line()
.interpolate("basis-closed");
var svg = viewport;
Panel.x = width / 2;
Panel.y = height / 2;
Panel.setTransform();
var id = 0;
var path = svg.selectAll("path")
.data(points)
.enter().append("path")
.attr("id", function(){
return "v" + id++;
});
d3.timer(function() {
VisDock.startChrome();
var voronoi = d3.geom.voronoi(points).map(function(cell) { return bounds.clip(cell); });
path.attr("d", function(point, i) { return line(resample(voronoi[i])); });
VisDock.updateLayers();
AnnotatedByData.update();
VisDock.finishChrome();
});
function circle(cx, cy, r, n, δθ) {
d3.range(1e-6, 2 * Math.PI, 2 * Math.PI / n).map(function(θ) {
var point = [cx + Math.cos(θ) * r, cy + Math.sin(θ) * r];
d3.timer(function() {
θ += δθ;
point[0] = cx + Math.cos(θ) * r;
point[1] = cy + Math.sin(θ) * r;
});
points.push(point);
return point;
});
}
function resample(points) {
var i = -1,
n = points.length,
p0 = points[n - 1], x0 = p0[0], y0 = p0[1], p1, x1, y1,
points2 = [];
while (++i < n) {
p1 = points[i], x1 = p1[0], y1 = p1[1];
points2.push(
[(x0 * 2 + x1) / 3, (y0 * 2 + y1) / 3],
[(x0 + x1 * 2) / 3, (y0 + y1 * 2) / 3],
p1
);
p0 = p1, x0 = x1, y0 = y1;
}
return points2;
}
VisDock.eventHandler = {
getHitsPolygon : function(points, inclusive) {
var shapebound = new createPolygon(points);
return shapebound.intersectPath(d3.selectAll("path")[0], inclusive)
},
getHitsLine : function(points, inclusive) {
var shapebound = new createLine(points);
return shapebound.intersectPath(d3.selectAll("path")[0], inclusive)
},
getHitsEllipse : function(points, inclusive) {
var shapebound = new createEllipse(points);
return shapebound.intersectPath(d3.selectAll("path")[0], inclusive)
},
setColor : function(hits) {
for (var i = 0; i < hits.length; i++) {
VisDock.utils.addPathLayer(hits[i], undefined, num - 1)
}
},
changeColor : function(color, query, index) {
for (var i = 0; i < query.length; i++) {
var vis = query[i].attr("style").split("opacity: ")[1].split(";")[0]
query[i][0][0].setAttributeNS(null, "style", "fill: " + color + "; stroke: black; opacity: " + vis)
}
},
changeVisibility : function(vis, query, index) {
for (var i = 0; i < query.length; i++) {
var color = query[i].attr("style").split(";")[0]
query[i][0][0].setAttributeNS(null, "style", color + "; opacity: " + vis)
}
},
removeColor : function(hits, index) {
for (var i = 0; i < hits.length; i++) {
hits[i].remove();
}
},
QueryClick : function(query, index) {
}
}
BirdView.init(viewport, 960, 700)
d3.select(self.frameElement).style("width", "960px");
d3.select(self.frameElement).style("height", "700px");
</script>
Modified http://d3js.org/d3.v3.min.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/2D.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/IntersectionUtilities.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.utils.js to a secure url
https://d3js.org/d3.v3.min.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/2D.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/IntersectionUtilities.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.utils.js