From 5e099a0da3738cba140509b463fac80cecacae29 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 7 Jun 2017 11:43:11 +0200 Subject: [PATCH] added graph colors in dahsboard --- pandora_console/include/constants.php | 1 + .../include/functions_custom_graphs.php | 5 ++-- pandora_console/include/functions_graph.php | 23 +++++++++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index cee055d867..aa287b344a 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -467,6 +467,7 @@ define("OPTION_SINGLE_SELECT_TIME", 7); define("OPTION_CUSTOM_INPUT", 8); define("OPTION_AGENT_AUTOCOMPLETE", 9); define("OPTION_SELECT_MULTISELECTION", 10); +define("OPTION_COLOR_PICKER", 11); /* Transactional map constants */ define("NODE_TYPE", 0); diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 361975b29c..499a8a817f 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -164,7 +164,7 @@ function custom_graphs_print($id_graph, $height, $width, $period, $background_color = 'white', $modules_param = array(), $homeurl = '', $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $ttl = 1, - $dashboard = false, $vconsole = false, $percentil = null, $from_interface = false) { + $dashboard = false, $vconsole = false, $percentil = null, $from_interface = false,$id_widget_dashboard=false) { global $config; @@ -260,7 +260,8 @@ function custom_graphs_print($id_graph, $height, $width, $period, $dashboard, $vconsole, $percentil, - $from_interface); + $from_interface, + $id_widget_dashboard); if ($return) return $output; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c6721d1476..ba089a9457 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -791,7 +791,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $only_image = false, $homeurl = '', $ttl = 1, $projection = false, $adapt_key = '', $compare = false, $show_unknown = false, $menu = true, $backgroundColor = 'white', $percentil = null, - $dashboard = false, $vconsole = false, $type_graph = 'area') { + $dashboard = false, $vconsole = false, $type_graph = 'area',$id_widget_dashboard = false) { global $config; global $graphic_type; @@ -855,8 +855,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $date, $unit, $baseline, $return_data, $show_title, $projection, $adapt_key, $compare, '', '', $show_unknown, $percentil, $dashboard, $vconsole,$type_graph); - - + if ($return_data) { return $data_returned; } @@ -907,6 +906,13 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, } else { // Color commented not to restrict serie colors + if($id_widget_dashboard){ + $opcion = unserialize(db_get_value_filter('options','twidget_dashboard',array('id' => $id_widget_dashboard))); + $color['min']['color'] = $opcion['min']; + $color['sum']['color'] = $opcion['avg']; + $color['max']['color'] = $opcion['max']; + } + return area_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, @@ -993,7 +999,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $prediction_period = false, $background_color = 'white', $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $labels = array(), $dashboard = false, - $vconsole = false, $percentil = null, $from_interface = false) { + $vconsole = false, $percentil = null, $from_interface = false, $id_widget_dashboard=false) { global $config; global $graphic_type; @@ -1828,6 +1834,15 @@ function graphic_combined_module ($module_list, $weight_list, $period, $color[15] = array('border' => '#000000', 'color' => COL_GRAPH13, 'alpha' => CHART_DEFAULT_ALPHA); + + if($id_widget_dashboard){ + $opcion = unserialize(db_get_value_filter('options','twidget_dashboard',array('id' => $id_widget_dashboard))); + foreach ($module_list as $key => $value) { + if(!empty($opcion[$value])){ + $color[$key]['color'] = $opcion[$value]; + } + } + } $threshold_data = array();