lib/society/formatter/report/templates/components/society-assets/society.js in society-1.0.0 vs lib/society/formatter/report/templates/components/society-assets/society.js in society-1.1.0
- old
+ new
@@ -233,13 +233,26 @@
this.width = 800;
this.height = 800;
};
Heatmap.prototype.transformData = function(data) {
+ var _findCluster = function(nodeIndex) {
+ var clusterId = null, i;
+ for (i = 0; i < data.clusters.length; i++) {
+ if (data.clusters[i].indexOf(nodeIndex) != -1) {
+ clusterId = i;
+ break;
+ }
+ }
+ return clusterId;
+ };
+
+ var findCluster = data.clusters ? _findCluster : function() { return 0; };
+
return {
- nodes: data.nodes.map(function(node) {
- return { name: node.name, group: 1 };
+ nodes: data.nodes.map(function(node, index) {
+ return { name: node.name, group: findCluster(index) };
}),
links: data.edges.map(function(edge) {
return { source: edge.from, target: edge.to, value: 1 };
})
};
@@ -262,11 +275,10 @@
var coOccurrenceSvg = this.element.append("svg")
.attr("width", this.width + this.margin.left + this.margin.right)
.attr("class", "society-graph")
.attr("height", this.height + this.margin.top + this.margin.bottom)
- .style("margin-left", -this.margin.left + "px")
.append("g")
.attr("transform", "translate(" + this.margin.left + "," + this.margin.top + ")");
var matrix = [],
nodes = this.data.nodes,
@@ -310,10 +322,11 @@
.attr("class", "society-row")
.attr("transform", function(d, i) { return "translate(0," + x(i) + ")"; })
.each(row);
row.append("line")
+ .attr("class", "society-cell-outline")
.attr("x2", this.width);
row.append("text")
.attr("x", -6)
.attr("y", x.rangeBand() / 2)
@@ -326,10 +339,11 @@
.enter().append("g")
.attr("class", "society-column")
.attr("transform", function(d, i) { return "translate(" + x(i) + ")rotate(-90)"; });
column.append("line")
+ .attr("class", "society-cell-outline")
.attr("x1", -this.width);
column.append("text")
.attr("x", 6)
.attr("y", x.rangeBand() / 2)
@@ -361,20 +375,20 @@
}
function order(value) {
x.domain(orders[value]);
- var t = coOccurrenceSvg.transition().duration(2500);
+ var t = coOccurrenceSvg.transition().duration(1000);
t.selectAll(".society-row")
- .delay(function(d, i) { return x(i) * 4; })
+ .delay(function(d, i) { return x(i) * 0.4; })
.attr("transform", function(d, i) { return "translate(0," + x(i) + ")"; })
.selectAll(".society-cell")
- .delay(function(d) { return x(d.x) * 4; })
+ .delay(function(d) { return x(d.x) * 0.4; })
.attr("x", function(d) { return x(d.x); });
t.selectAll(".society-column")
- .delay(function(d, i) { return x(i) * 4; })
+ .delay(function(d, i) { return x(i) * 0.4; })
.attr("transform", function(d, i) { return "translate(" + x(i) + ")rotate(-90)"; });
}
};