1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
| <?php
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_pie.php');
require_once ('jpgraph/jpgraph_pie3d.php');
$data = array(
array(80,18,15,17),
array(35,28,6,34),
array(10,28,10,5),
array(22,22,10,17));
$piepos = array(0.2,0.4,0.65,0.28,0.25,0.75,0.8,0.75);
$titles = array('USA','Sweden','South America','Australia');
$n = count($piepos)/2;
$graph = new PieGraph(550,400,'auto');
$graph->SetMargin(1,1,40,1);
$graph->SetMarginColor('navy');
$graph->SetShadow(false);
$graph->SetBackgroundImage('worldmap1.jpg',BGIMG_FILLPLOT);
$graph->title->Set("Pie plots with background image");
$graph->title->SetFont(FF_ARIAL,FS_BOLD,20);
$graph->title->SetColor('white');
$p = array();
for( $i=0; $i < $n; ++$i ) {
$d = "data$i";
$p[] = new PiePlot3D($data[$i]);
}
for( $i=0; $i < $n; ++$i ) {
$p[$i]->SetCenter($piepos[2*$i],$piepos[2*$i+1]);
}
for( $i=0; $i < $n; ++$i ) {
$p[$i]->title->Set($titles[$i]);
$p[$i]->title->SetColor('white');
$p[$i]->title->SetFont(FF_ARIAL,FS_BOLD,12);
}
for( $i=0; $i < $n; ++$i ) {
$p[$i]->value->SetFont(FF_ARIAL,FS_BOLD);
$p[$i]->value->SetColor('white');
}
for( $i=0; $i < $n; ++$i ) {
$p[$i]->value->Show();
}
for( $i=0; $i < $n; ++$i ) {
$p[$i]->value->SetFormat("%01.1f%%");
}
for( $i=0; $i < $n; ++$i ) {
$p[$i]->SetSize(0.15);
}
for( $i=0; $i < $n; ++$i ) {
$p[$i]->SetEdge(false);
$p[$i]->ExplodeSlice(1);
}
$p[0]->SetLegends(array("May","June","July","Aug"));
$graph->legend->Pos(0.05,0.35);
$graph->legend->SetShadow(false);
for( $i=0; $i < $n; ++$i ) {
$graph->Add($p[$i]);
}
$graph->Stroke();
?> |