예제 #1
0
 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');
 }
예제 #2
0
 private function piePlot($question, $datax, $datay, $width, $height)
 {
     include_once BASE . "jpgraph.php";
     include_once BASE . "jpgraph_pie.php";
     include_once BASE . "jpgraph_pie3d.php";
     // Create the Pie Graph.
     $graph = new PieGraph($width, $height, "auto");
     $graph->SetShadow();
     // Set A title for the plot
     $tFontSize = 11;
     $graph->title->Set($question);
     $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize);
     $graph->title->SetColor("darkblue");
     $graph->SetAntiAliasing(true);
     $graph->legend->SetPos(0.02, 0.95, 'right', 'bottom');
     $graph->legend->SetMarkAbsSize(5);
     $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9);
     $tWidth = $graph->title->GetWidth($graph->img);
     //if ($graph->title->GetWidth($graph->img)>$width) $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize-2);
     if ($tWidth > $width) {
         $index = strrpos(substr($question, 0, ($len = strlen($question)) / 2 + 5), ' ');
         //echo $index;
         if ($index === false) {
             $index = $len / 2 - 3;
         }
         $question[$index] = "\n";
         $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize -= 2);
         $graph->title->Set($question);
     }
     // Create pie plot
     $pie = new PiePlot3d($datay);
     $pie->SetTheme("sand");
     $pie->SetCenter(0.5, 0.4);
     $pie->SetSize(($t = $height * 0.005 / $this->amountOfVariants) > 0.5 ? 0.5 : $t);
     $pie->SetAngle(30);
     $pie->ExplodeAll(5);
     $pie->value->SetFont(FF_ARIAL, FS_NORMAL, 10);
     $pie->SetLegends($datax);
     $graph->Add($pie);
     return $graph->Stroke("images/raporty/{$this->id_pytanie}P.png");
 }