function createPie3D($pValues = "")
{
    // Some data
    $values = array("2010" => 1950, "2011" => 750, "2012" => 2100, "2013" => 580, "2014" => 5000, "2015" => 5000, "2016" => 5000, "2017" => 5000);
    if ($pValues) {
        $values = $pValues;
    }
    $total = count($values);
    $data = $total == 0 ? array(360) : array_values($values);
    $keys = $total == 0 ? array("") : array_keys($values);
    // Create the Pie Graph.
    $graph = new PieGraph(380, 400);
    $theme_class = new VividTheme();
    $graph->SetTheme($theme_class);
    // Set A title for the plot
    //$graph->title->Set("A Simple 3D Pie Plot");
    // Create
    $p1 = new PiePlot3D($data);
    $p1->SetLegends($keys);
    $graph->Add($p1);
    $p1->ShowBorder();
    $p1->SetColor('black');
    $p1->ExplodeSlice(1);
    $graph->Stroke();
}
Exemple #2
0
function graficarTorta()
{
    require 'jpgraph/src/jpgraph.php';
    require 'jpgraph/src/jpgraph_pie.php';
    require 'jpgraph/src/jpgraph_pie3d.php';
    // Some data
    $data = array($_GET['pos'], $_GET['neg']);
    // Create the Pie Graph.
    $graph = new PieGraph(350, 300);
    $theme_class = new VividTheme();
    $graph->SetTheme($theme_class);
    // Set A title for the plot
    // $graph->title->Set("Grafico Estadistico");
    // Create
    $p1 = new PiePlot3D($data);
    $p1->ShowBorder();
    $p1->SetColor('black');
    $p1->ExplodeSlice(1);
    $p1->SetLegends(array($_GET['lab1'], $_GET['lab2']));
    $p1->SetCenter(0.5, 0.4);
    $p1->SetAngle(40);
    $graph->Add($p1);
    $graph->Stroke();
}
Exemple #3
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_pie.php';
require_once 'jpgraph/jpgraph_pie3d.php';
// Some data
$data = array(40, 60, 21, 33);
// Create the Pie Graph.
$graph = new PieGraph(350, 250);
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
// Set A title for the plot
$graph->title->Set("A Simple 3D Pie Plot");
// Create
$p1 = new PiePlot3D($data);
$graph->Add($p1);
$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors(array('#1E90FF', '#2E8B57', '#ADFF2F', '#BA55D3'));
$p1->ExplodeSlice(1);
$graph->Stroke();
Exemple #4
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
\JpGraph\JpGraph::load();
\JpGraph\JpGraph::module('pie');
\JpGraph\JpGraph::module('pie3d');
// Some data
$data = array(40, 60, 21, 33);
$piepos = array(0.2, 0.35, 0.5, 0.25, 0.3, 0.7, 0.85, 0.7);
$titles = array('USA', 'Sweden', 'South America', 'Australia');
$n = count($piepos) / 2;
// A new Graph\Graph
$graph = new \PieGraph(450, 300, 'auto');
$theme_class = "PastelTheme";
$graph->SetTheme(new $theme_class());
// Setup background
$graph->SetBackgroundImage('worldmap1.jpg', BGIMG_FILLFRAME);
// Setup title
$graph->title->Set("Pie plots with background image");
$graph->title->SetColor('white');
$graph->SetTitleBackground('#4169E1', TITLEBKG_STYLE2, TITLEBKG_FRAME_FULL, '#4169E1', 10, 10, true);
$p = array();
// Create the plots
for ($i = 0; $i < $n; ++$i) {
    $p[] = new \PiePlot3D($data);
}
for ($i = 0; $i < $n; ++$i) {
    $graph->Add($p[$i]);
}
// Position the four pies and change color
function createPie($waktu, $data_pie)
{
    require_once '../jpgraph/jpgraph.php';
    require_once '../jpgraph/jpgraph_pie.php';
    require_once '../jpgraph/jpgraph_pie3d.php';
    // Some data
    $data = $data_pie;
    // Create the Pie Graph.
    $graph = new PieGraph(400, 300);
    $theme_class = new VividTheme();
    $graph->SetTheme($theme_class);
    // Set A title for the plot
    $graph->title->Set("GRAFIK KEPATUHAN WP");
    $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
    // Create
    $p1 = new PiePlot3D($data);
    $p1->SetLegends(array('PATUH', 'KURANG PATUH', 'TIDAK PATUH'));
    $p1->SetCenter(0.5, 0.45);
    $p1->ShowBorder();
    $p1->SetColor('black');
    $graph->Add($p1);
    //unlink('../graphfiles/pie_kepatuhan.png');
    $graph->Stroke("../graphfiles/pie_kepatuhan_" . $waktu . ".png");
}
 /**
  *
  * @Route("/piechart/{qid}/{rid}/{style}", name="enquisa_piechart")
  * @Method("GET")
  */
 public function piechartAction(Request $request, $qid, $rid, $style)
 {
     /** @var $em Doctrine\ORM\EntityManager */
     $em = $this->getDoctrine()->getManager();
     //$total = $em->getRepository('EnquisaBundle:Enquisa')->getTotal();
     //$qid = $request->query->get('qid');
     if ($rid == 0) {
         $preguntaStats = $em->getRepository('EnquisaBundle:Enquisa')->getPreguntaStats($qid);
     } else {
         $preguntaStats = $em->getRepository('EnquisaBundle:Enquisa')->getPreguntaStatsByRestaurant($qid, $rid);
     }
     if (count($preguntaStats) > 0) {
         $data = [];
         $label = [];
         $title = '';
         foreach ($preguntaStats as $pregunta) {
             $title = $pregunta['texto'];
             $data[] = $pregunta['value'];
             $label[] = $pregunta['label'] . ' %.1f%%';
         }
         JpGraph::load();
         JpGraph::module('pie');
         JpGraph::module('pie3d');
         $graph = new \PieGraph(350, 280);
         if ($style == 'VividTheme') {
             $theme_class = new \VividTheme();
         } else {
             $theme_class = new \UniversalTheme();
             //\VividTheme;
         }
         $graph->SetTheme($theme_class);
         $graph->legend->SetPos(0.5, 0.97, 'center', 'bottom');
         $graph->legend->SetColumns(3);
         $p1 = new \PiePlot3D($data);
         $graph->Add($p1);
         $p1->SetLegends($label);
         $p1->ShowBorder();
         $p1->SetColor('black');
         $p1->SetLabelType(PIE_VALUE_PER);
         $p1->SetSize(0.4);
         $p1->SetCenter(0.5, 0.47);
         $p1->value->Show();
         $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 12);
         ob_start();
         $graph->Stroke();
         $imgStream = ob_get_contents();
         ob_end_clean();
     } else {
         //gif transparent 1x1
         $imgStream = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7');
     }
     $response = new Response();
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-type', 'image/png');
     $response->setContent($imgStream);
     return $response;
 }