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']);
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'] == 10 ||
$data_module_graph['id_module_type'] == 33 ){
@ -258,12 +258,11 @@ function grafico_modulo_sparse_data_chart (
}
else{
//all points(data) and boolean
if( $params['zoom'] == 5 ||
$data_module_graph['id_module_type'] == 2 ||
$data_module_graph['id_module_type'] == 6 ||
if( $data_module_graph['id_module_type'] == 2 ||
$data_module_graph['id_module_type'] == 6 ||
$data_module_graph['id_module_type'] == 21 ||
$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'] == 100 ){
@ -278,19 +277,6 @@ function grafico_modulo_sparse_data_chart (
$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){
@ -419,45 +405,54 @@ function grafico_modulo_sparse_data(
false,
$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{
/*
$array_data = grafico_modulo_sparse_data_chart (
$agent_module_id,
$date_array,
$data_module_graph,
$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'];
//uncompress data except boolean and string.
if( $data_module_graph['id_module_type'] == 23 ||
$data_module_graph['id_module_type'] == 3 ||
$data_module_graph['id_module_type'] == 17 ||
$data_module_graph['id_module_type'] == 10 ||
$data_module_graph['id_module_type'] == 33 ||
$data_module_graph['id_module_type'] == 2 ||
$data_module_graph['id_module_type'] == 6 ||
$data_module_graph['id_module_type'] == 21 ||
$data_module_graph['id_module_type'] == 18 ||
$data_module_graph['id_module_type'] == 9 ||
$data_module_graph['id_module_type'] == 31 ||
$data_module_graph['id_module_type'] == 100 ){
html_debug_prinbt('entra');
$array_data = grafico_modulo_sparse_data_chart (
$agent_module_id,
$date_array,
$data_module_graph,
$params,
$series_suffix
);
}
else{
$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']
);
}
}
if($array_data === 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.
if($params['force_interval'] != ''){
$period_time_interval = $date_array['period'] * 1000;
@ -477,7 +472,6 @@ 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){
@ -1354,6 +1348,11 @@ function graphic_combined_module (
$params['show_unknown'] = false;
}
if(!isset($params['type_mode_graph'])){
//$config['type_mode_graph']
$params['type_mode_graph'] = 0;
}
$params['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 background_color = params.backgroundColor;
var legend_color = params.legend_color;
var update_legend = false;
var update_legend = {};
//XXXXXX colocar
var force_integer = 0;
@ -1554,8 +1554,10 @@ function pandoraFlotArea( graph_id, values, legend,
break;
}
if(value.slice_data){
update_legend = value.slice_data;
if(series_type[index] != 'boolean'){
if(value.slice_data){
update_legend[index] = value.slice_data;
}
}
//in graph stacked unset percentil
@ -1973,14 +1975,16 @@ function pandoraFlotArea( graph_id, values, legend,
y = y_array['y'];
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
if (series_type[dataset[k]["label"]] != 'points' &&
series_type[dataset[k]["label"]] != 'unknown' &&
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')
.eq(i).html(label_aux + ' value = ' +
(short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) +
@ -1988,45 +1992,48 @@ function pandoraFlotArea( graph_id, values, legend,
);
}
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 = "";
}
$.each(update_legend, function (index, value) {
if(!value[x]){
x = x +1;
}
if(value[x].min){
min_y_array = format_unit_yaxes(value[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(value[x].max){
max_y_array = format_unit_yaxes(value[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 = "";
}
if(value[x].avg){
avg_y_array = format_unit_yaxes(value[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
);
data_legend[index] =
' 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;
});
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[3] = 'x3';
$options[4] = 'x4';
$options[5] = __('full');
$options[5] = 'x5';
$data[1] = html_print_select ($options, "zoom", $zoom, '', '', 0, true, false, false);
$table->data[] = $data;
$table->rowclass[] = '';