fixed errors in custom graph with percentile and pdf

This commit is contained in:
daniel 2017-03-06 10:01:24 +01:00
parent cf5ade4972
commit ed287b7cdb
3 changed files with 52 additions and 9 deletions

View File

@ -480,7 +480,7 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
}
}
if (!is_null($percentil)) {
if (!is_null($percentil) && $percentil) {
$avg = array_map(function($item) { return $item['sum'];}, $chart);
$percentil_result = get_percentile($percentil, $avg);
@ -774,7 +774,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$chart_extra_data['legend_unknown'] = $legend['unknown'.$series_suffix_str];
}
if (!is_null($percentil)) {
if (!is_null($percentil) && $percentil) {
$first_data = reset($chart);
$percentil_value = format_for_graph($first_data['percentil'], 2);
@ -1739,8 +1739,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
}
break;
default:
if (!is_null($percentil)) {
if (!is_null($percentil) && $percentil) {
foreach ($graph_values as $graph_group => $point) {
foreach ($point as $timestamp_point => $point_value) {
$temp[$timestamp_point][$graph_group] = $point_value;
@ -1750,7 +1749,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$percentil_result[$graph_group] = array_fill ( 0, count($point), $percentile_value);
$series_type[$graph_group] = 'line';
$agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($module_list[$graph_group]));
modules_get_agentmodule_agent_alias ($module_list[$graph_group]));
$module_name = io_safe_output(
modules_get_agentmodule_name ($module_list[$graph_group]));
$module_name_list['percentil'.$graph_group] = __('Percentile %dº', $config['percentil']) . __(' of module ') . $agent_name .' / ' . $module_name . ' (' . $percentile_value . ' ' . $unit . ') ';

View File

@ -569,7 +569,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor;
$graph['percentil'] = $percentil_values;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";

View File

@ -137,6 +137,10 @@ if (isset($graph['series_type'])) {
$series_type = $graph['series_type'];
}
if (isset($graph['percentil'])){
$percentil = $graph['percentil'];
}
/*
@ -219,10 +223,20 @@ switch ($graph_type) {
case 'line':
case 'threshold':
case 'scatter':
if (!empty($percentil)) {
$count_percentil = count($percentil);
for ($j=0; $j < $count_percentil; $j++) {
$i=0;
foreach ($data as $key => $value) {
$data[$key]['percentil' . $j] = $percentil[$j][$i];
$i++;
}
}
}
foreach ($data as $i => $d) {
$data_values[] = $d;
if (($c % $step) == 0) {
$data_keys[] = $i;
}
@ -297,6 +311,36 @@ foreach ($colors as $i => $color) {
$rgb_color[$i]['alpha'] = $color['alpha'];
}
}
//add color for percentil
if($percentil){
for ($j=0; $j < $count_percentil; $j++) {
if (isset ($colors[$j]['border'])) {
$rgb['border'] = html_html2rgb($colors[$j]['border']);
if (isset($rgb['border'])) {
$rgb_color['percentil' . $j]['border']['R'] = $rgb['border'][0];
$rgb_color['percentil' . $j]['border']['G'] = $rgb['border'][1];
$rgb_color['percentil' . $j]['border']['B'] = $rgb['border'][2];
}
}
if (isset ($colors[$j]['color'])) {
$rgb['color'] = html_html2rgb($colors[$j]['color']);
if (isset($rgb['color'])) {
$rgb_color['percentil' . $j]['color']['R'] = $rgb['color'][0];
$rgb_color['percentil' . $j]['color']['G'] = $rgb['color'][1];
$rgb_color['percentil' . $j]['color']['B'] = $rgb['color'][2];
}
}
if (isset ($colors[$j]['alpha'])) {
$rgb_color['percentil' . $j]['alpha'] = $colors[$j]['alpha'];
}
}
}
//add for report with max 15 modules comparation repeat
$countlegend = count($legend);
if($countlegend > 15){
@ -812,7 +856,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
"BorderB" => $rgb_color[$i]['border']["B"],
"Alpha" => $rgb_color[$i]['alpha']));
/*$palette_color = array();
$palette_color = array();
if (isset($rgb_color[$i]['color'])) {
$palette_color["R"] = $rgb_color[$i]['color']["R"];
$palette_color["G"] = $rgb_color[$i]['color']["G"];
@ -827,7 +871,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$palette_color["Alpha"] = $rgb_color[$i]['Alpha'];
}
$MyData->setPalette($point_id, $palette_color);*/
$MyData->setPalette($point_id, $palette_color);
}
// The weight of the line is not calculated in pixels, so it needs to be transformed