2014-08-21 Alejandro Gallardo <alejandro.gallardo@artica.es>

* include/functions_graph.php: Improved the function
	"graph_monitor_wheel" to remove the html encoding.
	
	* include/graphs/pandora.d3.js: Mayor improvements
	on the function "solarburst".


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10440 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
alexhigh 2014-08-21 10:15:12 +00:00
parent 9fcc2c76a5
commit 34ea647346
3 changed files with 80 additions and 15 deletions

View File

@ -1,3 +1,11 @@
2014-08-21 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/functions_graph.php: Improved the function
"graph_monitor_wheel" to remove the html encoding.
* include/graphs/pandora.d3.js: Mayor improvements
on the function "solarburst".
2014-08-21 Junichi Satoh <junichi@rworks.jp> 2014-08-21 Junichi Satoh <junichi@rworks.jp>
* include/functions_api.php: Added a function to add an event comment. * include/functions_api.php: Added a function to add an event comment.

View File

@ -4135,20 +4135,21 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
$module_id = (int) $module['id_agente_modulo']; $module_id = (int) $module['id_agente_modulo'];
$agent_id = (int) $module['id_agente']; $agent_id = (int) $module['id_agente'];
$module_group_id = (int) $module['id_module_group']; $module_group_id = (int) $module['id_module_group'];
$module_name = $module['nombre']; $module_name = io_safe_output($module['nombre']);
$module_status = modules_get_agentmodule_status($module_id); $module_status = modules_get_agentmodule_status($module_id);
$module_value = modules_get_last_value($module_id);
if (!isset($data_agents[$agent_id])) { if (!isset($data_agents[$agent_id])) {
$data_agents[$agent_id] = array(); $data_agents[$agent_id] = array();
$data_agents[$agent_id]['id'] = $agent_id; $data_agents[$agent_id]['id'] = $agent_id;
$data_agents[$agent_id]['name'] = $agents[$agent_id]['nombre']; $data_agents[$agent_id]['name'] = io_safe_output($agents[$agent_id]['nombre']);
$data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo']; $data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo'];
$data_agents[$agent_id]['type'] = 'agent'; $data_agents[$agent_id]['type'] = 'agent';
$data_agents[$agent_id]['size'] = 30; $data_agents[$agent_id]['size'] = 30;
$data_agents[$agent_id]['children'] = array(); $data_agents[$agent_id]['children'] = array();
$tooltip_content = __('Agent') . ": <b>" . $data_agents[$agent_id]['name'] . "</b>"; $tooltip_content = __('Agent') . ": <b>" . $data_agents[$agent_id]['name'] . "</b>";
$data_agents[$agent_id]['tooltip_content'] = $tooltip_content; $data_agents[$agent_id]['tooltip_content'] = io_safe_output($tooltip_content);
$data_agents[$agent_id]['modules_critical'] = 0; $data_agents[$agent_id]['modules_critical'] = 0;
$data_agents[$agent_id]['modules_warning'] = 0; $data_agents[$agent_id]['modules_warning'] = 0;
@ -4164,12 +4165,12 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
if (!isset($data_agents[$agent_id]['children'][$module_group_id])) { if (!isset($data_agents[$agent_id]['children'][$module_group_id])) {
$data_agents[$agent_id]['children'][$module_group_id] = array(); $data_agents[$agent_id]['children'][$module_group_id] = array();
$data_agents[$agent_id]['children'][$module_group_id]['id'] = $module_group_id; $data_agents[$agent_id]['children'][$module_group_id]['id'] = $module_group_id;
$data_agents[$agent_id]['children'][$module_group_id]['name'] = $module_groups[$module_group_id]; $data_agents[$agent_id]['children'][$module_group_id]['name'] = io_safe_output($module_groups[$module_group_id]);
$data_agents[$agent_id]['children'][$module_group_id]['type'] = 'module_group'; $data_agents[$agent_id]['children'][$module_group_id]['type'] = 'module_group';
$data_agents[$agent_id]['children'][$module_group_id]['size'] = 10; $data_agents[$agent_id]['children'][$module_group_id]['size'] = 10;
$data_agents[$agent_id]['children'][$module_group_id]['children'] = array(); $data_agents[$agent_id]['children'][$module_group_id]['children'] = array();
$tooltip_content = __('Module group') . ": <b>" . $module_groups[$module_group_id] . "</b>"; $tooltip_content = __('Module group') . ": <b>" . $data_agents[$agent_id]['children'][$module_group_id]['name'] . "</b>";
$data_agents[$agent_id]['children'][$module_group_id]['tooltip_content'] = $tooltip_content; $data_agents[$agent_id]['children'][$module_group_id]['tooltip_content'] = $tooltip_content;
$data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] = 0; $data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] = 0;
@ -4261,8 +4262,13 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
$data_module['name'] = $module_name; $data_module['name'] = $module_name;
$data_module['type'] = 'module'; $data_module['type'] = 'module';
$data_module['size'] = 10; $data_module['size'] = 10;
$data_module['link'] = ui_get_full_url("index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$agent_id");
$tooltip_content = __('Module') . ": <b>" . $module_name . "</b>"; $tooltip_content = __('Module') . ": <b>" . $module_name . "</b>";
if (isset($module_value) && $module_value !== false) {
$tooltip_content .= "<br>";
$tooltip_content .= __('Value') . ": <b>" . io_safe_output($module_value) . "</b>";
}
$data_module['tooltip_content'] = $tooltip_content; $data_module['tooltip_content'] = $tooltip_content;
switch ($module_status) { switch ($module_status) {
@ -4309,7 +4315,7 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
if (!isset($data_agents[$id])) { if (!isset($data_agents[$id])) {
$data_agents[$id] = array(); $data_agents[$id] = array();
$data_agents[$id]['id'] = (int) $id; $data_agents[$id]['id'] = (int) $id;
$data_agents[$id]['name'] = $agent['nombre']; $data_agents[$id]['name'] = io_safe_output($agent['nombre']);
$data_agents[$id]['type'] = 'agent'; $data_agents[$id]['type'] = 'agent';
$data_agents[$id]['color'] = COL_NOTINIT; $data_agents[$id]['color'] = COL_NOTINIT;
} }
@ -4326,7 +4332,8 @@ function graph_monitor_wheel ($width = 500, $height = 600) {
$group_aux = array(); $group_aux = array();
$group_aux['id'] = (int) $id; $group_aux['id'] = (int) $id;
$group_aux['name'] = $group['nombre']; $group_aux['name'] = io_safe_output($group['nombre']);
$group_aux['show_name'] = true;
$group_aux['parent'] = (int) $group['parent']; $group_aux['parent'] = (int) $group['parent'];
$group_aux['type'] = 'group'; $group_aux['type'] = 'group';
$group_aux['size'] = 100; $group_aux['size'] = 100;

View File

@ -698,9 +698,7 @@ function sunburst (recipient, data, width, height) {
var svg = d3.select(recipient).append("svg") var svg = d3.select(recipient).append("svg")
.attr("width", width) .attr("width", width)
.attr("height", height) .attr("height", height);
.append("g")
.attr("transform", "translate(" + width / 2 + "," + (height / 2 + 10) + ")");
var partition = d3.layout.partition() var partition = d3.layout.partition()
.value(function(d) { return d.size; }); .value(function(d) { return d.size; });
@ -711,20 +709,72 @@ function sunburst (recipient, data, width, height) {
.innerRadius(function(d) { return Math.max(0, y(d.y)); }) .innerRadius(function(d) { return Math.max(0, y(d.y)); })
.outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); }); .outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); });
var path = svg.selectAll("path") var g = svg.selectAll("g")
.data(partition.nodes(data)) .data(partition.nodes(data))
.enter().append("path") .enter().append("g")
.attr("transform", "translate(" + width / 2 + "," + (height / 2 + 10) + ")");
var path = g.append("path")
.attr("d", arc) .attr("d", arc)
.style("fill", function(d) { return d.color ? d3.rgb(d.color) : color((d.children ? d : d.parent).name); }) .style("fill", function(d) { return d.color ? d3.rgb(d.color) : color((d.children ? d : d.parent).name); })
.style("cursor", "pointer")
.on("click", click) .on("click", click)
.on("mouseover", over_user) .on("mouseover", over_user)
.on("mouseout", out_user) .on("mouseout", out_user)
.on("mousemove", move_tooltip); .on("mousemove", move_tooltip);
function computeTextRotation(d) {
var angle = x(d.x + d.dx / 2) - Math.PI / 2;
return angle / Math.PI * 180;
}
var text = g.append("text")
.attr("x", function(d) { return y(d.y); })
.attr("dx", "6") // margin
.attr("dy", ".35em") // vertical-align
.attr("opacity", function(d) {
if (typeof d.show_name != "undefined" && d.show_name)
return 1;
else
return 0;
})
.text(function(d) {
return d.name;
})
.attr("transform", function(d) { return "rotate(" + computeTextRotation(d) + ")"; })
.style("font-size", "10px")
// Makes svg elements invisible to events
.style("pointer-events", "none");
function click(d) { function click(d) {
path.transition() if (typeof d.link != "undefined") {
.duration(750) window.location.href = d.link;
.attrTween("d", arcTween(d)); }
else {
// fade out all text elements
text.transition().attr("opacity", 0);
path.transition()
.duration(750)
.attrTween("d", arcTween(d))
.each("end", function(e, i) {
// check if the animated element's data e lies within the visible angle span given in d
if ((typeof e.type != 'undefined'
&& (e.type == "group"
|| ( e.type == "agent" && (d.type == "group" || d.type == "agent" || d.type == "module_group" || d.type == "module") )
|| ( (e.type == "module_group" || e.type == "module") && (d.type == "agent" || d.type == "module_group") ) ))
&& e.x >= d.x && e.x < (d.x + d.dx)) {
// get a selection of the associated text element
var arcText = d3.select(this.parentNode).select("text");
// fade in the text element and recalculate positions
arcText
.attr("transform", function() { return "rotate(" + computeTextRotation(e) + ")" })
.attr("x", function(d) { return y(d.y); })
.transition().duration(250)
.attr("opacity", 1);
}
});
}
} }
d3.select(self.frameElement).style("height", height + "px"); d3.select(self.frameElement).style("height", height + "px");