[ Index ] |
|
Code source de jpGraph 2.2 |
1 <?php 2 include ("../jpgraph.php"); 3 include ("../jpgraph_bar.php"); 4 5 $datay=array(2,3,5,8,12,6,3); 6 $datax=array("Jan","Feb","Mar","Apr","May","Jun","Jul"); 7 8 $width=400; 9 $height=500; 10 11 // Set the basic parameters of the graph 12 $graph = new Graph($width,$height,'auto'); 13 $graph->SetScale("textlin"); 14 15 $top = 80; 16 $bottom = 30; 17 $left = 50; 18 $right = 30; 19 $graph->Set90AndMargin($left,$right,$top,$bottom); 20 21 // Nice shadow 22 $graph->SetShadow(); 23 24 // Setup title 25 $graph->title->Set("Horizontal bar graph ex 2"); 26 $graph->title->SetFont(FF_VERDANA,FS_BOLD,14); 27 $graph->subtitle->Set("(Axis at top)"); 28 29 // Setup X-axis 30 $graph->xaxis->SetTickLabels($datax); 31 $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,12); 32 33 // Some extra margin looks nicer 34 $graph->xaxis->SetLabelMargin(5); 35 36 // Label align for X-axis 37 $graph->xaxis->SetLabelAlign('right','center'); 38 39 // Add some grace to y-axis so the bars doesn't go 40 // all the way to the end of the plot area 41 $graph->yaxis->scale->SetGrace(20); 42 $graph->yaxis->SetLabelAlign('center','bottom'); 43 $graph->yaxis->SetLabelAngle(45); 44 $graph->yaxis->SetLabelFormat('%d'); 45 $graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,12); 46 47 // We don't want to display Y-axis 48 //$graph->yaxis->Hide(); 49 50 // Now create a bar pot 51 $bplot = new BarPlot($datay); 52 $bplot->SetFillColor("orange"); 53 $bplot->SetShadow(); 54 55 //You can change the width of the bars if you like 56 //$bplot->SetWidth(0.5); 57 58 // We want to display the value of each bar at the top 59 $bplot->value->Show(); 60 $bplot->value->SetFont(FF_ARIAL,FS_BOLD,12); 61 $bplot->value->SetAlign('left','center'); 62 $bplot->value->SetColor("black","darkred"); 63 $bplot->value->SetFormat('%.1f mkr'); 64 65 // Add the bar to the graph 66 $graph->Add($bplot); 67 68 69 $graph->Stroke(); 70 ?>
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 |
![]() |