1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_pie.php');
|
---|
4 | require_once ('jpgraph/jpgraph_pie3d.php');
|
---|
5 |
|
---|
6 | // Some data
|
---|
7 | $data = array(40,60,21,33);
|
---|
8 |
|
---|
9 | $piepos = array(0.2,0.35,0.5,0.25,0.3,0.7,0.85,0.7);
|
---|
10 | $titles = array('USA','Sweden','South America','Australia');
|
---|
11 |
|
---|
12 | $n = count($piepos)/2;
|
---|
13 |
|
---|
14 | // A new graph
|
---|
15 | $graph = new PieGraph(450,300,'auto');
|
---|
16 |
|
---|
17 | $theme_class="PastelTheme";
|
---|
18 | $graph->SetTheme(new $theme_class());
|
---|
19 |
|
---|
20 | // Setup background
|
---|
21 | $graph->SetBackgroundImage('worldmap1.jpg',BGIMG_FILLFRAME);
|
---|
22 |
|
---|
23 | // Setup title
|
---|
24 | $graph->title->Set("Pie plots with background image");
|
---|
25 | $graph->title->SetColor('white');
|
---|
26 | $graph->SetTitleBackground('#4169E1',TITLEBKG_STYLE2,TITLEBKG_FRAME_FULL,'#4169E1',10,10,true);
|
---|
27 |
|
---|
28 | $p = array();
|
---|
29 | // Create the plots
|
---|
30 | for( $i=0; $i < $n; ++$i ) {
|
---|
31 | $p[] = new PiePlot3D($data);
|
---|
32 | }
|
---|
33 | for( $i=0; $i < $n; ++$i ) {
|
---|
34 | $graph->Add($p[$i]);
|
---|
35 | }
|
---|
36 |
|
---|
37 | // Position the four pies and change color
|
---|
38 | for( $i=0; $i < $n; ++$i ) {
|
---|
39 | $p[$i]->SetCenter($piepos[2*$i],$piepos[2*$i+1]);
|
---|
40 | $p[$i]->SetSliceColors(array('#1E90FF','#2E8B57','#ADFF2F','#DC143C','#BA55D3'));
|
---|
41 | }
|
---|
42 |
|
---|
43 | // Set the titles
|
---|
44 | for( $i=0; $i < $n; ++$i ) {
|
---|
45 | $p[$i]->title->Set($titles[$i]);
|
---|
46 | $p[$i]->title->SetFont(FF_ARIAL,FS_NORMAL,8);
|
---|
47 | }
|
---|
48 |
|
---|
49 | for( $i=0; $i < $n; ++$i ) {
|
---|
50 | $p[$i]->value->Show(false);
|
---|
51 | }
|
---|
52 |
|
---|
53 | // Size of pie in fraction of the width of the graph
|
---|
54 | for( $i=0; $i < $n; ++$i ) {
|
---|
55 | $p[$i]->SetSize(0.13);
|
---|
56 | }
|
---|
57 |
|
---|
58 | for( $i=0; $i < $n; ++$i ) {
|
---|
59 | $p[$i]->SetEdge(false);
|
---|
60 | $p[$i]->ExplodeSlice(1,7);
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | $graph->Stroke();
|
---|
65 | ?>
|
---|