[42] | 1 | <?php // content="text/plain; charset=utf-8"
|
---|
| 2 | // Example for use of JpGraph,
|
---|
| 3 | require_once ('jpgraph/jpgraph.php');
|
---|
| 4 | require_once ('jpgraph/jpgraph_bar.php');
|
---|
| 5 |
|
---|
| 6 | // We need some data
|
---|
| 7 | $datay=array(0.13,0.25,0.21,0.35,0.31,0.06);
|
---|
| 8 | $datax=array("January","February","March","April","May","June");
|
---|
| 9 |
|
---|
| 10 | // Setup the graph.
|
---|
| 11 | $graph = new Graph(400,240);
|
---|
| 12 | $graph->img->SetMargin(60,20,35,75);
|
---|
| 13 | $graph->SetScale("textlin");
|
---|
| 14 | $graph->SetMarginColor("lightblue:1.1");
|
---|
| 15 | $graph->SetShadow();
|
---|
| 16 |
|
---|
| 17 | // Set up the title for the graph
|
---|
| 18 | $graph->title->Set("Bar gradient with left reflection");
|
---|
| 19 | $graph->title->SetMargin(8);
|
---|
| 20 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
|
---|
| 21 | $graph->title->SetColor("darkred");
|
---|
| 22 |
|
---|
| 23 | // Setup font for axis
|
---|
| 24 | $graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
|
---|
| 25 | $graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
|
---|
| 26 |
|
---|
| 27 | // Show 0 label on Y-axis (default is not to show)
|
---|
| 28 | $graph->yscale->ticks->SupressZeroLabel(false);
|
---|
| 29 |
|
---|
| 30 | // Setup X-axis labels
|
---|
| 31 | $graph->xaxis->SetTickLabels($datax);
|
---|
| 32 | $graph->xaxis->SetLabelAngle(50);
|
---|
| 33 |
|
---|
| 34 | // Create the bar pot
|
---|
| 35 | $bplot = new BarPlot($datay);
|
---|
| 36 | $bplot->SetWidth(0.6);
|
---|
| 37 |
|
---|
| 38 | // Setup color for gradient fill style
|
---|
| 39 | $bplot->SetFillGradient("navy:0.9","navy:1.85",GRAD_LEFT_REFLECTION);
|
---|
| 40 |
|
---|
| 41 | // Set color for the frame of each bar
|
---|
| 42 | $bplot->SetColor("white");
|
---|
| 43 | $graph->Add($bplot);
|
---|
| 44 |
|
---|
| 45 | // Finally send the graph to the browser
|
---|
| 46 | $graph->Stroke();
|
---|
| 47 | ?>
|
---|