fixed errors in graphs

This commit is contained in:
daniel 2018-07-06 11:56:38 +02:00
parent 8d639b031e
commit c26a50e838
3 changed files with 98 additions and 92 deletions

View File

@ -240,7 +240,7 @@ function grafico_modulo_sparse_data_chart (
$data_slice = $date_array['period'] / (250 * $params['zoom']); $data_slice = $date_array['period'] / (250 * $params['zoom']);
if( $data_module_graph['id_module_type'] == 23 || if( $data_module_graph['id_module_type'] == 23 ||
$data_module_graph['id_module_type'] == 3 || $data_module_graph['id_module_type'] == 3 ||
$data_module_graph['id_module_type'] == 17 || $data_module_graph['id_module_type'] == 17 ||
$data_module_graph['id_module_type'] == 10 || $data_module_graph['id_module_type'] == 10 ||
$data_module_graph['id_module_type'] == 33 ){ $data_module_graph['id_module_type'] == 33 ){
@ -258,12 +258,11 @@ function grafico_modulo_sparse_data_chart (
} }
else{ else{
//all points(data) and boolean //all points(data) and boolean
if( $params['zoom'] == 5 || if( $data_module_graph['id_module_type'] == 2 ||
$data_module_graph['id_module_type'] == 2 || $data_module_graph['id_module_type'] == 6 ||
$data_module_graph['id_module_type'] == 6 ||
$data_module_graph['id_module_type'] == 21 || $data_module_graph['id_module_type'] == 21 ||
$data_module_graph['id_module_type'] == 18 || $data_module_graph['id_module_type'] == 18 ||
$data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 9 ||
$data_module_graph['id_module_type'] == 31 || $data_module_graph['id_module_type'] == 31 ||
$data_module_graph['id_module_type'] == 100 ){ $data_module_graph['id_module_type'] == 100 ){
@ -278,19 +277,6 @@ function grafico_modulo_sparse_data_chart (
$data_module_graph['history_db'] $data_module_graph['history_db']
); );
} }
else{
$data = db_get_all_rows_filter (
'tagente_datos',
array ('id_agente_modulo' => (int)$agent_module_id,
"utimestamp > '". $date_array['start_date']. "'",
"utimestamp < '". $date_array['final_date'] . "'",
'group' => "ROUND(utimestamp / $data_slice)",
'order' => 'utimestamp ASC'),
array ('sum(datos)/count(datos) as datos', 'min(utimestamp) as utimestamp'),
'AND',
$data_module_graph['history_db']
);
}
} }
if($data === false){ if($data === false){
@ -419,45 +405,54 @@ function grafico_modulo_sparse_data(
false, false,
$params['type_mode_graph'] $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'];
} }
else{ else{
/* //uncompress data except boolean and string.
$array_data = grafico_modulo_sparse_data_chart ( if( $data_module_graph['id_module_type'] == 23 ||
$agent_module_id, $data_module_graph['id_module_type'] == 3 ||
$date_array, $data_module_graph['id_module_type'] == 17 ||
$data_module_graph, $data_module_graph['id_module_type'] == 10 ||
$params, $data_module_graph['id_module_type'] == 33 ||
$series_suffix $data_module_graph['id_module_type'] == 2 ||
); $data_module_graph['id_module_type'] == 6 ||
*/ $data_module_graph['id_module_type'] == 21 ||
$array_data = fullscale_data( $data_module_graph['id_module_type'] == 18 ||
$agent_module_id, $data_module_graph['id_module_type'] == 9 ||
$date_array, $data_module_graph['id_module_type'] == 31 ||
$params['show_unknown'], $data_module_graph['id_module_type'] == 100 ){
$params['percentil'], html_debug_prinbt('entra');
$series_suffix, $array_data = grafico_modulo_sparse_data_chart (
$params['flag_overlapped'], $agent_module_id,
$data_slice = $date_array['period'] / (250 * $params['zoom']) + 100, $date_array,
$params['type_mode_graph'] $data_module_graph,
); $params,
$series_suffix
$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']; else{
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name']; $array_data = fullscale_data(
$array_data["sum" . $series_suffix]['agent_alias'] = $data_module_graph['agent_alias']; $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']
);
}
} }
if($array_data === false){ if($array_data === false){
return false; return false;
} }
$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'];
//This is for a specific type of report that consists in passing an interval and doing the average sum and avg. //This is for a specific type of report that consists in passing an interval and doing the average sum and avg.
if($params['force_interval'] != ''){ if($params['force_interval'] != ''){
$period_time_interval = $date_array['period'] * 1000; $period_time_interval = $date_array['period'] * 1000;
@ -477,7 +472,6 @@ function grafico_modulo_sparse_data(
unset($array_data['sum1']['data'][$key]); unset($array_data['sum1']['data'][$key]);
} }
else{ else{
html_debug_print('entra');
if($params['force_interval'] == 'max_only'){ if($params['force_interval'] == 'max_only'){
$acum_array_data[$i][0] = $start_period; $acum_array_data[$i][0] = $start_period;
if(is_array($array_data_only) && count($array_data_only) > 0){ if(is_array($array_data_only) && count($array_data_only) > 0){
@ -1354,6 +1348,11 @@ function graphic_combined_module (
$params['show_unknown'] = false; $params['show_unknown'] = false;
} }
if(!isset($params['type_mode_graph'])){
//$config['type_mode_graph']
$params['type_mode_graph'] = 0;
}
$params['graph_combined'] = true; $params['graph_combined'] = true;
$params_combined['graph_combined'] = true; $params_combined['graph_combined'] = true;

View File

@ -881,7 +881,7 @@ function pandoraFlotArea( graph_id, values, legend,
var grid_color = params.grid_color; var grid_color = params.grid_color;
var background_color = params.backgroundColor; var background_color = params.backgroundColor;
var legend_color = params.legend_color; var legend_color = params.legend_color;
var update_legend = false; var update_legend = {};
//XXXXXX colocar //XXXXXX colocar
var force_integer = 0; var force_integer = 0;
@ -1554,8 +1554,10 @@ function pandoraFlotArea( graph_id, values, legend,
break; break;
} }
if(value.slice_data){ if(series_type[index] != 'boolean'){
update_legend = value.slice_data; if(value.slice_data){
update_legend[index] = value.slice_data;
}
} }
//in graph stacked unset percentil //in graph stacked unset percentil
@ -1973,14 +1975,16 @@ function pandoraFlotArea( graph_id, values, legend,
y = y_array['y']; y = y_array['y'];
how_bigger = y_array['unit']; how_bigger = y_array['unit'];
var label_aux = legend[series.label]; var data_legend = [];
// The graphs of points type and unknown graphs will dont be updated // The graphs of points type and unknown graphs will dont be updated
if (series_type[dataset[k]["label"]] != 'points' && if (series_type[dataset[k]["label"]] != 'points' &&
series_type[dataset[k]["label"]] != 'unknown' && series_type[dataset[k]["label"]] != 'unknown' &&
series_type[dataset[k]["label"]] != 'percentil' series_type[dataset[k]["label"]] != 'percentil'
) { ) {
if(!update_legend){ if(Object.keys(update_legend).length == 0){
var label_aux = legend[series.label];
$('#legend_' + graph_id + ' .legendLabel') $('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux + ' value = ' + .eq(i).html(label_aux + ' value = ' +
(short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) + (short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) +
@ -1988,45 +1992,48 @@ function pandoraFlotArea( graph_id, values, legend,
); );
} }
else{ else{
if(!update_legend[x]){ $.each(update_legend, function (index, value) {
x = x +1; if(!value[x]){
} x = x +1;
if(update_legend[x].min){ }
min_y_array = format_unit_yaxes(update_legend[x].min); if(value[x].min){
min_y = min_y_array['y']; min_y_array = format_unit_yaxes(value[x].min);
min_bigger = min_y_array['unit']; min_y = min_y_array['y'];
} min_bigger = min_y_array['unit'];
else{ }
min_y = 0; else{
min_bigger = ""; min_y = 0;
} min_bigger = "";
}
if(update_legend[x].max){ if(value[x].max){
max_y_array = format_unit_yaxes(update_legend[x].max); max_y_array = format_unit_yaxes(value[x].max);
max_y = max_y_array['y']; max_y = max_y_array['y'];
max_bigger = max_y_array['unit']; max_bigger = max_y_array['unit'];
} }
else{ else{
max_y = 0; max_y = 0;
max_bigger = ""; max_bigger = "";
} }
if(update_legend[x].avg){ if(value[x].avg){
avg_y_array = format_unit_yaxes(update_legend[x].avg); avg_y_array = format_unit_yaxes(value[x].avg);
avg_y = avg_y_array['y']; avg_y = avg_y_array['y'];
avg_bigger = avg_y_array['unit']; avg_bigger = avg_y_array['unit'];
} }
else{ else{
avg_y = 0; avg_y = 0;
avg_bigger = ""; avg_bigger = "";
} }
$('#legend_' + graph_id + ' .legendLabel') data_legend[index] =
.eq(i).html(label_aux ' Min: ' + (short_data ? number_format(min_y, 0, "", short_data) : parseFloat(min_y)) + min_bigger
+ ' 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
+ ' 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;
+ ' Avg: ' + (short_data ? number_format(avg_y, 0, "", short_data) : parseFloat(avg_y)) + avg_bigger });
);
var label_aux = legend[series.label] + data_legend[series.label];
$('#legend_' + graph_id + ' .legendLabel').eq(i).html(label_aux);
} }
} }

View File

@ -295,7 +295,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
$options[2] = 'x2'; $options[2] = 'x2';
$options[3] = 'x3'; $options[3] = 'x3';
$options[4] = 'x4'; $options[4] = 'x4';
$options[5] = __('full'); $options[5] = 'x5';
$data[1] = html_print_select ($options, "zoom", $zoom, '', '', 0, true, false, false); $data[1] = html_print_select ($options, "zoom", $zoom, '', '', 0, true, false, false);
$table->data[] = $data; $table->data[] = $data;
$table->rowclass[] = ''; $table->rowclass[] = '';