1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | //$Id: pieex7.php,v 1.1 2002/06/17 13:53:43 aditus Exp $ |
---|
3 | require_once ('jpgraph/jpgraph.php'); |
---|
4 | require_once ('jpgraph/jpgraph_pie.php'); |
---|
5 | |
---|
6 | // Some data |
---|
7 | $data = array(27,23,0,17); |
---|
8 | |
---|
9 | // A new graph |
---|
10 | $graph = new PieGraph(350,200); |
---|
11 | $graph->SetShadow(); |
---|
12 | |
---|
13 | // Setup title |
---|
14 | $graph->title->Set("Pie plot with absolute labels"); |
---|
15 | $graph->subtitle->Set('(With hidden 0 labels)'); |
---|
16 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
17 | |
---|
18 | // The pie plot |
---|
19 | $p1 = new PiePlot($data); |
---|
20 | |
---|
21 | |
---|
22 | // Move center of pie to the left to make better room |
---|
23 | // for the legend |
---|
24 | $p1->SetCenter(0.35,0.5); |
---|
25 | |
---|
26 | // No border |
---|
27 | $p1->ShowBorder(false); |
---|
28 | |
---|
29 | // Label font and color setup |
---|
30 | $p1->value->SetFont(FF_FONT1,FS_BOLD); |
---|
31 | $p1->value->SetColor("darkred"); |
---|
32 | |
---|
33 | // Use absolute values (type==1) |
---|
34 | $p1->SetLabelType(PIE_VALUE_ABS); |
---|
35 | |
---|
36 | // Label format |
---|
37 | $p1->value->SetFormat("$%d"); |
---|
38 | $p1->value->HideZero(); |
---|
39 | $p1->value->Show(); |
---|
40 | |
---|
41 | // Size of pie in fraction of the width of the graph |
---|
42 | $p1->SetSize(0.3); |
---|
43 | |
---|
44 | // Legends |
---|
45 | $p1->SetLegends(array("May ($%d)","June ($%d)","July ($%d)","Aug ($%d)")); |
---|
46 | $graph->legend->Pos(0.05,0.2); |
---|
47 | |
---|
48 | $graph->Add($p1); |
---|
49 | $graph->Stroke(); |
---|
50 | ?> |
---|
51 | |
---|
52 | |
---|