AJAX - Problema HighCharts

 
Vista:
sin imagen de perfil

Problema HighCharts

Publicado por Matias (1 intervención) el 28/06/2014 01:59:51
Buenas noches, me comunico con ustedes para consultarles, ya que llevo mas de 3 dias renegando y no consigo la solucion a mi problema, el cual consiste en graficar la unos valores en funcion de la fecha que levanto de un servidor mysql.

Les adjunto el codigo para que lo vean

grafic.php --------------------->

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Highcharts Example</title>
 
<!--		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> -->
<script type="text/javascript" src="../../js/jquery.min.js"></script>
 
		<script type="text/javascript">
 
 
 
$(document).ready(
		    function() {
			var options = {
		    chart: {
			type: 'line',
	                renderTo: 'container',
	                plotBackgroundColor: null,
	                plotBorderWidth: null,
	                plotShadow: false,
	                zoomType: 'x',
//			spacingRight: 20
 
	            },
	            title: {
	                text: 'Grafico de Servicios'
	            },
 
//Aca le agregue	  
/*
	    xAxis: {
		type: 'datetime',
		
		                dateTimeLabelFormats: {
                    day: '%m-%d'
                },
		
	  ordinal: true,	
		title: {
		    text: 'Date'
			    }
			},	    
		    */
 
 
        xAxis: {
            type: 'datetime',
            tickPixelInterval: 150,
            maxZoom: 20 * 1000
        },
 
 
 
            yAxis: {
                title: {
                    text: 'Tiempo en (ms)'
                },
//                min: 0
            },
// aca le agregue	            
 
	    tooltip: {
 
			enabled: true,
 
			formatter: function() {
/*				      return '<b>'+ this.series.name +' </b>' + this.y + ' ms' + '<br/>'+
					  Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.value) +'<br/>';
*/
 
return Highcharts.dateFormat('%a %d %b %H:%M:%S', this.x);
 
					    }
	            },
 
	            series: [{
 
			name: 'SSH',
			data: []
	            },
			    {
//	                type: 'line',
	                name: 'PING',
	                data: []
	            },
			    {
//	                type: 'line',
	                name: 'HTTP',
	                data: []
 
	            }
 
	            ]
 
	        }
 
	        $.getJSON("<?php echo SITEURL?>/modules/data.php?servicio=SSH",
 
	        function(json) {
				options.series[0].data = json;
	        	chart = new Highcharts.Chart(options);
 
	        });
 
	        $.getJSON("<?php echo SITEURL?>/modules/data.php?servicio=PING",
 
	        function(json) {
				options.series[1].data = json;
	        	chart = new Highcharts.Chart(options);
	        });
 
		$.getJSON("<?php echo SITEURL?>/modules/data.php?servicio=HTTP",
 
	        function(json) {
				options.series[2].data = json;
	        	chart = new Highcharts.Chart(options);
	        });
 
      	});
 
 
 
		</script>
	</head>
	<body>
		<script src="<?php echo SITEURL?>/js/highcharts.js"></script>
		<script src="<?php echo SITEURL?>/js/exporting.js"></script>
 
<div id="container" style="min-width: 500px; height: 500px; margin: 0 auto"></div>
 
	</body>
</html>


data.php --------------------------------->

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
 
$con = mysql_connect("localhost","root","root");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
 
mysql_select_db("controlcubas", $con);
 
$servicio=$_GET["servicio"]; //tomo el dato de servicio para enviarlo al graficoador grafic.php
 
$result = mysql_query("SELECT fecha, RTT FROM alarmas_historial WHERE servicio='$servicio'");
 
$rows = array();
 
while($r = mysql_fetch_array($result))
{
 
$date = date_create($r[0]);
 
	$row[0]= date_format($date, 'H:i:s');
 
	$row[1] = $r[1]; //fecha
 
	array_push($rows,$row);
}
 
 
 
 
 
print json_encode($rows, JSON_NUMERIC_CHECK);
 
 
mysql_close($con);
 
?>
 
 
<?php
/*
$con = mysql_connect("localhost","root","root");

if (!$con) {
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("controlcubas", $con);

$sth = mysql_query("SELECT servicio, RTT FROM alarmas_historial WHERE servicio='SSH'");
$rows = array();
//$rows['name'] = 'Revenue';
while($r = mysql_fetch_array($sth)) {
	$rows[0] = $r[0]; // servicio
	$rows[1] = $r[1]; //RTT
}

$sth = mysql_query("SELECT * FROM alarmas_historial");
$rows1 = array();
//$rows1['name'] = 'Overhead';
while($rr = mysql_fetch_assoc($sth)) {
//	$rows1[1] = $rr[0]; // servicio
	$rows1[0] = $rr[1]; //RTT
}

$result = array();
array_push($result,$rows);
//array_push($result,$rows1);

print json_encode($result, JSON_NUMERIC_CHECK);

mysql_close($con);
*/
?>

Muchas gracias!!!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder