| 1 |
lars |
1 |
<?php
|
|
|
2 |
// $Id
|
|
|
3 |
// Example of pie with center circle
|
|
|
4 |
include ("../jpgraph.php");
|
|
|
5 |
include ("../jpgraph_pie.php");
|
|
|
6 |
|
|
|
7 |
// Some data
|
|
|
8 |
$data = array(50,28,25,27,31,20);
|
|
|
9 |
|
|
|
10 |
// A new pie graph
|
|
|
11 |
$graph = new PieGraph(300,300,'auto');
|
|
|
12 |
|
|
|
13 |
// Setup title
|
|
|
14 |
$graph->title->Set("Pie plot with center circle");
|
|
|
15 |
$graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
|
|
|
16 |
$graph->title->SetMargin(8); // Add a little bit more margin from the top
|
|
|
17 |
|
|
|
18 |
// Create the pie plot
|
|
|
19 |
$p1 = new PiePlotC($data);
|
|
|
20 |
|
|
|
21 |
// Set size of pie
|
|
|
22 |
$p1->SetSize(0.32);
|
|
|
23 |
|
|
|
24 |
// Label font and color setup
|
|
|
25 |
$p1->value->SetFont(FF_ARIAL,FS_BOLD,10);
|
|
|
26 |
$p1->value->SetColor('black');
|
|
|
27 |
|
|
|
28 |
// Setup the title on the center circle
|
|
|
29 |
$p1->midtitle->Set("Test mid\nRow 1\nRow 2");
|
|
|
30 |
$p1->midtitle->SetFont(FF_ARIAL,FS_NORMAL,10);
|
|
|
31 |
|
|
|
32 |
// Set color for mid circle
|
|
|
33 |
$p1->SetMidColor('yellow');
|
|
|
34 |
|
|
|
35 |
// Use percentage values in the legends values (This is also the default)
|
|
|
36 |
$p1->SetLabelType(PIE_VALUE_PER);
|
|
|
37 |
|
|
|
38 |
// Add plot to pie graph
|
|
|
39 |
$graph->Add($p1);
|
|
|
40 |
|
|
|
41 |
// .. and send the image on it's marry way to the browser
|
|
|
42 |
$graph->Stroke();
|
|
|
43 |
|
|
|
44 |
?>
|
|
|
45 |
|
|
|
46 |
|