Rafraichissement d'une page chaque x seconde

cs_prg11 Messages postés 7 Date d'inscription dimanche 1 octobre 2006 Statut Membre Dernière intervention 11 janvier 2007 - 10 janv. 2007 à 13:31
juki_webmaster Messages postés 947 Date d'inscription mercredi 19 novembre 2003 Statut Membre Dernière intervention 5 avril 2008 - 11 janv. 2007 à 16:21
Bon voila
j'ai un problem qui me derrange dans pas mal de temps
j'ai pus arriver a realiser le code suivant avec le rafraichissement de ma page chaque seconde
 mai le problem c'est que je veut realiser un graphe qui deffile dans le temps il'n'ya pas une idée ?
aide moi a realiser ce graphe en temps réel
Question:
comment realiser un graphe qui deffile dans le temps .
l'idée ou bien un petite exempls serons utils merci.

//le script php qui crere le graphe
//Racine contient la bibliotheque jpgraphe
//Genere_Graphe.php
//remarque:
telecharger la bibliotheuq jpgraphe 1.20.5 et copier la dans le mem repertoire des 2 scriptes ces dessous et vous aller voire le resultats
 
<?php

// Example on how to treat and format timestamp as human readable labels
require_once("Racine/jpgraph.php");
require_once("Racine/jpgraph_line.php");

// Number of "fake" data points
DEFINE('NDATAPOINTS',500);

// Assume data points are sample every 10th second
DEFINE('SAMPLERATE',10);

// Callback formatting function for the X-scale to convert timestamps
// to hour and minutes.
function TimeCallback($aVal) {
    return Date('H:i', $aVal);
}

// Get start time
$start = time();
// Set the start time to be on the closest minute just before the "start" timestamp
$adjstart = floor($start);// / 60);

// Create a data set in range (20,100) and X-positions
// We also apply a simple low pass filter on the data to make it less
// random and a little smoother
$data = array();
$xdata = array();
$data[0] = rand(20,60);
$xdata[0] = $adjstart;
for( $i=1; $i < NDATAPOINTS; ++$i ) {
    $data[$i] = rand(20,100)*0.2 + $data[$i-1]*0.8;
    $xdata[$i] = $adjstart + $i * SAMPLERATE;
}

// Assume that the data points represents data that is sampled every 10s
// when determing the end value on the scale. We also add some extra
// length to end on an even label tick.
$adjend = $adjstart  + (NDATAPOINTS+10)*10;

$graph = new Graph(950,500);
$graph->SetMargin(40,20,30,50);

// Now specify the X-scale explicit but let the Y-scale be auto-scaled
$graph->SetScale("intlin",0,0,$adjstart,$adjend);
$graph->title->Set("La Température Dans La Salle Des Cuves");

// Setup the callback and adjust the angle of the labels
$graph->xaxis->SetLabelFormatCallback('TimeCallback');
$graph->xaxis->SetLabelAngle(90);

// Set the labels every 5min (i.e. 300seconds) and minor ticks every minute
$graph->xaxis->scale->ticks->Set(300,60);

$line = new LinePlot($data,$xdata);
//$line->SetColor('lightblue');
$line->SetColor('red');
$graph->Add($line);

$graph->Stroke();
?>

// contenu du fichier voire_graphe

<!doctype html public "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="refresh" content="0">
  <title>Untitled web-page</title>
</head>

<?php
$i=0;
while($i<10)
{
  echo  '';
$i++;
}
?>

</html>

3 réponses

juki_webmaster Messages postés 947 Date d'inscription mercredi 19 novembre 2003 Statut Membre Dernière intervention 5 avril 2008 3
10 janv. 2007 à 18:25
Salut,

Ton code HTML tel quel marchera moyen, fait un refresh sur 1 seconde voir 2 (le temps de generer l'image), et affiche une seul fois l'image par page.


<!doctype html public "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Refresh" content="2;URL=TA_PAGE.html">
<title>Untitled web-page</title>
</head>



</html>


Sinon utilise une
et du Javascript, pour rafrachir l'espace toute les 2 secondes. (innerHTML).
www.javascriptfr.com
0
cs_prg11 Messages postés 7 Date d'inscription dimanche 1 octobre 2006 Statut Membre Dernière intervention 11 janvier 2007
11 janv. 2007 à 11:53
salut
bon j'ai put raffraichire la page mais une question
je cherche un algorithme pour dessiner un graphe en temps reél ou bien une extension php ou bien outille web interessant tu connait pas un?
merci et a la prochaine.
0
juki_webmaster Messages postés 947 Date d'inscription mercredi 19 novembre 2003 Statut Membre Dernière intervention 5 avril 2008 3
11 janv. 2007 à 16:21
Graphe en temps reél ? un graph qui ce met à jours toutes les secondes ? dans ce cas c'est au HTML (+JS) de faire l'affichage le PHP genereras tout seul l'image. OU bien alors surcharger le serveur avec une tachcron (inutile) qui creeras une image sur le serveur (voir ob_* http://fr3.php.net/manual/en/ref.outcontrol.php ).

Je n'ai jamais eu à utiliser de Graphes en PHP, mais j'ai quelques liens :

Power Graphic : http://www.phpclasses.org/browse/package/1993.html
Sur PHPClasses.org il ya un moteur de recherche qui retourne pas mal de resultat sur 'graph'.

http://stefangabos.blogspot.com/2006/09/zebra-php-framework-php-html-graph.html
http://www.graidle.altervista.org/
http://forum.soundboss.cz/en/viewtopic.php?t=20
0
Rejoignez-nous