lib/society/formatter/report/templates/components/society-assets/society.js in society-1.3.0 vs lib/society/formatter/report/templates/components/society-assets/society.js in society-1.4.0
- old
+ new
@@ -19,10 +19,11 @@
this.innerRadius = this.radius - 260;
this.element = element;
this.data = this.transformData(data);
this.includeIsolatedNodes = true;
+ this.depsFiltered = false;
};
NetworkGraph.prototype.transformData = function(data) {
return(Object.keys(data).map(function(node) {
return {
@@ -128,18 +129,51 @@
.classed("society-node--faded", false)
.classed("society-node--target", false)
.classed("society-node--source", false);
};
+ var toggleFilterOnlyDeps = function(d) {
+ if (this.depsFiltered == false) {
+ nodeAnchor.selectAll(".society-node--faded")
+ .style("visibility", "hidden");
+ linkAnchor.selectAll(".society-link")
+ .filter(":not(.society-link--source)")
+ .filter(":not(.society-link--target)")
+ .style("visibility", "hidden");
+ this.depsFiltered = true;
+ } else {
+ d3
+ .selectAll(".society-node")
+ .style("visibility", "visible");
+ d3
+ .selectAll(".society-link")
+ .style("visibility", "visible");
+ this.depsFiltered = false;
+ }
+ };
+
+ document.onkeydown = function(evt) {
+ evt = evt || window.event;
+ if (evt.keyCode == 27) {
+ d3
+ .selectAll(".society-node")
+ .style("visibility", "visible");
+ d3
+ .selectAll(".society-link")
+ .style("visibility", "visible");
+ }
+ };
+
var newNodes = node.enter().append("text")
.attr("opacity", 0)
.attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + (d.y + 64) + ",0)" + (d.x < 180 ? "" : "rotate(180)"); })
.style("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
.attr("class", "society-node")
.attr("dy", ".31em")
.text(function(d) { return d.key; })
.on("mouseover", mouseovered)
- .on("mouseout", mouseouted);
+ .on("mouseout", mouseouted)
+ .on("click", toggleFilterOnlyDeps);
link.enter().append("path")
.attr("opacity", 0)
.attr("class", "society-link");
link.transition().duration(1000)