Hola espero me puedan ayudar , estoy utilizando Highcharts js y necesito graficar una serie de tiempo de una consulta a una base de datos , son aproximadamente 1000 datos y cada dato es de cada minuto
tengo un archivo php con el cual consulto la base y obtengo los registros
data.php
Código PHP:
Ver original$usuario = '******';
$contrasenia = '****';
try {
$db = new PDO('pgsql:host=localhost;dbname=****',$usuario,$contrasenia);
//$db = new PDO('pgsql:host=192.168.102.200;dbname=volcanoes',$usuario,$contrasenia);
}catch(PDOException $e) {
//echo $e->getMessage();
echo "Usuario y Clave Invalidas";
throw new Exception("Usuario y Clave Invalidas", 0, $e);
}
$consulta = $db->prepare("SELECT * FROM anemometro");
$consulta->execute();
while($fila = $consulta->fetch(PDO::FETCH_ASSOC))
{
echo $fila['fecha'].$fila['hora']. "\t" . $fila['temperatura']. "\n";
}
esta ahi todo va bien , el proble inicia para graficar la serie de tiempo , hasta el momento este es mi codigo
index.php
Código PHP:
Ver original$(function () {
$('#container').highcharts({
chart: {
zoomType: 'x',
spacingRight: 20
},
title: {
text: 'Metereologica'
},
xAxis: {
type: 'datetime',
maxZoom: 14 * 24 * 3600000, // fourteen days
title: {
text: null
}
},
yAxis: {
title: {
text: 'Temperatura'
}
},
plotOptions: {
area: {
fillColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
lineWidth: 1,
marker: {
enabled: false
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
/* como obtengo el archivo php para graficar los datos*/
series: [{
type: 'area',
pointInterval: 24 * 3600 * 1000,
pointStart
: Date.UTC
(2006, 0, 01), data: [ ]
}]
});
});