From 54c6de6a41b1b4dd3409b9fa941a91c2d1092210 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Mon, 13 Jun 2016 09:00:11 +0200 Subject: [PATCH] Fixed Pie charts and legend. Tiquet: #3742 --- pandora_console/include/functions_graph.php | 2 +- pandora_console/include/graphs/fgraph.php | 25 ++++++++++--------- .../include/graphs/functions_pchart.php | 3 +-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 9c860c79d3..e643c9a7c6 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1816,7 +1816,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, case CUSTOM_GRAPH_PIE: return ring_graph($flash_charts, $graph_values, $width, $height, $others_str, $homeurl, $water_mark, $config['fontpath'], - ($config['font_size']+1), 1, false, $color, false); + ($config['font_size']+1), $ttl, false, $color, false); break; } } diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index ae6800aca9..fe37fb9058 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -741,36 +741,37 @@ function ring_graph($flash_chart, $chart_data, $width, $total_modules = $chart_data['total_modules']; unset($chart_data['total_modules']); - + $max_values = 9; //Remove the html_entities $n = 0; $temp = array(); $coloretes = array(); foreach ($chart_data as $key => $value) { - $temp[io_safe_output($key)] = $value['value']; - $legend[] = io_safe_output($key) .": " . $value['value'] . " " .$value['unit']; - //~ $coloretes[$n] = $colors[$n]['color']; - //~ $n++; + if ($n < $max_values) { + $temp[io_safe_output($key)] = $value['value']; + $legend[] = io_safe_output($key) .": " . $value['value'] . " " .$value['unit']; + } + $n++; } $chart_data = $temp; $chart_data_trunc = array(); $coloretes = array(); $n = 1; - foreach ($chart_data as $key => $value) { - if ($n < $max_values) { + //~ foreach ($chart_data as $key => $value) { + //~ if ($n < $max_values) { - $chart_data_trunc[$key] = $value; - } + //~ $chart_data_trunc[$key] = $value; + //~ } //~ else { //~ if (!isset($chart_data_trunc[$others_str])) { //~ $chart_data_trunc[$others_str] = 0; //~ } //~ $chart_data_trunc[$others_str] += $value; //~ } - $n++; - } - $chart_data = $chart_data_trunc; + //~ $n++; + //~ } + //~ $chart_data = $chart_data_trunc; //TODO SET THE LEGEND POSITION diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index 13e933bb0a..2da5491147 100644 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -62,7 +62,7 @@ $ttl = get_parameter('ttl', 1); $graph = unserialize_in_temp($id_graph, true, $ttl); -if (!isset($graph)) { +if (!$graph) { exit; } @@ -1111,7 +1111,6 @@ function pch_bullet_chart($graph_type, $data, $legend, /* Create and populate the pData object */ $MyData = new pData(); - html_debug($data,true); foreach ($data as $key => $dat) { $MyData->addPoints($dat, $key); }