1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | include ("../jpgraph.php");
|
---|
3 | include ("../jpgraph_pie.php");
|
---|
4 |
|
---|
5 | // Some data and the labels
|
---|
6 | $data = array(19,12,4,7,3,12,3);
|
---|
7 | $labels = array("First\n(%.1f%%)",
|
---|
8 | "Second\n(%.1f%%)","Third\n(%.1f%%)",
|
---|
9 | "Fourth\n(%.1f%%)","Fifth\n(%.1f%%)",
|
---|
10 | "Sixth\n(%.1f%%)","Seventh\n(%.1f%%)");
|
---|
11 |
|
---|
12 | // Create the Pie Graph.
|
---|
13 | $graph = new PieGraph(300,300);
|
---|
14 | $graph->SetShadow();
|
---|
15 |
|
---|
16 | // Set A title for the plot
|
---|
17 | $graph->title->Set('String labels with values');
|
---|
18 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
|
---|
19 | $graph->title->SetColor('black');
|
---|
20 |
|
---|
21 | // Create pie plot
|
---|
22 | $p1 = new PiePlot($data);
|
---|
23 | $p1->SetCenter(0.5,0.5);
|
---|
24 | $p1->SetSize(0.3);
|
---|
25 |
|
---|
26 | // Setup the labels to be displayed
|
---|
27 | $p1->SetLabels($labels);
|
---|
28 |
|
---|
29 | // This method adjust the position of the labels. This is given as fractions
|
---|
30 | // of the radius of the Pie. A value < 1 will put the center of the label
|
---|
31 | // inside the Pie and a value >= 1 will pout the center of the label outside the
|
---|
32 | // Pie. By default the label is positioned at 0.5, in the middle of each slice.
|
---|
33 | $p1->SetLabelPos(1);
|
---|
34 |
|
---|
35 | // Setup the label formats and what value we want to be shown (The absolute)
|
---|
36 | // or the percentage.
|
---|
37 | $p1->SetLabelType(PIE_VALUE_PER);
|
---|
38 | $p1->value->Show();
|
---|
39 | $p1->value->SetFont(FF_ARIAL,FS_NORMAL,9);
|
---|
40 | $p1->value->SetColor('darkgray');
|
---|
41 |
|
---|
42 | // Add and stroke
|
---|
43 | $graph->Add($p1);
|
---|
44 | $graph->Stroke();
|
---|
45 |
|
---|
46 | ?>
|
---|
47 |
|
---|
48 |
|
---|