From 2c535bb747190dc33d0b13643d9983dec619c44e Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 21 Jul 2020 15:06:41 +0200 Subject: [PATCH] Fixed labels mode classic --- .../godmode/setup/setup_visuals.php | 4 +- pandora_console/include/functions.php | 114 ++++++++++++++---- 2 files changed, 92 insertions(+), 26 deletions(-) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 9874d4503b..9ecbd495b1 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -870,8 +870,8 @@ $row++; $table_chars->data[$row][0] = __('Show only average'); $options_soft_graphs = []; - $options_soft_graphs[0] = __('Standard mode'); - $options_soft_graphs[1] = __('Classic mode'); + $options_soft_graphs[0] = __('Show only average by default'); + $options_soft_graphs[1] = __('Show MAX/AVG/MIN by default'); $table_chars->data[$row][1] = html_print_select($options_soft_graphs, 'type_mode_graph', $config['type_mode_graph'], '', '', 0, true, false, false); $row++; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 23773a2934..3595fa571b 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3623,6 +3623,14 @@ function color_graph_array() } +/** + * Label graph Sparse. + * + * @param array $data Data chart. + * @param array $show_elements_graph Data visual styles chart. + * + * @return array Array label. + */ function series_type_graph_array($data, $show_elements_graph) { global $config; @@ -3645,7 +3653,13 @@ function series_type_graph_array($data, $show_elements_graph) $color_series = color_graph_array(); if ($show_elements_graph['id_widget_dashboard']) { - $opcion = unserialize(db_get_value_filter('options', 'twidget_dashboard', ['id' => $show_elements_graph['id_widget_dashboard']])); + $opcion = unserialize( + db_get_value_filter( + 'options', + 'twidget_dashboard', + ['id' => $show_elements_graph['id_widget_dashboard']] + ) + ); if ($show_elements_graph['graph_combined']) { foreach ($show_elements_graph['modules_id'] as $key => $value) { $color_series[$key] = [ @@ -3674,13 +3688,15 @@ function series_type_graph_array($data, $show_elements_graph) if (strpos($key, 'summatory') !== false) { $data_return['series_type'][$key] = $type_graph; - $data_return['legend'][$key] = __('Summatory series').' '.$str; - $data_return['color'][$key] = $color_series['summatory']; + $data_return['legend'][$key] = __('Summatory series').' '.$str; + $data_return['color'][$key] = $color_series['summatory']; } else if (strpos($key, 'average') !== false) { $data_return['series_type'][$key] = $type_graph; - $data_return['legend'][$key] = __('Average series').' '.$str; - $data_return['color'][$key] = $color_series['average']; - } else if (strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false) { + $data_return['legend'][$key] = __('Average series').' '.$str; + $data_return['color'][$key] = $color_series['average']; + } else if (strpos($key, 'sum') !== false + || strpos($key, 'baseline') !== false + ) { switch ($value['id_module_type']) { case 21: case 2: @@ -3702,24 +3718,44 @@ function series_type_graph_array($data, $show_elements_graph) && (count($show_elements_graph['labels']) > 0) ) { if ($show_elements_graph['unit']) { - $name_legend = $show_elements_graph['labels'][$value['agent_module_id']].' / '.__('Unit ').' '.$show_elements_graph['unit'].': '; - $data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']].' / '.__('Unit ').' '.$show_elements_graph['unit'].': '; + $name_legend = $show_elements_graph['labels'][$value['agent_module_id']]; + $name_legend .= ' / '; + $name_legend .= __('Unit ').' '; + $name_legend .= $show_elements_graph['unit'].': '; } else { $name_legend = $show_elements_graph['labels'][$value['agent_module_id']].': '; - $data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']].': '; } } else { if (strpos($key, 'baseline') !== false) { if ($value['unit']) { - $name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].'Baseline '; + $name_legend = $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name']; + $name_legend .= ' / '; + $name_legend .= __('Unit ').' '; + $name_legend .= $value['unit'].'Baseline '; } else { - $name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].'Baseline '; + $name_legend = $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name'].'Baseline '; } } else { + $name_legend = ''; + if ((int) $config['type_mode_graph'] === 1) { + $name_legend .= 'Avg: '; + } + if ($value['unit']) { - $name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$value['unit'].': '; + $name_legend .= $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name']; + $name_legend .= ' / '; + $name_legend .= __('Unit ').' '; + $name_legend .= $value['unit'].': '; } else { - $name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': '; + $name_legend .= $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name'].': '; } } } @@ -3727,10 +3763,11 @@ function series_type_graph_array($data, $show_elements_graph) if (isset($value['weight']) === true && empty($value['weight']) === false ) { - $name_legend .= ' ('.__('Weight').' * '.$value['weight'].') '; - $data_return['legend'][$key] .= ' ('.__('Weight').' * '.$value['weight'].') '; + $name_legend .= ' ('.__('Weight'); + $name_legend .= ' * '.$value['weight'].') '; } + $data_return['legend'][$key] = $name_legend; if ((int) $value['min'] === PHP_INT_MAX) { $value['min'] = 0; } @@ -3756,36 +3793,63 @@ function series_type_graph_array($data, $show_elements_graph) ) ).' '.$str; - if ($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2') { + if ($show_elements_graph['compare'] == 'overlapped' + && $key == 'sum2' + ) { $data_return['color'][$key] = $color_series['overlapped']; } else { $data_return['color'][$key] = $color_series[$i]; $i++; } - } else if (!$show_elements_graph['fullscale'] && strpos($key, 'min') !== false - || !$show_elements_graph['fullscale'] && strpos($key, 'max') !== false + } else if (!$show_elements_graph['fullscale'] + && strpos($key, 'min') !== false + || !$show_elements_graph['fullscale'] + && strpos($key, 'max') !== false ) { $data_return['series_type'][$key] = $type_graph; + $name_legend = ''; + if ((int) $config['type_mode_graph'] === 1) { + if (strpos($key, 'min') !== false) { + $name_legend .= 'Min: '; + } + + if (strpos($key, 'max') !== false) { + $name_legend .= 'Max: '; + } + } + if ($show_elements_graph['unit']) { - $name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].' / '.__('Unit ').' '.$show_elements_graph['unit'].': '; + $name_legend .= $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name']; + $name_legend .= ' / '; + $name_legend .= __('Unit ').' '; + $name_legend .= $show_elements_graph['unit'].': '; } else { - $name_legend = $data_return['legend'][$key] = $value['agent_alias'].' / '.$value['module_name'].': '; + $name_legend .= $value['agent_alias']; + $name_legend .= ' / '; + $name_legend .= $value['module_name'].': '; } $data_return['legend'][$key] = $name_legend; if ($show_elements_graph['type_mode_graph']) { - $data_return['legend'][$key] .= __('Min:').remove_right_zeros( + $data_return['legend'][$key] .= __('Min:'); + $data_return['legend'][$key] .= remove_right_zeros( number_format( $value['min'], $config['graph_precision'] ) - ).' '.__('Max:').remove_right_zeros( + ); + $data_return['legend'][$key] .= ' '.__('Max:'); + $data_return['legend'][$key] .= remove_right_zeros( number_format( $value['max'], $config['graph_precision'] ) - ).' '._('Avg:').remove_right_zeros( + ); + $data_return['legend'][$key] .= ' '._('Avg:'); + $data_return['legend'][$key] .= remove_right_zeros( number_format( $value['avg'], $config['graph_precision'] @@ -3793,7 +3857,9 @@ function series_type_graph_array($data, $show_elements_graph) ).' '.$str; } - if ($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2') { + if ($show_elements_graph['compare'] == 'overlapped' + && $key == 'sum2' + ) { $data_return['color'][$key] = $color_series['overlapped']; } else { $data_return['color'][$key] = $color_series[$i];