Merge branch '2450-Falsa_representación_en_graficas_sin_TIP' into 'develop'

2450 falsa representación en graficas sin tip

See merge request artica/pandorafms!1593
This commit is contained in:
vgilc 2018-07-05 12:05:09 +02:00
commit f244dd79be
6 changed files with 418 additions and 97 deletions

View File

@ -685,6 +685,17 @@ $options_full_escale[2] = __('On Boolean graphs');
$table_chars->data[$row][1] = html_print_select($options_full_escale, 'full_scale_option', $config["full_scale_option"], '', '', 0, true, false, false);
$row++;
$table_chars->data[$row][0] = __('Soft graphs:');
$table_chars->data[$row][0] .= ui_print_help_tip(__('This option may cause performance issues'), true);
$options_soft_graphs = array();
$options_soft_graphs[0] = __('Standard mode');
$options_soft_graphs[1] = __('Classic mode');
$table_chars->data[$row][1] = html_print_select($options_soft_graphs, 'type_mode_graph', $config["type_mode_graph"], '', '', 0, true, false, false);
$row++;
$table_chars->data[$row][0] = __('Graph image height');
$table_chars->data[$row][1] = html_print_input_text ('graph_image_height', $config['graph_image_height'], '', 20, 20, true);
$row++;

View File

