[ Index ] |
|
Code source de jpGraph 2.2 |
1 <?php 2 // $Id: barscalecallbackex1.php,v 1.2 2002/07/11 23:27:28 aditus Exp $ 3 include ("../jpgraph.php"); 4 include ("../jpgraph_bar.php"); 5 6 // Callback function for Y-scale 7 function yScaleCallback($aVal) { 8 return number_format($aVal); 9 } 10 11 // Some data 12 $datay=array(120567,134013,192000,87000); 13 14 // Create the graph and setup the basic parameters 15 $graph = new Graph(460,200,'auto'); 16 $graph->img->SetMargin(80,30,30,40); 17 $graph->SetScale("textint"); 18 $graph->SetShadow(); 19 $graph->SetFrame(false); // No border around the graph 20 21 // Add some grace to the top so that the scale doesn't 22 // end exactly at the max value. 23 // Since we are using integer scale the gace gets intervalled 24 // to adding integer values. 25 // For example grace 10 to 100 will add 1 to max, 101-200 adds 2 26 // and so on... 27 $graph->yaxis->scale->SetGrace(30); 28 $graph->yaxis->SetLabelFormatCallback('yScaleCallback'); 29 30 // Setup X-axis labels 31 $a = $gDateLocale->GetShortMonth(); 32 $graph->xaxis->SetTickLabels($a); 33 $graph->xaxis->SetFont(FF_FONT2); 34 35 // Setup graph title ands fonts 36 $graph->title->Set("Example of Y-scale callback formatting"); 37 $graph->title->SetFont(FF_FONT2,FS_BOLD); 38 $graph->xaxis->title->Set("Year 2002"); 39 $graph->xaxis->title->SetFont(FF_FONT2,FS_BOLD); 40 41 // Create a bar pot 42 $bplot = new BarPlot($datay); 43 $bplot->SetFillColor("orange"); 44 $bplot->SetWidth(0.5); 45 $bplot->SetShadow(); 46 47 // Setup the values that are displayed on top of each bar 48 $bplot->value->Show(); 49 // Must use TTF fonts if we want text at an arbitrary angle 50 $bplot->value->SetFont(FF_ARIAL,FS_BOLD); 51 $bplot->value->SetAngle(45); 52 $bplot->value->SetFormat('$ %0.0f'); 53 // Black color for positive values and darkred for negative values 54 $bplot->value->SetColor("black","darkred"); 55 $graph->Add($bplot); 56 57 // Finally stroke the graph 58 $graph->Stroke(); 59 ?>
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 |
![]() |