public static function pieChart($data, $legends) { $graph = new PieGraph(900, 550, 'auto'); $graph->SetShadow(); // $graph->title->Set($topic); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 14); $graph->legend->Pos(0.1, 0.2); // Creating a 3D pie graphic $p1 = new PiePlot3d($data); $p1->SetTheme("sand"); $p1->SetLabels($legends); $p1->SetLabelPos(1); $p1->SetLabelType(PIE_VALUE_PER); $p1->value->Show(); $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 20); $p1->value->SetColor('darkgray'); $p1->SetCenter(0.45, 0.5); $p1->SetAngle(45); $p1->ExplodeAll(20); // $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 12); // $p1->SetLegends($legends); $graph->img->SetImgFormat('png'); $graph->Add($p1); // Showing graphic return $graph->Stroke('../graph/3DpieChart.png'); }
} elseif ($type == "alarm") { //$graph->title->Set(gettext("ALARMS RECEIVED")); } $graph->title->SetFont(FF_FONT1, FS_BOLD); // Create pie plot $p1 = new PiePlot3d($data); $p1->SetHeight(12); $p1->SetSize(0.3); if (count($labels) > 1) { $p1->SetCenter(0.5, 0.25); } else { $p1->SetCenter(0.57, 0.25); } $p1->SetLegends($legend); $p1->SetLabels($labels); $p1->SetLabelPos(1); $graph->legend->SetPos(0.5, 0.95, 'center', 'bottom'); $graph->legend->SetShadow('#fafafa', 0); $graph->legend->SetFrameWeight(0); $graph->legend->SetFillColor('#fafafa'); $graph->SetFrame(false); $p1->SetSliceColors($colors); //$p1->SetStartAngle(M_PI/8); //$p1->ExplodeSlice(0); $graph->Add($p1); $graph->Stroke(); unset($graph); exit; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="">
$graph->title->SetFont(FF_TIMES, FS_BOLD, 16); $graph->title->SetColor("darkgray"); $graph->legend->Pos(0.075, 0.2); $graph->SetFrame(false); // Create 3D pie plot $p1 = new PiePlot3d($data); $p1->SetSliceColors(array('#5CD900', '#6666FF')); $p1->SetCenter(0.45, 0.65); $p1->SetSize(70); // Adjust projection angle $p1->SetAngle(45); // Adjsut angle for first slice $p1->SetStartAngle(80); // Display the slice values $p1->value->SetFont(FF_TIMES, FS_BOLD, 11); $p1->value->SetColor("navy"); // Add colored edges to the 3D pie // NOTE: You can't have exploded slices with edges! $p1->SetEdge("navy"); $p1->SetLabelType(PIE_VALUE_ABS); $p1->value->SetFormat('$%d'); $p1->SetLabels(array($balance, $total), 1); $p1->SetLabelPos(0.3); $p1->SetLegends(array($label1, $label2)); $graph->Add($p1); $graph->SetAntiAliasing(); $graph->Stroke(); ?>