@ -3104,20 +3104,57 @@ function series_type_graph_array($data, $show_elements_graph){
if (isset($show_elements_graph['labels']) &&
is_array($show_elements_graph['labels']) &&
(count($show_elements_graph['labels']) > 0)){
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
$name_legend = $data_return['legend'][$key] = $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
}
else{
if(strpos($key, 'baseline') !== false){
$data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
$name_legend = $data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
$value['module_name'] . ' Baseline ';
}
else{
$data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
$name_legend = $data_return['legend'][$key] = $value['agent_alias'] . ' / ' .
$value['module_name'] . ': ';
}
}
if(strpos($key, 'baseline') === false){
if(($show_elements_graph['fullscale'] ||
$show_elements_graph['type_mode_graph'] ) &&
strpos($key, 'baseline') === false ){
$data_return['legend'][$key] .=
__('Min:') . remove_right_zeros(
number_format(
$value['min'],
$config['graph_precision']
)
) . ' ' .
__('Max:') . remove_right_zeros(
number_format(
$value['max'],
$config['graph_precision']
)
) . ' ' .
_('Avg:') . remove_right_zeros(
number_format(
$value['avg'],
$config['graph_precision']
)
) . ' ' . $str;
}
if($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2'){
$data_return['color'][$key] = $color_series['overlapped'];
}
else{
$data_return['color'][$key] = $color_series[$i];
$i++;
}
}
elseif(!$show_elements_graph['fullscale'] && strpos($key, 'min') !== false ||
!$show_elements_graph['fullscale'] && strpos($key, 'max') !== false){
$data_return['series_type'][$key] = $type_graph;
$data_return['legend'][$key] = $name_legend;
if($show_elements_graph['type_mode_graph']){
$data_return['legend'][$key] .=
__('Min:') . remove_right_zeros(
number_format(
@ -3177,13 +3214,7 @@ function series_type_graph_array($data, $show_elements_graph){
__('Percentil') . ' ' .
$config['percentil'] .
'º ' . __('of module') . ' ';
if (isset($show_elements_graph['labels']) && is_array($show_elements_graph['labels'])){
$data_return['legend'][$key] .= $show_elements_graph['labels'][$value['agent_module_id']] . ' ' ;
}
else{
$data_return['legend'][$key] .= $value['agent_alias'] . ' / ' .
$value['module_name'] . ': ' . ' Value: ';
}
$data_return['legend'][$key] .= $name_legend;
$data_return['legend'][$key] .= remove_right_zeros(
number_format(
$value['data'][0][1],

View File

@ -627,7 +627,10 @@ function config_update_config () {
if (!config_update_value ('full_scale_option', (int) get_parameter('full_scale_option', 0)))
$error_update[] = __('Default full scale (TIP)');
if (!config_update_value ('type_mode_graph', (int) get_parameter('type_mode_graph', 0)))
$error_update[] = __('Default soft graphs');
if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 0)))
$error_update[] = __('Default height of the chart image');

View File

@ -601,7 +601,7 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend
* utimestamp
*
*/
function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = false) {
function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = false, $slice_size = false) {
global $config;
if (!isset($id_agente_modulo)) {
@ -709,7 +709,9 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
}
// Retrieve module_interval to build the template
$slice_size = $module_interval;
if($slice_size === false){
$slice_size = $module_interval;
}
$return = array();

View File

@ -415,7 +415,9 @@ function grafico_modulo_sparse_data(
$params['show_unknown'],
$params['percentil'],
$series_suffix,
$params['flag_overlapped']
$params['flag_overlapped'],
false,
$params['type_mode_graph']
);
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
@ -425,6 +427,7 @@ function grafico_modulo_sparse_data(
$array_data["sum" . $series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
}
else{
/*
$array_data = grafico_modulo_sparse_data_chart (
$agent_module_id,
$date_array,
@ -432,6 +435,23 @@ function grafico_modulo_sparse_data(
$params,
$series_suffix
);
*/
$array_data = fullscale_data(
$agent_module_id,
$date_array,
$params['show_unknown'],
$params['percentil'],
$series_suffix,
$params['flag_overlapped'],
$data_slice = $date_array['period'] / (250 * $params['zoom']) + 100,
$params['type_mode_graph']
);
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
$array_data["sum" . $series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
}
if($array_data === false){
@ -457,6 +477,7 @@ function grafico_modulo_sparse_data(
unset($array_data['sum1']['data'][$key]);
}
else{
html_debug_print('entra');
if($params['force_interval'] == 'max_only'){
$acum_array_data[$i][0] = $start_period;
if(is_array($array_data_only) && count($array_data_only) > 0){
@ -878,6 +899,11 @@ function grafico_modulo_sparse ($params) {
$params['zoom'] = 1;
}
if(!isset($params['type_mode_graph'])){
//$config['type_mode_graph']
$params['type_mode_graph'] = $config['type_mode_graph'];
}
//XXXX Configurable
$params['grid_color'] = '#C1C1C1';
$params['legend_color'] = '#636363';
@ -3948,86 +3974,267 @@ function fullscale_data (
$agent_module_id, $date_array,
$show_unknown = 0, $show_percentil = 0,
$series_suffix,
$compare = false){
$compare = false,
$data_slice = false,
$type_mode_graph){
global $config;
$data_uncompress =
db_uncompress_module_data(
$agent_module_id,
$date_array['start_date'],
$date_array['final_date']
$date_array['final_date'],
$data_slice
);
$data = array();
$previous_data = 0;
$min_value = PHP_INT_MAX-1;
$max_value = PHP_INT_MIN+1;
//normal
$min_value_total = PHP_INT_MAX;
$max_value_total = -PHP_INT_MAX;
//max
$max_value_min = PHP_INT_MAX;
$max_value_max = -PHP_INT_MAX;
//min
$min_value_min = PHP_INT_MAX;
$min_value_max = -PHP_INT_MAX;
//avg
$avg_value_min = PHP_INT_MAX;
$avg_value_max = -PHP_INT_MAX;
$flag_unknown = 0;
$array_percentil = array();
foreach ($data_uncompress as $k) {
foreach ($k["data"] as $v) {
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
continue;
}
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
}
else{
$real_date = $v['utimestamp'] * 1000;
}
if ($v["datos"] === NULL) {
// Unknown
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
if($data_slice){
foreach ($data_uncompress as $k) {
$sum_data = 0;
$count_data = 0;
$min_value = PHP_INT_MAX;
$max_value = -PHP_INT_MAX;
$flag_virtual_data = 0;
foreach ($k["data"] as $v) {
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
continue;
$flag_virtual_data = 1;
}
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
}
else{
$real_date = $v['utimestamp'] * 1000;
}
if ($v["datos"] === NULL) {
// Unknown
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
}
else{
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
$flag_unknown = 1;
}
}
else{
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
$flag_unknown = 1;
}
$v["datos"] = $previous_data;
}
else {
//normal
$previous_data = $v["datos"];
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
$flag_unknown = 0;
}
}
}
}
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
}
else {
//normal
$previous_data = $v["datos"];
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
$flag_unknown = 0;
}
if(isset($v["datos"]) && $v["datos"]){
//max
if($v['datos'] >= $max_value){
$max_value = $v['datos'];
}
//min
if($v['datos'] <= $min_value){
$min_value = $v['datos'];
}
//avg sum
$sum_data += $v["datos"];
}
//avg count
$count_data++;
if($show_percentil && !$compare){
$array_percentil[] = $v["datos"];
}
$last_data = $v["datos"];
}
if(isset($v["datos"]) && $v["datos"]){
//max
if($v['datos'] >= $max_value){
$max_value = $v['datos'];
if(!$flag_virtual_data){
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($k['data'][0]['utimestamp'] + $date_array['period']) * 1000;
}
//min
if($v['datos'] <= $min_value){
$min_value = $v['datos'];
else{
$real_date = $k['data'][0]['utimestamp'] * 1000;
}
//avg sum
$sum_data += $v["datos"];
}
//avg count
$count_data++;
if($show_percentil && !$compare){
$array_percentil[] = $v["datos"];
}
$data["sum" . $series_suffix]['data'][] = array($real_date , $sum_data/$count_data);
if($type_mode_graph && !$params['baseline']){
$data["min" . $series_suffix]['data'][] = array($real_date , $min_value);
$data["max" . $series_suffix]['data'][] = array($real_date , $max_value);
}
else{
$data["sum" . $series_suffix]['slice_data'][$real_date]['min'] = $min_value;
$data["sum" . $series_suffix]['slice_data'][$real_date]['avg'] = $sum_data/$count_data;
$data["sum" . $series_suffix]['slice_data'][$real_date]['max'] = $max_value;
}
$last_data = $v["datos"];
//max_total
if($max_value >= $max_value_total){
$max_value_total = $max_value;
}
//min_total
if($min_value <= $min_value_total){
$min_value_total = $min_value;
}
//avg sum_total
$sum_data_total += $sum_data;
//avg count_total
$count_data_total++;
if($type_mode_graph && !$params['baseline']){
/*MIN*/
//max_min
if($min_value >= $min_value_max){
$min_value_max = $min_value;
}
//min_min
if($min_value <= $min_value_min){
$min_value_min = $min_value;
}
//avg sum_min
$sum_data_min += $min_value;
/*MAX*/
//max_max
if($max_value >= $max_value_max){
$max_value_max = $max_value;
}
//min_max
if($max_value <= $max_value_min){
$max_value_min = $max_value;
}
//avg sum_max
$sum_data_max += $max_value;
/*AVG*/
//max_max
if(($sum_data/$count_data) >= $avg_value_max){
$avg_value_max = $sum_data/$count_data;
}
//min_max
if(($sum_data/$count_data) <= $avg_value_min){
$avg_value_min = $sum_data/$count_data;
}
//avg sum_max
$sum_data_avg += $sum_data/$count_data;
}
}
}
$data["sum" . $series_suffix]['min'] = $min_value_total;
$data["sum" . $series_suffix]['max'] = $max_value_total;
$data["sum" . $series_suffix]['avg'] = $sum_data_total/$count_data_total;
if($type_mode_graph && !$params['baseline']){
$data["min" . $series_suffix]['min'] = $min_value_min;
$data["min" . $series_suffix]['max'] = $min_value_max;
$data["min" . $series_suffix]['avg'] = $sum_data_min/$count_data_total;
$data["max" . $series_suffix]['min'] = $max_value_min;
$data["max" . $series_suffix]['max'] = $max_value_max;
$data["max" . $series_suffix]['avg'] = $sum_data_max/$count_data_total;
$data["sum" . $series_suffix]['min'] = $avg_value_min;
$data["sum" . $series_suffix]['max'] = $avg_value_max;
$data["sum" . $series_suffix]['avg'] = $sum_data_avg/$count_data_total;
}
}
else{
foreach ($data_uncompress as $k) {
foreach ($k["data"] as $v) {
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
continue;
}
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
}
else{
$real_date = $v['utimestamp'] * 1000;
}
if ($v["datos"] === NULL) {
// Unknown
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
}
else{
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
$flag_unknown = 1;
}
}
}
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
}
else {
//normal
$previous_data = $v["datos"];
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
$flag_unknown = 0;
}
}
}
}
if(isset($v["datos"]) && $v["datos"]){
//max
if($v['datos'] >= $max_value){
$max_value = $v['datos'];
}
//min
if($v['datos'] <= $min_value){
$min_value = $v['datos'];
}
//avg sum
$sum_data += $v["datos"];
}
//avg count
$count_data++;
if($show_percentil && !$compare){
$array_percentil[] = $v["datos"];
}
$last_data = $v["datos"];
}
}
$data["sum" . $series_suffix]['min'] = $min_value;
$data["sum" . $series_suffix]['max'] = $max_value;
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
}
if($show_percentil && !$compare){
@ -4065,12 +4272,19 @@ function fullscale_data (
$date_array['final_date'] * 1000,
$last_data
);
if($data_slice){
if($type_mode_graph && !$params['baseline']){
$data["min" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $min_value);
$data["max" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $max_value);
}
else{
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['min'] = $min_value;
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['avg'] = $sum_data/$count_data;
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['max'] = $max_value;
}
}
}
$data["sum" . $series_suffix]['min'] = $min_value;
$data["sum" . $series_suffix]['max'] = $max_value;
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
return $data;
}

