Ver Mensaje Individual
  #6 (permalink)  
Antiguo 30/03/2011, 05:12
Oracles
 
Fecha de Ingreso: septiembre-2008
Ubicación: Valencia
Mensajes: 160
Antigüedad: 15 años, 7 meses
Puntos: 2
Respuesta: ¿Como situar valor varchar como categories en grafica?

Si lo quieres aquí lo tienes lo he ido modificando desde el primer post estoy haciendo pruebas por mi cuenta

Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php
include('../Datos.php');
$user = 'xxx';
$pass = 'xxx';
$url = 'localhost';
$con = mysql_connect($url,$user,$pass);
mysql_select_db('Meteo',$con);
$resultado1= mysql_query("SELECT * FROM Regsitros WHERE( Fecha ='$Dia') ORDER BY Hora ASC",$con);
$row = mysql_fetch_array($resultado1); 
$resultado2 = $row['Fecha'];
$z = 0;
$total = mysql_num_rows($resultado1);
$total2 = $total++;
/*---------------------*/
while ($z < $total2){
$hora[$z] = mysql_result($resultado1, $z, 'Hora');
$z++;
if ($z == $total2){
	$z = 0;
	break;
	}
}
/*---------------------*/
while ($z < $total2){
$temperatura[$z] = mysql_result($resultado1, $z, 'Temperatura');
$z++;
if ($z == $total2){
	$z = 0;
	break;
	}
}
/*---------------------*/
while ($z < $total2){
$sensacio[$z] = mysql_result($resultado1, $z, 'SensacionTermica');
$z++;
}
$x=0;
while($x<$z){
	$temperatura[$x];
	$temp[$x] = $temperatura[$x].',';
	$x++;
	}
$x=0;
while($x<$z){
	$sensacio[$x];
	$sens[$x] = $sensacio[$x].','; 
	$x++;
	}
$x=0;
while($x<$z){
	$hora[$x];
	$h[$x] = $hora[$x].','; 
	$x++;
	}
$x=0;
?>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Gráfica Tempertaura - IES La Vereda (La Pobla de Vallbona)</title>
		
		
		<!-- 1. Add these JavaScript inclusions in the head of your page -->
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
		<script type="text/javascript" src="highcharts.js"></script>
		
		<!-- 1a) Optional: add a theme file -->
		<!--
			<script type="text/javascript" src="../js/themes/gray.js"></script>
		-->
		
		<!-- 1b) Optional: the exporting module -->
		<script type="text/javascript" src="../js/modules/exporting.js"></script>
		
		
		<!-- 2. Add the JavaScript to initialize the chart on document ready -->
		<script type="text/javascript">
		
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container',
						defaultSeriesType: 'spline'
					},
					title: {
						text: 'Temperatura del <?=$resultado2;?>'
					},
					subtitle: {
						text: 'Temperatura en Cº en La Pobla de Vallbona'
					},
					xAxis: {
						categories: ['0','<?=$h[$x];?>']
					},
					yAxis: {
						title: {
							text: 'Temperatura Cº'
						},
						labels: {
							formatter: function() {
								return this.value +'°'
							}
						}
					},
					tooltip: {
						crosshairs: true,
						shared: true
					},
					plotOptions: {
						spline: {
							marker: {
								radius: 4,
								lineColor: '#666666',
								lineWidth: 1
							}
						}
					},
					series: [{
						name: 'Sensación Térmica',
						marker: {
							symbol: 'circle'
						},
						data: [{
							y: 0,
							marker: {
								symbol: 'url(min.png)'
							}
						},<?=$sens[$x];?>]
				
					}, {
						name: 'Temperatura',
						marker: {
							symbol: 'square'
						},
						data: [{
							y:0,
							marker: {
								symbol: 'url(max.png)'
							}
						},<?=$temp[$x];?>]
					}]
				});
				
				
			});
				
		</script>
		
	</head>
	<body>
		
		<!-- 3. Add the container -->
		<div id="container" style="width: 800px; height: 400px; margin: 0 auto"></div>
		
				
	</body>
</html>
__________________
Siempre inmerso en nuevos proyectos.

Cuando estoy activo puedes verme en //LiveCoding