1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <?php
require_once ("../include/jpgraph/jpgraph.php"); // à adapter en fonction de ton arborescence
require_once ('../include/jpgraph/jpgraph_scatter.php'); // idem
$valeur_limite='15';
// création d'un tableau de valeurs aléatoires
$datax[0]=0;
$datay[0]=$valeur_limite;
for ($indice=1;$indice<100;$indice++)
{
$datax[$indice]=$indice;
$datay[$indice]=max(0,$datay[$indice-1]-1+rand(0,2));
}
$y1_data = array();
$y2_data = array();
$x1_data = array();
$x2_data = array();
$nb_val=sizeof($datay);
for($i=0;$i<$nb_val;$i++)
{
if ($datay[$i]<=$valeur_limite)
{
$y1_data[]=$datay[$i];
$x1_data[]=$datax[$i];
}
else
{
$y2_data[]=$datay[$i];
$x2_data[]=$datax[$i];
}
}
$graph = new Graph(600,200);
$graph->SetScale("linlin");
$graph->img->SetMargin(40,40,40,40);
$graph->SetShadow();
$graph->title->Set("A simple scatter plot");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$sp1 = new ScatterPlot($y1_data,$x1_data);
$sp2 = new ScatterPlot($y2_data,$x2_data);
$graph->Add($sp1);
$graph->Add($sp2);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("green");
$sp1->mark->SetWidth(2);
$sp2->mark->SetType(MARK_FILLEDCIRCLE);
$sp2->mark->SetFillColor("red");
$sp2->mark->SetWidth(2);
$sp2->SetImpuls();
$sp2->SetColor("red");
$graph->Stroke();
?> |
Partager