View File

@ -881,6 +881,7 @@ function pandoraFlotArea( graph_id, values, legend,
var grid_color = params.grid_color;
var background_color = params.backgroundColor;
var legend_color = params.legend_color;
var update_legend = false;
//XXXXXX colocar
var force_integer = 0;
@ -1553,6 +1554,10 @@ function pandoraFlotArea( graph_id, values, legend,
break;
}
if(value.slice_data){
update_legend = value.slice_data;
}
//in graph stacked unset percentil
if( ! ( (type == 1) && ( /percentil/.test(index) ) == true ) &&
! ( (type == 3) && ( /percentil/.test(index) ) == true ) ){
@ -1582,9 +1587,6 @@ function pandoraFlotArea( graph_id, values, legend,
// The first execution, the graph data is the base data
datas = data_base;
// minTickSize
var count_data = datas[0].data.length;
var number_ticks = 8;
if(vconsole){
number_ticks = 5;
@ -1962,26 +1964,14 @@ function pandoraFlotArea( graph_id, values, legend,
if(series.data[j]){
var y = series.data[j][1];
var x = series.data[j][0] -1 ;
}
}
var how_bigger = "";
if (y > 1000000) {
how_bigger = "M";
y = y / 1000000;
}
else if (y > 1000) {
how_bigger = "K";
y = y / 1000;
}
else if(y < -1000000) {
how_bigger = "M";
y = y / 1000000;
}
else if (y < -1000) {
how_bigger = "K";
y = y / 1000;
}
y_array = format_unit_yaxes(y);
y = y_array['y'];
how_bigger = y_array['unit'];
var label_aux = legend[series.label];
@ -1990,11 +1980,54 @@ function pandoraFlotArea( graph_id, values, legend,
series_type[dataset[k]["label"]] != 'unknown' &&
series_type[dataset[k]["label"]] != 'percentil'
) {
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux + ' value = ' +
(short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) +
how_bigger + ' ' + unit
);
if(!update_legend){
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux + ' value = ' +
(short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) +
how_bigger + ' ' + unit
);
}
else{
if(!update_legend[x]){
x = x +1;
}
if(update_legend[x].min){
min_y_array = format_unit_yaxes(update_legend[x].min);
min_y = min_y_array['y'];
min_bigger = min_y_array['unit'];
}
else{
min_y = 0;
min_bigger = "";
}
if(update_legend[x].max){
max_y_array = format_unit_yaxes(update_legend[x].max);
max_y = max_y_array['y'];
max_bigger = max_y_array['unit'];
}
else{
max_y = 0;
max_bigger = "";
}
if(update_legend[x].avg){
avg_y_array = format_unit_yaxes(update_legend[x].avg);
avg_y = avg_y_array['y'];
avg_bigger = avg_y_array['unit'];
}
else{
avg_y = 0;
avg_bigger = "";
}
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux
+ ' Min: ' + (short_data ? number_format(min_y, 0, "", short_data) : parseFloat(min_y)) + min_bigger
+ ' Max: ' + (short_data ? number_format(max_y, 0, "", short_data) : parseFloat(max_y)) + max_bigger
+ ' Avg: ' + (short_data ? number_format(avg_y, 0, "", short_data) : parseFloat(avg_y)) + avg_bigger
);
}
}
$('#legend_' + graph_id + ' .legendLabel').eq(i).css('color', legend_color);
@ -2317,6 +2350,33 @@ function pandoraFlotArea( graph_id, values, legend,
}
}
function format_unit_yaxes(y){
var how_bigger = [];
if (y > 1000000) {
how_bigger['unit'] = "M";
how_bigger['y'] = y / 1000000;
}
else if (y > 1000) {
how_bigger['unit'] = "K";
how_bigger['y'] = y / 1000;
}
else if(y < -1000000) {
how_bigger['unit'] = "M";
how_bigger['y'] = y / 1000000;
}
else if (y < -1000) {
how_bigger['unit'] = "K";
how_bigger['y'] = y / 1000;
}
else{
how_bigger['unit'] = "";
how_bigger['y'] = y;
}
return how_bigger;
}
function adjust_menu(graph_id, plot, parent_height, width, show_legend) {
if ($('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width') != undefined) {
left_ticks_width = $('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width').split('px')[0];