From c0661fc1b7304507e99d9d23907e2941404af68f Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 13 Jul 2020 10:02:56 +0200 Subject: [PATCH] fixed legend max 10 modules for chart --- .../reporting/graph_builder.graph_editor.php | 16 +++++++- pandora_console/include/functions_graph.php | 40 ++++++------------- .../include/graphs/flot/pandora.flot.js | 6 +-- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index d69729eac9..1227494e91 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -190,8 +190,20 @@ if ($editGraph) { $weights = implode(',', $weight_array); } + + +$count_module_array = count($module_array); +if ($count_module_array > 10) { + ui_print_warning_message( + __( + 'The maximum number of items in a chart is 10. You have %s elements, only first 10 will be displayed.', + $count_module_array + ) + ); +} + // Modules table. -if (count($module_array) > 0) { +if ($count_module_array > 0) { echo ""; echo ' @@ -202,7 +214,7 @@ if (count($module_array) > 0) { '; $color = 0; - for ($a = 0; $a < count($module_array); $a++) { + for ($a = 0; $a < $count_module_array; $a++) { // Calculate table line color. if ($color == 1) { $tdcolor = 'datos'; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c3402237c8..05551b14b9 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1483,6 +1483,11 @@ function graphic_combined_module( continue; } + // Only 10 item for chart. + if ($i > 9) { + break; + } + if (is_metaconsole()) { $server = metaconsole_get_connection_by_id( $agent_module_id['server'] @@ -1839,15 +1844,12 @@ function graphic_combined_module( } } - if ($automatic_custom_graph_meta) { - $module = $module_item['module']; - } else { - $module = $module_item; - } - + $module = $module_item['module']; $search_in_history_db = db_search_in_history_db($datelimit); - $temp[$module] = io_safe_output(modules_get_agentmodule($module)); + $temp[$module] = io_safe_output( + modules_get_agentmodule($module) + ); $query_last_value = sprintf( ' SELECT datos @@ -1975,12 +1977,7 @@ function graphic_combined_module( } } - if ($automatic_custom_graph_meta) { - $module = $module_item['module']; - } else { - $module = $module_item; - } - + $module = $module_item['module']; $temp[$module] = modules_get_agentmodule($module); $query_last_value = sprintf( ' @@ -2102,12 +2099,7 @@ function graphic_combined_module( } } - if ($automatic_custom_graph_meta === true) { - $module = $module_item['module']; - } else { - $module = $module_item; - } - + $module = $module_item['module']; $module_data = modules_get_agentmodule($module); $query_last_value = sprintf( 'SELECT datos @@ -2243,16 +2235,10 @@ function graphic_combined_module( } } - if ($automatic_custom_graph_meta) { - $module = $module_item['module']; - } else { - $module = $module_item; - } - + $module = $module_item['module']; $data_module = modules_get_agentmodule($module); $query_last_value = sprintf( - ' - SELECT datos + 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 48aaa94ee5..3f4d4d17fe 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2432,7 +2432,7 @@ function pandoraFlotArea( if (!value[x]) { x = x + 1; } - if (value[x].min) { + if (typeof value[x].min !== "undefined" && value[x].min) { min_y_array = format_unit_yaxes(value[x].min); min_y = min_y_array["y"]; min_bigger = min_y_array["unit"]; @@ -2441,7 +2441,7 @@ function pandoraFlotArea( min_bigger = ""; } - if (value[x].max) { + if (typeof value[x].max !== "undefined" && value[x].max) { max_y_array = format_unit_yaxes(value[x].max); max_y = max_y_array["y"]; max_bigger = max_y_array["unit"]; @@ -2450,7 +2450,7 @@ function pandoraFlotArea( max_bigger = ""; } - if (value[x].avg) { + if (typeof value[x].avg !== "undefined" && value[x].avg) { avg_y_array = format_unit_yaxes(value[x].avg); avg_y = avg_y_array["y"]; avg_bigger = avg_y_array["unit"];
'.__('P.').''.__('Delete').' '.__('Sort').'