[ Index ] |
|
Code source de jpGraph 2.2 |
1 <?php 2 include ("../jpgraph.php"); 3 include ("../jpgraph_line.php"); 4 5 // Callback to negate the argument 6 function _cb_negate($aVal) { 7 return round(-$aVal); 8 } 9 10 // A fake depth curve 11 $ydata = array(0,1,4,5,8,9,10,14,16,16,16,18,20,20,20,22,22.5,22,19,19,15,15,15,15,10,10,10,6,5,5,5,4,4,2,1,0); 12 13 $n = count($ydata); 14 $y2data = array(); 15 for( $i=0; $i< $n; ++$i ) { 16 $y2data[] = $ydata[$i]+10; 17 } 18 19 // Negate all data 20 $n = count($ydata); 21 for($i=0; $i<$n; ++$i) { 22 $ydata[$i] = round(-$ydata[$i]); 23 $y2data[$i] = round(-$y2data[$i]); 24 } 25 26 // Basic graph setup 27 $graph = new Graph(400,300,"auto"); 28 $graph->SetScale("linlin"); 29 $graph->SetY2Scale("lin"); 30 $graph->SetMargin(50,50,60,40); 31 $graph->SetMarginColor('darkblue'); 32 $graph->SetColor('darkblue'); 33 34 // Setup titles 35 $graph->title->Set("Inverting both Y-axis"); 36 $graph->title->SetFont(FF_FONT1,FS_BOLD); 37 $graph->title->SetColor("white"); 38 39 $graph->subtitle->Set("(Negated Y & Y2 axis)"); 40 $graph->subtitle->SetFont(FF_FONT1,FS_NORMAL); 41 $graph->subtitle->SetColor("white"); 42 43 // Setup axis 44 $graph->yaxis->SetLabelFormatCallback("_cb_negate"); 45 $graph->xaxis->SetColor("lightblue","white"); 46 $graph->yaxis->SetColor("lightblue","white"); 47 $graph->ygrid->SetColor("blue"); 48 49 // Setup Y2 axis 50 $graph->y2axis->SetLabelFormatCallback("_cb_negate"); 51 $graph->y2axis->SetColor("darkred","white"); 52 $graph->y2scale->SetAutoMax(0); // To make sure it starts with 0 53 54 // Setup plot 1 55 $lp1 = new LinePlot($ydata); 56 $lp1->SetColor("yellow"); 57 $lp1->SetWeight(2); 58 $graph->Add($lp1); 59 60 // Setup plot 2 61 $lp2 = new LinePlot($y2data); 62 $lp2->SetColor("darkred"); 63 $lp2->SetWeight(2); 64 $graph->AddY2($lp2); 65 66 $graph->Stroke(); 67 ?> 68 69
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:27:55 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |