Graphe en temp reél et pour un system en temp rée - graphe en temp reél avec php

Salut ,
je veut realiser un programme qui lit des données a partire d’une base de données et affiche ces donnée sur un graphe.
ma base de donnée contient les valuer de temperatures d’un system qui fonctionne en temps réel.
je travaile avec php et mysqle et apache serveur.
j’utilise la bibliotheque jpgraphe speciale pour realiser des graphe.
le problem c que je ne parvient pas a raffraichire la page .
question:
aider moi a realiser un script qui affiche un graphe qui defile dans le temps.

Un applet Java ne serait il pas plus adapté ? :neutre:

salut voic mon scripte qui realis un graphe static a partire des données il est utile pour des graphe en temp réel
si jamais il y’a qelq '1 qui peut le rendre dynamique merci de me contacter.

reamarque:
racine est un repertoire qui contient la bibliotheque jpgraphe 1.20.5
<?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,‘chart.png’);
$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();
?>

Pas besoin de recréer un nouveau topic pour ça :jap:

pourquoi ne pas utiliser une balise meta qui recharge ta page toutes les X secondes ?
par contre si ta page est lourde tu verra plus souvent une page blanche que ton graph…

merci pour vos conseille.
une applet java je vais voire mais avant dit moi:
ta pas un algorithme qui m’aide a realiser se graphe en temp réel?
pour le raffraichissementtoute est bon j’ai put raffraichire mon grphe mais je me suis tromper dans l’idée
alors donne mois un algorithme pour dessiner un graphe qui deffile dans le temps?
voici mes progression
//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>
<body>
<?php
$i=0;
while($i<10)
{
  echo  '<img src="Genere_Graphe.php" >';
$i++;
}
?>
</body>
</html>

Sinon tu as aussi le canvas

<canvas>…</canvas>

Tu pourrais avec AJAX faire la même chose qu’avec un applet java, et éviter de surcharger ton serveur (en ne prenant que les dernières valeurs).