From 89ffa677401840184ca7f2a18e748076e943d8cc Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 31 Mar 2011 08:46:04 +0000 Subject: [PATCH] 2011-03-31 Miguel de Dios * include/functions_graph.php, include/graphs/functions_fsgraph.php: add to support and wip with new graph engine. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4153 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++ pandora_console/include/functions_graph.php | 12 ++++- .../include/graphs/functions_fsgraph.php | 48 ++++++++++++++----- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 844117aeaa..414d879c0f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2011-03-31 Miguel de Dios + + * include/functions_graph.php, include/graphs/functions_fsgraph.php: add + to support and wip with new graph engine. + 2011-03-31 Sergio Martin * include/graphs/functions_pchart.php: Improved diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index df127dd545..a147286bcc 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -257,8 +257,16 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events, $color['alert'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50); $color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 100); $color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 100); - $color['min'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); + $color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); - area_graph(0, $chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption, $baseline, $color); + $legend = array(); + $legend['sum'] = __('Avg') . ' (' . $avg_value . ')'; + $legend['event'] = __('Events'); + $legend['alert'] = __('Alerts'); + $legend['max'] = __('Max') . ' (' . $max_value . ')'; + $legend['min'] = __('Min') . ' (' . $min_value . ')'; + $legend['baseline'] = __('Baseline'); + + area_graph(0, $chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption, $baseline, $color, $legend); } ?> \ No newline at end of file diff --git a/pandora_console/include/graphs/functions_fsgraph.php b/pandora_console/include/graphs/functions_fsgraph.php index 73b51ff65f..c95d75a9b1 100755 --- a/pandora_console/include/graphs/functions_fsgraph.php +++ b/pandora_console/include/graphs/functions_fsgraph.php @@ -49,7 +49,7 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti $total_min = 0; // Create categories - foreach ($data as $value) { + foreach ($data as $i => $value) { $total_avg +=$value["sum"]; @@ -66,7 +66,8 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti } else { $show_name = '0'; } - $chart->addCategory(date($time_format, $value['timestamp_bottom']), 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $value['timestamp_bottom']) . ';showName=' . $show_name); + $chart->addCategory(date($time_format, $i), + 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i) . ';showName=' . $show_name); } if ($count > 0) @@ -74,12 +75,20 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti else $total_avg = 0; - $total_min = format_for_graph ($total_min); - $total_max = format_for_graph ($total_max); - + //$total_min = format_for_graph ($total_min); + //$total_max = format_for_graph ($total_max); + // Event chart if ($show_events == 1) { - $chart->addDataSet(__('Events'), 'alpha=50;showAreaBorder=1;areaBorderColor=#ff7f00;color=#ff7f00'); + $showAreaBorder = 0; + if (!is_null($color['event']['border'])) { + $showAreaBorder = 1; + } + + $chart->addDataSet($caption['event'], 'alpha=' . $color['event']['alpha'] . ';' . + 'showAreaBorder=' . $showAreaBorder . ';' . + 'areaBorderColor=' . $color['event']['border'] . ';' . + 'color=#' . $color['event']['color']); foreach ($data as $value) { $chart->addChartData($value['event']); } @@ -87,15 +96,23 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti // Alert chart if ($show_alerts == 1) { - $chart->addDataSet(__('Alerts'), 'alpha=50;showAreaBorder=1;areaBorderColor=#ff0000;color=#ff0000'); + $showAreaBorder = 0; + if (!is_null($color['alert']['border'])) { + $showAreaBorder = 1; + } + + $chart->addDataSet($caption['alert'], 'alpha=' . $color['alert']['alpha'] . ';' . + 'showAreaBorder=' . $showAreaBorder . ';' . + 'areaBorderColor=' . $color['alert']['border'] . ';' . + 'color=' . $color['alert']['color']); foreach ($data as $value) { $chart->addChartData($value['alert']); } } // Max chart - if ($avg_only == 0) { - $chart->addDataSet(__('Max')." ($total_max)", 'color=' . $config['graph_color3']); + if ($avg_only == 0) { + $chart->addDataSet($caption['max'], 'color=' . $color['max']['color']); foreach ($data as $value) { $chart->addChartData($value['max']); } @@ -103,7 +120,7 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti // Avg chart $empty = 1; - $chart->addDataSet(__('Avg'). " ($total_avg)", 'color=' . $config['graph_color2']); + $chart->addDataSet($caption['sum'], 'color=' . $color['sum']['color']); foreach ($data as $value) { if ($value['sum'] > 0) { $empty = 0; @@ -113,7 +130,7 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti // Min chart if ($avg_only == 0) { - $chart->addDataSet(__('Min'). " ($total_min)", 'color=' . $config['graph_color1']); + $chart->addDataSet($caption['min'], 'color=' . $color['min']['color']); foreach ($data as $value) { $chart->addChartData($value['min']); } @@ -121,7 +138,14 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti // Baseline chart if ($baseline == 1) { - $chart->addDataSet(__('Baseline'), 'color=0097BD;alpha=10;showAreaBorder=0;'); + $showAreaBorder = 0; + if (!is_null($color['baseline']['border'])) { + $showAreaBorder = 1; + } + + $chart->addDataSet($caption['baseline'], 'color=' . $color['baseline']['color'] . ';' . + 'alpha=' . $color['baseline']['alpha'] . ';' . + 'showAreaBorder=' . $showAreaBorder . ';'); foreach ($data as $value) { $chart->addChartData($value['baseline']); }