| 1 | <?php // content="text/plain; charset=utf-8"
 | 
|---|
| 2 | // Example for use of JpGraph, 
 | 
|---|
| 3 | // ljp, 01/03/01 19:44
 | 
|---|
| 4 | require_once ('jpgraph/jpgraph.php');
 | 
|---|
| 5 | require_once ('jpgraph/jpgraph_bar.php');
 | 
|---|
| 6 | 
 | 
|---|
| 7 | // We need some data
 | 
|---|
| 8 | $datay=array(0.3031,0.3044,0.3049,0.3040,0.3024,0.3047);
 | 
|---|
| 9 | 
 | 
|---|
| 10 | // Setup the graph. 
 | 
|---|
| 11 | $graph = new Graph(400,200);    
 | 
|---|
| 12 | $graph->img->SetMargin(60,30,30,40);
 | 
|---|
| 13 | $graph->SetScale("textlin");
 | 
|---|
| 14 | $graph->SetMarginColor("teal");
 | 
|---|
| 15 | $graph->SetShadow();
 | 
|---|
| 16 | 
 | 
|---|
| 17 | // Set up the title for the graph
 | 
|---|
| 18 | $graph->title->Set("Bargraph with small variations");
 | 
|---|
| 19 | $graph->title->SetColor("white");
 | 
|---|
| 20 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
 | 
|---|
| 21 | 
 | 
|---|
| 22 | // Setup color for axis and labels
 | 
|---|
| 23 | $graph->xaxis->SetColor("black","white");
 | 
|---|
| 24 | $graph->yaxis->SetColor("black","white");
 | 
|---|
| 25 | 
 | 
|---|
| 26 | // Setup font for axis
 | 
|---|
| 27 | $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
 | 
|---|
| 28 | $graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
 | 
|---|
| 29 | 
 | 
|---|
| 30 | // Setup X-axis title (color & font)
 | 
|---|
| 31 | $graph->xaxis->title->Set("X-axis");
 | 
|---|
| 32 | $graph->xaxis->title->SetColor("white");
 | 
|---|
| 33 | $graph->xaxis->title->SetFont(FF_VERDANA,FS_BOLD,10);
 | 
|---|
| 34 | 
 | 
|---|
| 35 | // Create the bar pot
 | 
|---|
| 36 | $bplot = new BarPlot($datay);
 | 
|---|
| 37 | $bplot->SetWidth(0.6);
 | 
|---|
| 38 | 
 | 
|---|
| 39 | // Setup color for gradient fill style 
 | 
|---|
| 40 | $tcol=array(100,100,255);
 | 
|---|
| 41 | $fcol=array(255,100,100);
 | 
|---|
| 42 | $bplot->SetFillGradient($fcol,$tcol,GRAD_HOR);
 | 
|---|
| 43 | $graph->Add($bplot);
 | 
|---|
| 44 | 
 | 
|---|
| 45 | // Finally send the graph to the browser
 | 
|---|
| 46 | $graph->Stroke();
 | 
|---|
| 47 | ?>
 | 
|---|