From 76da0337753a67baca10f5d1f7d26cc9085d6e19 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 17 Dec 2020 16:58:20 +0100 Subject: [PATCH] fix legend pdf chart verticals --- .../reporting/graph_builder.graph_editor.php | 8 +++++--- pandora_console/godmode/setup/setup_visuals.php | 14 ++++++++++++++ pandora_console/include/functions.php | 5 +++++ pandora_console/include/functions_config.php | 8 ++++++++ pandora_console/include/functions_graph.php | 12 ++++++++++-- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 1227494e91..c4db4fa6aa 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -193,11 +193,13 @@ if ($editGraph) { $count_module_array = count($module_array); -if ($count_module_array > 10) { +if ($count_module_array > $config['items_combined_charts']) { 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 + 'The maximum number of items in a chart is %d. You have %d elements, only first %d will be displayed.', + $config['items_combined_charts'], + $count_module_array, + $config['items_combined_charts'] ) ); } diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index d1230f8c35..98d634f404 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -908,6 +908,20 @@ $row++; ); $row++; + $table_chars->data[$row][0] = __('Number of elements in Custom Graph'); + $table_chars->data[$row][1] = html_print_input_text( + 'items_combined_charts', + $config['items_combined_charts'], + '', + 5, + 5, + true, + false, + false, + '' + ); + $row++; + $table_chars->data[$row][0] = __('Use round corners'); $table_chars->data[$row][1] = html_print_checkbox_switch( 'round_corner', diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index f79c56b764..05ff55feca 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -4107,6 +4107,11 @@ function generator_chart_to_pdf( if ($type_graph_pdf === 'vbar') { $width_img = $params['generals']['pdf']['width']; $height_img = $params['generals']['pdf']['height']; + } else if ($type_graph_pdf === 'combined' + && $params_combined['stacked'] == CUSTOM_GRAPH_VBARS + ) { + $width_img = 650; + $height_img = ($params['height'] + 50); } else { $width_img = 550; $height_img = $params['height']; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 4d3665db4d..d6534f7758 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1177,6 +1177,10 @@ function config_update_config() $error_update[] = __('Default type of module charts.'); } + if (!config_update_value('items_combined_charts', (string) get_parameter('items_combined_charts', 10))) { + $error_update[] = __('Default Number of elements in Custom Graph.'); + } + if (!config_update_value('type_interface_charts', (string) get_parameter('type_interface_charts', 'line'))) { $error_update[] = __('Default type of interface charts.'); } @@ -2869,6 +2873,10 @@ function config_process_config() config_update_value('type_module_charts', 'area'); } + if (!isset($config['items_combined_charts'])) { + config_update_value('items_combined_charts', 10); + } + if (!isset($config['type_interface_charts'])) { config_update_value('type_interface_charts', 'line'); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index f40b75e3b2..9b2415716e 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1557,7 +1557,7 @@ function graphic_combined_module( } // Only 10 item for chart. - if ($i > 9) { + if ($i >= $config['items_combined_charts']) { break; } @@ -2153,7 +2153,12 @@ function graphic_combined_module( case CUSTOM_GRAPH_HBARS: case CUSTOM_GRAPH_VBARS: $label = ''; + $i = 0; foreach ($module_list as $module_item) { + if ($i >= $config['items_combined_charts']) { + break; + } + if (is_metaconsole() === true) { $server = metaconsole_get_connection_by_id( $module_item['server'] @@ -2213,6 +2218,8 @@ function graphic_combined_module( if (is_metaconsole() === true) { metaconsole_restore_db(); } + + $i++; } $color = color_graph_array(); @@ -2267,7 +2274,7 @@ function graphic_combined_module( $options['generals']['rotate'] = true; $options['generals']['forceTicks'] = true; - $options['x']['labelWidth'] = $sizeLabelTickWidth; + $options['x']['labelWidth'] = ($params['pdf'] === true) ? 30 : $sizeLabelTickWidth; $options['generals']['arrayColors'] = $color; $options['grid']['backgroundColor'] = 'transparent'; $options['grid']['backgroundColor'] = $background_color; @@ -3924,6 +3931,7 @@ function graph_custom_sql_graph( $options['generals']['arrayColors'] = $color; $options['x']['labelWidth'] = 75; if ($ttl === 2) { + $options['x']['labelWidth'] = 35; $options['backgroundColor'] = 'transparent'; $options['grid']['backgroundColor'] = 'transparent'; $options['y']['color'] = 'transparent';