2
// $Id: barscalecallbackex1.php,v 1.2 2002/07/11 23:27:28 aditus Exp $
3
include ("../jpgraph.php");
4
include ("../jpgraph_bar.php");
6
// Callback function for Y-scale
7
function yScaleCallback($aVal) {
8
return number_format($aVal);
12
$datay=array(120567,134013,192000,87000);
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");
19
$graph->SetFrame(false); // No border around the graph
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
27
$graph->yaxis->scale->SetGrace(30);
28
$graph->yaxis->SetLabelFormatCallback('yScaleCallback');
30
// Setup X-axis labels
31
$a = $gDateLocale->GetShortMonth();
32
$graph->xaxis->SetTickLabels($a);
33
$graph->xaxis->SetFont(FF_FONT2);
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);
42
$bplot = new BarPlot($datay);
43
$bplot->SetFillColor("orange");
44
$bplot->SetWidth(0.5);
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");
57
// Finally stroke the graph