par
rarnold » 10 mars 2006, 10:21
Voici le script en php en question!
<?
foreach ($_POST as $key => $value) $$key = addslashes($value);
foreach ($_GET as $key => $value) $$key = addslashes($value);
?>
<?
include ( "/usr/local/share/jpgraph/jpgraph.php");
include ("/usr/local/share/jpgraph/jpgraph_line.php");
// The callback that converts timestamp to minutes and seconds
function TimeCallback($aVal) {
return Date('H:i:s',$aVal);
}
if ($nomfile == "")
{
echo("<h3>Le champ nom est vide !</h3>");
$valide = false;
}
else
{
$readfile = file($nomfile);
}
for ($k=1; $k<=count($readfile)-1; $k++)
{
$fields = split("\t",$readfile[$k]);
$temps[] = $fields[0]*60;
$powerc[] = $fields[1];
$power[] = $fields[2];
$presc[] = $fields[3];
$press[] = $fields[4];
$temp[] = $fields[5];
$depla[]= $fields[6]/10;
}
//$delta_t = $temps[1]-$temps[0]
//Set data to plot
switch($plot1)
{
case 0:
$ydata = $power;
break;
case 1:
$ydata = $temp;
break;
case 2:
$ydata = $press;
break;
case 3:
$ydata = $presc;
break;
case 4:
$ydata = $powerc;
break;
case 5:
$ydata = $depla;
break;
}
switch($plot2)
{
case 0:
$y2data = $power;
break;
case 1:
$y2data = $temp;
break;
case 2:
$y2data = $press;
break;
case 3:
$y2data = $presc;
break;
case 4:
$y2data = $powerc;
break;
case 5:
$y2data = $depla;
break;
}
// Create the graph. These two calls are always required
$graph = new Graph(750,375,"auto");
$graph->img->SetMargin(50,100,50,75);
//$graph->SetScale("textlin");
$graph->SetScale("linlin");
$graph->SetShadow();
$interval=$k/10;
$graph->xaxis->SetTextTickInterval($interval,1);
$graph->SetY2Scale("lin");
// Create the linear plot
$xdata=$temps;
$lineplot=new LinePlot($ydata,$xdata);
$lineplot2=new LinePlot($y2data,$xdata);
switch($plot1)
{
case 0:
$lineplot ->SetLegend("P(W)");
break;
case 1:
$lineplot ->SetLegend("T(C)");
break;
case 2:
$lineplot ->SetLegend("P(bar)");
break;
case 3:
$lineplot ->SetLegend("Pc(bar)");
break;
case 4:
$lineplot ->SetLegend("Pc(W)");
break;
case 5:
$lineplot ->SetLegend("d(mm)");
break;
}
switch($plot2)
{
case 0:
$lineplot2 ->SetLegend("P(W)");
break;
case 1:
$lineplot2 ->SetLegend("T(C)");
break;
case 2:
$lineplot2 ->SetLegend("P(bar)");
break;
case 3:
$lineplot2 ->SetLegend("Pc(bar)");
break;
case 4:
$lineplot2 ->SetLegend("Pc(W)");
break;
case 5:
$lineplot2 ->SetLegend("d(mm)");
break;
}
$graph ->legend->Pos( 0.01,0.5,"right" ,"center");
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
$graph->y2axis->SetColor("orange");
$graph->title->Set("Belt parameters ON LINE");
//$graph->xaxis->title->Set("Time x step ");
//$graph->yaxis->title->Set("Belt on line");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetLabelFormatCallback('TimeCallback');
$graph->xaxis->SetLabelAngle(90);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
$graph->yaxis->SetColor("blue");// Display the graph
$graph->Stroke();
//$graph ->Stroke("/usr/home/peter/images/result2002.png" );
?>
Je désir en fait permettreaux utilisateurs de ce script de ne plus avoir a faire un copie coller du nom du fichier TXT!
Je voudrais rajouter dans ce code: une varible permettant de choisir un ensemble de fichier TXT présent dans un repertoire de mon hébergeur!
par exemple:
chemin:
www.monsite.com/fichier.php
irait sur le répertoire de stockage des fichiers txt :
www.monsite.com/fichier_txt/....
Dans se liens se trouverez en fait la liste complète des fichiers en txt.
Le code en question permettrrais juste de lire en temps réel la liste des fichiers présent dans le dossier de stockage et établirer un menu déroulant ou toute les donnée txt apparaitrai voilà!
je sais pas si je me suis bien fais comprendre ??
et si biensur cela est possible je sais que c'est possible en html en créant un formulaire et en rentrant chaque valeur a la main et c'est justement ca que je veus eviter!
Voici le script en php en question!
[php]<?
foreach ($_POST as $key => $value) $$key = addslashes($value);
foreach ($_GET as $key => $value) $$key = addslashes($value);
?>
<?
include ( "/usr/local/share/jpgraph/jpgraph.php");
include ("/usr/local/share/jpgraph/jpgraph_line.php");
// The callback that converts timestamp to minutes and seconds
function TimeCallback($aVal) {
return Date('H:i:s',$aVal);
}
if ($nomfile == "")
{
echo("<h3>Le champ nom est vide !</h3>");
$valide = false;
}
else
{
$readfile = file($nomfile);
}
for ($k=1; $k<=count($readfile)-1; $k++)
{
$fields = split("\t",$readfile[$k]);
$temps[] = $fields[0]*60;
$powerc[] = $fields[1];
$power[] = $fields[2];
$presc[] = $fields[3];
$press[] = $fields[4];
$temp[] = $fields[5];
$depla[]= $fields[6]/10;
}
//$delta_t = $temps[1]-$temps[0]
//Set data to plot
switch($plot1)
{
case 0:
$ydata = $power;
break;
case 1:
$ydata = $temp;
break;
case 2:
$ydata = $press;
break;
case 3:
$ydata = $presc;
break;
case 4:
$ydata = $powerc;
break;
case 5:
$ydata = $depla;
break;
}
switch($plot2)
{
case 0:
$y2data = $power;
break;
case 1:
$y2data = $temp;
break;
case 2:
$y2data = $press;
break;
case 3:
$y2data = $presc;
break;
case 4:
$y2data = $powerc;
break;
case 5:
$y2data = $depla;
break;
}
// Create the graph. These two calls are always required
$graph = new Graph(750,375,"auto");
$graph->img->SetMargin(50,100,50,75);
//$graph->SetScale("textlin");
$graph->SetScale("linlin");
$graph->SetShadow();
$interval=$k/10;
$graph->xaxis->SetTextTickInterval($interval,1);
$graph->SetY2Scale("lin");
// Create the linear plot
$xdata=$temps;
$lineplot=new LinePlot($ydata,$xdata);
$lineplot2=new LinePlot($y2data,$xdata);
switch($plot1)
{
case 0:
$lineplot ->SetLegend("P(W)");
break;
case 1:
$lineplot ->SetLegend("T(C)");
break;
case 2:
$lineplot ->SetLegend("P(bar)");
break;
case 3:
$lineplot ->SetLegend("Pc(bar)");
break;
case 4:
$lineplot ->SetLegend("Pc(W)");
break;
case 5:
$lineplot ->SetLegend("d(mm)");
break;
}
switch($plot2)
{
case 0:
$lineplot2 ->SetLegend("P(W)");
break;
case 1:
$lineplot2 ->SetLegend("T(C)");
break;
case 2:
$lineplot2 ->SetLegend("P(bar)");
break;
case 3:
$lineplot2 ->SetLegend("Pc(bar)");
break;
case 4:
$lineplot2 ->SetLegend("Pc(W)");
break;
case 5:
$lineplot2 ->SetLegend("d(mm)");
break;
}
$graph ->legend->Pos( 0.01,0.5,"right" ,"center");
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
$graph->y2axis->SetColor("orange");
$graph->title->Set("Belt parameters ON LINE");
//$graph->xaxis->title->Set("Time x step ");
//$graph->yaxis->title->Set("Belt on line");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetLabelFormatCallback('TimeCallback');
$graph->xaxis->SetLabelAngle(90);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
$graph->yaxis->SetColor("blue");// Display the graph
$graph->Stroke();
//$graph ->Stroke("/usr/home/peter/images/result2002.png" );
?>
[/php]
Je désir en fait permettreaux utilisateurs de ce script de ne plus avoir a faire un copie coller du nom du fichier TXT!
Je voudrais rajouter dans ce code: une varible permettant de choisir un ensemble de fichier TXT présent dans un repertoire de mon hébergeur!
par exemple:
chemin:www.monsite.com/fichier.php
irait sur le répertoire de stockage des fichiers txt :www.monsite.com/fichier_txt/....
Dans se liens se trouverez en fait la liste complète des fichiers en txt.
Le code en question permettrrais juste de lire en temps réel la liste des fichiers présent dans le dossier de stockage et établirer un menu déroulant ou toute les donnée txt apparaitrai voilà!
je sais pas si je me suis bien fais comprendre ??
et si biensur cela est possible je sais que c'est possible en html en créant un formulaire et en rentrant chaque valeur a la main et c'est justement ca que je veus eviter!