mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Init d3 donut function
This commit is contained in:
parent
d18dded93a
commit
d35b420c36
@ -31,6 +31,7 @@ require_once ($config['homedir'].'/include/functions_agents.php');
|
|||||||
require_once ($config['homedir'].'/include/functions_modules.php');
|
require_once ($config['homedir'].'/include/functions_modules.php');
|
||||||
require_once ($config['homedir'].'/include/functions_users.php');
|
require_once ($config['homedir'].'/include/functions_users.php');
|
||||||
require_once ($config['homedir'].'/include/functions.php');
|
require_once ($config['homedir'].'/include/functions.php');
|
||||||
|
require_once ($config['homedir'].'/include/graphs/functions_d3.php');
|
||||||
|
|
||||||
function visual_map_print_item_toolbox($idDiv, $text, $float) {
|
function visual_map_print_item_toolbox($idDiv, $text, $float) {
|
||||||
if ($float == 'left') {
|
if ($float == 'left') {
|
||||||
@ -1140,7 +1141,7 @@ function visual_map_print_item($mode = "read", $layoutData,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DONUT_GRAPH:
|
case DONUT_GRAPH:
|
||||||
$donut_data = get_donut_module_data($layoutData['id_agent'], $layoutData['id_agente_modulo']);
|
$donut_data = get_donut_module_data($layoutData['id_agente_modulo']);
|
||||||
|
|
||||||
if ((get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap')) {
|
if ((get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap')) {
|
||||||
if($width == 0 || $height == 0){
|
if($width == 0 || $height == 0){
|
||||||
@ -1168,7 +1169,7 @@ function visual_map_print_item($mode = "read", $layoutData,
|
|||||||
$img = d3_donut_graph ($layoutData['id'], $width, $height, $donut_data);
|
$img = d3_donut_graph ($layoutData['id'], $width, $height, $donut_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Restore db connection
|
//Restore db connection
|
||||||
if ($layoutData['id_metaconsole'] != 0) {
|
if ($layoutData['id_metaconsole'] != 0) {
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
@ -1632,6 +1633,7 @@ function visual_map_print_item($mode = "read", $layoutData,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DONUT_GRAPH:
|
case DONUT_GRAPH:
|
||||||
|
html_debug($img, true);
|
||||||
echo $img;
|
echo $img;
|
||||||
break;
|
break;
|
||||||
case SIMPLE_VALUE:
|
case SIMPLE_VALUE:
|
||||||
@ -1785,8 +1787,23 @@ function visual_map_print_item($mode = "read", $layoutData,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_donut_module_data ($id_agent, $id_module) {
|
function get_donut_module_data ($id_module) {
|
||||||
|
$mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module));
|
||||||
|
|
||||||
|
$values = explode(";", $mod_values);
|
||||||
|
|
||||||
|
$values_to_return = array();
|
||||||
|
$index = 0;
|
||||||
|
$total = 0;
|
||||||
|
foreach ($values as $val) {
|
||||||
|
$data = explode(":", $val);
|
||||||
|
$values_to_return[$index]['tag'] = $data[0];
|
||||||
|
$values_to_return[$index]['value'] = $data[1];
|
||||||
|
$index++;
|
||||||
|
}
|
||||||
|
$values_to_return['total'] = count($values_to_return);
|
||||||
|
|
||||||
|
return $values_to_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,9 +331,6 @@ function d3_donut_graph ($id, $width, $height, $module_data) {
|
|||||||
print_donut_graph('" . $recipient_name_to_js . "', " . $width . ", " . $height . ", " . $module_data . ");
|
print_donut_graph('" . $recipient_name_to_js . "', " . $width . ", " . $height . ", " . $module_data . ");
|
||||||
</script>";
|
</script>";
|
||||||
|
|
||||||
if (!$return)
|
|
||||||
echo $output;
|
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1495,6 +1495,8 @@ function print_phases_donut (recipient, phases) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function print_donut_graph (recipient, width, height, module_data) {
|
function print_donut_graph (recipient, width, height, module_data) {
|
||||||
|
console.log(module_data);
|
||||||
|
|
||||||
var svg = d3.select(recipient)
|
var svg = d3.select(recipient)
|
||||||
.append("svg")
|
.append("svg")
|
||||||
.attr("width", width)
|
.attr("width", width)
|
||||||
@ -1511,7 +1513,6 @@ function print_donut_graph (recipient, width, height, module_data) {
|
|||||||
|
|
||||||
svg.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
|
svg.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
|
||||||
|
|
||||||
/* ------- PIE SLICES -------*/
|
|
||||||
var slice = svg.select(".slices").selectAll("path.slice")
|
var slice = svg.select(".slices").selectAll("path.slice")
|
||||||
.data(module_data);
|
.data(module_data);
|
||||||
|
|
||||||
@ -1539,4 +1540,5 @@ function print_donut_graph (recipient, width, height, module_data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
slice.exit().remove();
|
slice.exit().remove();
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user