2014-05-29 Miguel de Dios <miguel.dedios@artica.es>

* include/graphs/pandora.d3.js, include/graphs/functions_d3.php,
	operation/agentes/networkmap.dinamic.php: fixed the css for the
	m$-internet exploter 11. Please Bill Gates travels to Leon.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10040 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-05-29 15:50:21 +00:00
parent abdf2be6a4
commit 9b123de8a3
4 changed files with 221 additions and 202 deletions

View File

@ -1,3 +1,9 @@
2014-05-29 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/pandora.d3.js, include/graphs/functions_d3.php,
operation/agentes/networkmap.dinamic.php: fixed the css for the
m$-internet exploter 11. Please Bill Gates travels to Leon.
2014-05-29 Alejandro Gallardo <alejandro.gallardo@artica.es> 2014-05-29 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/functions_config.php: Fixed the permission * include/functions_config.php: Fixed the permission

View File

@ -60,7 +60,7 @@ function d3_tree_map_graph ($data, $width = 700, $height = 700, $return = false)
if (is_array($data)) if (is_array($data))
$data = json_encode($data); $data = json_encode($data);
$output = "<div id=\"tree_map\"></div>"; $output = "<div id=\"tree_map\" style='overflow: hidden;'></div>";
$output .= include_javascript_d3(true); $output .= include_javascript_d3(true);
$output .= "<style type=\"text/css\"> $output .= "<style type=\"text/css\">
.cell>rect { .cell>rect {

View File

@ -346,26 +346,37 @@ 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 d.id; return "p-" + d.name;
}); });
var parentEnterTransition = parentCells.enter() var parentEnterTransition = parentCells.enter()
.append("g") .append("g")
.attr("class", "cell parent") .attr("class", "cell parent")
.on("click", function(d) { .on("click", function(d) {
zoom(node === d ? root : d); zoom(d);
}); })
.append("svg")
.attr("class", "clip")
.attr("width", function(d) {
return Math.max(0.01, d.dx);
})
.attr("height", headerHeight);
parentEnterTransition.append("rect") parentEnterTransition.append("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", headerHeight) .attr("height", headerHeight)
.style("fill", headerColor); .style("fill", headerColor);
parentEnterTransition.append('foreignObject') parentEnterTransition.append('text')
.attr("class", "foreignObject") .attr("class", "label")
.append("xhtml:div") .attr("fill", "white")
.attr("class", "labelbody") .attr("transform", "translate(3, 13)")
.append("div") .attr("width", function(d) {
.attr("class", "label"); return Math.max(0.01, d.dx);
})
.attr("height", headerHeight)
.text(function(d) {
return d.name;
});
// update transition // update transition
var parentUpdateTransition = parentCells.transition().duration(transitionDuration); var parentUpdateTransition = parentCells.transition().duration(transitionDuration);
parentUpdateTransition.select(".cell") parentUpdateTransition.select(".cell")
@ -378,12 +389,12 @@ function treeMap(recipient, data, width, height) {
}) })
.attr("height", headerHeight) .attr("height", headerHeight)
.style("fill", headerColor); .style("fill", headerColor);
parentUpdateTransition.select(".foreignObject") parentUpdateTransition.select(".label")
.attr("transform", "translate(3, 13)")
.attr("width", function(d) { .attr("width", function(d) {
return Math.max(0.01, d.dx); return Math.max(0.01, d.dx);
}) })
.attr("height", headerHeight) .attr("height", headerHeight)
.select(".labelbody .label")
.text(function(d) { .text(function(d) {
return d.name; return d.name;
}); });
@ -394,47 +405,39 @@ 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 d.id; return "c-" + d.name;
}); });
// enter transition // enter transition
var childEnterTransition = childrenCells.enter() var childEnterTransition = childrenCells.enter()
.append("g") .append("g")
.attr("class", "cell child") .attr("class", "cell child")
.on("click", function(d) {
zoom(node === d.parent ? root : d.parent);
})
.on("mouseover", over_user) .on("mouseover", over_user)
.on("mouseout", out_user) .on("mouseout", out_user)
.on("mousemove", move_tooltip) .on("mousemove", move_tooltip)
.on("click", function(d) { .append("svg")
zoom(node === d.parent ? root : d.parent); .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.name); return color(d.parent.name);
}); });
childEnterTransition.append('foreignObject') childEnterTransition.append('text')
.attr("class", "foreignObject")
.attr("width", function(d) {
return Math.max(0.01, d.dx);
})
.attr("height", function(d) {
return Math.max(0.01, d.dy);
})
.append("xhtml:div")
.attr("class", "labelbody")
.append("div")
.attr("class", "label") .attr("class", "label")
.attr('x', function(d) {
return d.dx / 2;
})
.attr('y', function(d) {
return d.dy / 2;
})
.attr("dy", ".35em")
.attr("text-anchor", "middle")
.style("display", "none")
.text(function(d) { .text(function(d) {
return d.name; return d.name;
}); });
if (isIE) {
childEnterTransition.selectAll(".foreignObject .labelbody .label")
.style("display", "none");
} else {
childEnterTransition.selectAll(".foreignObject")
.style("display", "none");
}
// update transition // update transition
var childUpdateTransition = childrenCells.transition().duration(transitionDuration); var childUpdateTransition = childrenCells.transition().duration(transitionDuration);
childUpdateTransition.select(".cell") childUpdateTransition.select(".cell")
@ -447,23 +450,30 @@ function treeMap(recipient, data, width, height) {
}) })
.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(".foreignObject") childUpdateTransition.select(".label")
.attr("width", function(d) { .attr('x', function(d) {
return Math.max(0.01, d.dx); return d.dx / 2;
}) })
.attr("height", function(d) { .attr('y', function(d) {
return Math.max(0.01, d.dy); return d.dy / 2;
}) })
.select(".labelbody .label") .attr("dy", ".35em")
.attr("text-anchor", "middle")
.style("display", "none")
.text(function(d) { .text(function(d) {
return d.name; return d.name;
}); });
// exit transition // exit transition
childrenCells.exit() childrenCells.exit()
.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);
@ -503,9 +513,10 @@ 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]).nodes(d); .padding([headerHeight / (chartHeight / d.dy), 0, 0, 0])
.nodes(d);
// moving the next two lines above treemap layout messes up padding of zoom result // moving the next two lines above treemap layout messes up padding of zoom result
var kx = chartWidth / d.dx; var kx = chartWidth / d.dx;
@ -516,76 +527,78 @@ function treeMap(recipient, data, width, height) {
yscale.domain([d.y, d.y + d.dy]); yscale.domain([d.y, d.y + d.dy]);
if (node != level) { if (node != level) {
if (isIE) { chart.selectAll(".cell.child .label")
chart.selectAll(".cell.child .foreignObject .labelbody .label")
.style("display", "none"); .style("display", "none");
} else {
chart.selectAll(".cell.child .foreignObject")
.style("display", "none");
}
} }
var zoomTransition = chart.selectAll("g.cell").transition().duration(transitionDuration) var zoomTransition = chart.selectAll("g.cell").transition().duration(transitionDuration)
.attr("transform", function(d) { .attr("transform", function(d) {
return "translate(" + xscale(d.x) + "," + yscale(d.y) + ")"; return "translate(" + xscale(d.x) + "," + yscale(d.y) + ")";
}) })
.each("start", function() {
d3.select(this).select("label")
.style("display", "none");
})
.each("end", function(d, i) { .each("end", function(d, i) {
if (!i && (level !== self.root)) { if (!i && (level !== self.root)) {
chart.selectAll(".cell.child") chart.selectAll(".cell.child")
.filter(function(d) { .filter(function(d) {
return d.parent === self.node; // only get the children for selected group return d.parent === self.node; // only get the children for selected group
}) })
.select(".foreignObject .labelbody .label") .select(".label")
.style("color", function(d) { .style("display", "")
.style("fill", function(d) {
return idealTextColor(color(d.parent.name)); return idealTextColor(color(d.parent.name));
}); });
if (isIE) {
chart.selectAll(".cell.child")
.filter(function(d) {
return d.parent === self.node; // only get the children for selected group
})
.select(".foreignObject .labelbody .label")
.style("display", "")
} else {
chart.selectAll(".cell.child")
.filter(function(d) {
return d.parent === self.node; // only get the children for selected group
})
.select(".foreignObject")
.style("display", "")
}
} }
}); });
zoomTransition.select(".foreignObject") zoomTransition.select(".clip")
.attr("width", function(d) { .attr("width", function(d) {
return Math.max(0.01, kx * d.dx); return Math.max(0.01, (kx * d.dx));
}) })
.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));
});
zoomTransition.select(".label")
.attr("width", function(d) {
return Math.max(0.01, (kx * d.dx));
})
.attr("height", function(d) {
return d.children ? headerHeight : Math.max(0.01, (ky * d.dy));
}) })
.select(".labelbody .label")
.text(function(d) { .text(function(d) {
return d.name; return d.name;
}); });
// update the width/height of the rects zoomTransition.select(".child .label")
.attr("x", function(d) {
return kx * d.dx / 2;
})
.attr("y", function(d) {
return ky * d.dy / 2;
});
zoomTransition.select("rect") zoomTransition.select("rect")
.attr("width", function(d) { .attr("width", function(d) {
return Math.max(0.01, kx * d.dx); return Math.max(0.01, (kx * d.dx));
}) })
.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;
if (d3.event) { if (d3.event) {
d3.event.preventDefault(); d3.event.stopPropagation();
} }
} }
function position() { function position() {
this.style("left", function(d) { return d.x + "px"; }) this.style("left", function(d) { return d.x + "px"; })
.style("top", function(d) { return d.y + "px"; }) .style("top", function(d) { return d.y + "px"; })

View File

@ -54,7 +54,7 @@ $zoom_default = file($config['homedir'] . '/images/zoom_default.svg');
//html_debug_print($graph); //html_debug_print($graph);
echo '<script type="text/javascript" src="' . $config['homeurl'] . 'include/javascript/d3.v3.js" charset="utf-8"></script>'; echo '<script type="text/javascript" src="' . $config['homeurl'] . 'include/javascript/d3.v3.js" charset="utf-8"></script>';
echo '<div id="dinamic_networkmap"></div>'; echo '<div id="dinamic_networkmap" style="overflow: hidden;"></div>';
?> ?>
<style type="text/css"> <style type="text/css">
#tooltip_networkmap { #tooltip_networkmap {