2014-06-24 Alejandro Gallardo <alejandro.gallardo@artica.es>

* include/graphs/pandora.d3.js: Fixed some errors on
	the graph created by the function "treeMap".


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10279 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
alexhigh 2014-06-24 14:04:44 +00:00
parent a595a55b1b
commit e9d05381af
2 changed files with 218 additions and 212 deletions

View File

@ -1,3 +1,8 @@
2014-06-24 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/graphs/pandora.d3.js: Fixed some errors on
the graph created by the function "treeMap".
2014-06-24 Miguel de Dios <miguel.dedios@artica.es> 2014-06-24 Miguel de Dios <miguel.dedios@artica.es>
* godmode/setup/setup_visuals.php, include/functions_networkmap.php, * godmode/setup/setup_visuals.php, include/functions_networkmap.php,

View File

@ -346,7 +346,7 @@ function treeMap(recipient, data, width, height) {
// create parent cells // create parent cells
var parentCells = chart.selectAll("g.cell.parent") var parentCells = chart.selectAll("g.cell.parent")
.data(parents, function(d) { .data(parents, function(d) {
return "p-" + d.name; return d.id;
}); });
var parentEnterTransition = parentCells.enter() var parentEnterTransition = parentCells.enter()
.append("g") .append("g")
@ -405,8 +405,9 @@ function treeMap(recipient, data, width, height) {
// create children cells // create children cells
var childrenCells = chart.selectAll("g.cell.child") var childrenCells = chart.selectAll("g.cell.child")
.data(children, function(d) { .data(children, function(d) {
return "c-" + d.name; return d.id;
}); });
// enter transition // enter transition
var childEnterTransition = childrenCells.enter() var childEnterTransition = childrenCells.enter()
.append("g") .append("g")
@ -419,11 +420,13 @@ function treeMap(recipient, data, width, height) {
.on("mousemove", move_tooltip) .on("mousemove", move_tooltip)
.append("svg") .append("svg")
.attr("class", "clip"); .attr("class", "clip");
childEnterTransition.append("rect") childEnterTransition.append("rect")
.classed("background", true) .classed("background", true)
.style("fill", function(d) { .style("fill", function(d) {
return color(d.parent.name); return color(d.name);
}); });
childEnterTransition.append('text') childEnterTransition.append('text')
.attr("class", "label") .attr("class", "label")
.attr('x', function(d) { .attr('x', function(d) {
@ -438,22 +441,23 @@ function treeMap(recipient, data, width, height) {
.text(function(d) { .text(function(d) {
return d.name; return d.name;
}); });
// update transition // update transition
var childUpdateTransition = childrenCells.transition().duration(transitionDuration); var childUpdateTransition = childrenCells.transition().duration(transitionDuration);
childUpdateTransition.select(".cell") childUpdateTransition.select(".cell")
.attr("transform", function(d) { .attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")"; return "translate(" + d.x + "," + d.y + ")";
}); });
childUpdateTransition.select("rect") childUpdateTransition.select("rect")
.attr("width", function(d) { .attr("width", function(d) {
return Math.max(0.01, d.dx); return Math.max(0.01, d.dx);
}) })
.attr("height", function(d) { .attr("height", function(d) {
return d.dy; return d.dy;
})
.style("fill", function(d) {
return color(d.parent.name);
}); });
childUpdateTransition.select(".label") childUpdateTransition.select(".label")
.attr('x', function(d) { .attr('x', function(d) {
return d.dx / 2; return d.dx / 2;
@ -473,7 +477,6 @@ function treeMap(recipient, data, width, height) {
.remove(); .remove();
d3.select("select").on("change", function() { d3.select("select").on("change", function() {
console.log("select zoom(node)");
treemap.value(this.value == "size" ? size : count) treemap.value(this.value == "size" ? size : count)
.nodes(root); .nodes(root);
zoom(node); zoom(node);
@ -513,6 +516,7 @@ function treeMap(recipient, data, width, height) {
var bgDelta = (components.R * 0.299) + (components.G * 0.587) + (components.B * 0.114); var bgDelta = (components.R * 0.299) + (components.G * 0.587) + (components.B * 0.114);
return ((255 - bgDelta) < nThreshold) ? "#000000" : "#ffffff"; return ((255 - bgDelta) < nThreshold) ? "#000000" : "#ffffff";
} }
function zoom(d) { function zoom(d) {
treemap treemap
.padding([headerHeight / (chartHeight / d.dy), 0, 0, 0]) .padding([headerHeight / (chartHeight / d.dy), 0, 0, 0])
@ -547,7 +551,7 @@ function zoom(d) {
}) })
.select(".label") .select(".label")
.style("display", "") .style("display", "")
.style("fill", function(d) { .style("color", function(d) {
return idealTextColor(color(d.parent.name)); return idealTextColor(color(d.parent.name));
}); });
} }
@ -586,9 +590,6 @@ function zoom(d) {
}) })
.attr("height", function(d) { .attr("height", function(d) {
return d.children ? headerHeight : Math.max(0.01, (ky * d.dy)); return d.children ? headerHeight : Math.max(0.01, (ky * d.dy));
})
.style("fill", function(d) {
return d.children ? headerColor : color(d.parent.name);
}); });
node = d; node = d;