From 057b3cfcdcc5ebe04efb739fe7ceaddc998396fe Mon Sep 17 00:00:00 2001
From: Alejandro Gallardo Escobar <alex@artica.es>
Date: Mon, 6 Jun 2016 17:01:34 +0200
Subject: [PATCH] Now avg_only is enabled by default in stat_win.php and errors
 fixed. Ticket #3778 (cherry picked from commit
 8000b55a683ce74d4d77a6b7cf45c97b5b6cd6b5)

---
 .../include/graphs/flot/pandora.flot.js       | 19 +++++++------------
 .../include/graphs/functions_flot.php         |  4 ++--
 .../operation/agentes/stat_win.php            |  4 +---
 3 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js
index 5bd1f6893a..0eb12c3eb2 100644
--- a/pandora_console/include/graphs/flot/pandora.flot.js
+++ b/pandora_console/include/graphs/flot/pandora.flot.js
@@ -2011,10 +2011,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
 	if (menu) {
 		var parent_height;
 		$('#menu_overview_' + graph_id).click(function() {
-			if ( $('#overview_' + graph_id).css('visibility') == 'hidden' )
-				$('#overview_' + graph_id).css('visibility','visible');
-			else
-				$('#overview_' + graph_id).css('visibility','hidden');
+			$('#overview_' + graph_id).toggle();
 		});
 
 		$('#menu_export_csv_' + graph_id).click(function() {
@@ -2181,14 +2178,12 @@ function get_event_details (event_ids) {
 }
 
 function adjust_left_width_canvas(adapter_id, adapted_id) {
-	adapter_left_margin = $('#'+adapter_id+' .yAxis .tickLabel').css('width');
-
-	adapted_pix = $('#'+adapted_id).css('width').split('px');
-	new_adapted_width = parseInt(adapted_pix[0])-parseInt(adapter_left_margin);
-
-	$('#'+adapted_id).css('width',new_adapted_width);
-
-	$('#'+adapted_id).css('margin-left',adapter_left_margin);
+	var adapter_left_margin = $('#'+adapter_id+' .yAxis .tickLabel').width();
+	var adapted_pix = $('#'+adapted_id).width();
+	var new_adapted_width = adapted_pix - adapter_left_margin;
+	
+	$('#'+adapted_id).width(new_adapted_width);
+	$('#'+adapted_id).css('margin-left', adapter_left_margin);
 }
 
 function check_adaptions(graph_id) {
diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php
index 209a12f84a..ca8a805ef5 100644
--- a/pandora_console/include/graphs/functions_flot.php
+++ b/pandora_console/include/graphs/functions_flot.php
@@ -249,8 +249,8 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
 	else {
 		$height = 1;
 	}
-	if ( $dashboard == false AND $vconsole == false )
-		$return .= "<div id='overview_$graph_id' class='overview_graph' style='visibility: hidden; margin-left:0px; margin-top:20px; width: ".$width."px; height: ".$height ."px;'></div>";
+	if (!$dashboard && !$vconsole)
+		$return .= "<div id='overview_$graph_id' class='overview_graph' style='display: none; margin-left:0px; margin-top:20px; width: ".$width."px; height: ".$height ."px;'></div>";
 	
 	if ($water_mark != '') {
 		$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php
index fc0918cf8a..57c1787daf 100644
--- a/pandora_console/operation/agentes/stat_win.php
+++ b/pandora_console/operation/agentes/stat_win.php
@@ -134,7 +134,7 @@ $id = get_parameter('id');
 		}
 		
 		$draw_alerts = get_parameter("draw_alerts", 0);
-		$avg_only = get_parameter ("avg_only", 0);
+		$avg_only = get_parameter ("avg_only", 1);
 		$show_other = (bool)get_parameter('show_other', false);
 		if ($show_other) {
 			$avg_only = 0;
@@ -497,8 +497,6 @@ ui_include_time_picker(true);
 	
 	$.datepicker.setDefaults($.datepicker.regional["<?php echo $custom_user_language; ?>"]);
 	
-	forced_title_callback();
-	
 	$(window).ready(function() {
 		$("#field_list").css('height', ($(window).height() - 160) + 'px');
 	});