示例#1
0
 /**
  * Constructor
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  * @param string $format one of png, jpeg, gif
  */
 public function __construct(Request $request, $format = 'png')
 {
     parent::__construct($request);
     $this->response->headers->set('Content-Type', 'image/' . $format);
     // load JpGraph
     // NOTE: JpGraph installs its own graphical error handler
     \JpGraph\JpGraph::load();
     \JpGraph\JpGraph::module('date');
     \JpGraph\JpGraph::module('line');
     if ($this->request->query->has('width')) {
         $this->width = $this->request->query->get('width');
     }
     if ($this->request->query->has('height')) {
         $this->height = $this->request->query->get('height');
     }
     $this->colors = Util\Configuration::read('colors');
     $this->graph = new \Graph($this->width, $this->height);
     // disable JpGraph default handler
     restore_exception_handler();
     $this->graph->img->SetImgFormat($format);
     // Specify what scale we want to use,
     $this->graph->SetScale('datlin');
     $this->graph->legend->SetPos(0.03, 0.06);
     $this->graph->legend->SetShadow(FALSE);
     $this->graph->legend->SetFrameWeight(1);
     $this->graph->SetMarginColor('white');
     $this->graph->SetYDeltaDist(65);
     $this->graph->yaxis->SetTitlemargin(36);
     $this->graph->SetTickDensity(TICKD_DENSE, TICKD_SPARSE);
     $this->graph->xaxis->SetFont(FF_ARIAL);
     $this->graph->xaxis->SetLabelAngle(45);
     $this->graph->xaxis->SetLabelFormatCallback(function ($label) {
         return date('j.n.y G:i', $label);
     });
     if (function_exists('imageantialias')) {
         $this->graph->img->SetAntiAliasing(true);
     }
 }
示例#2
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(20, 27, 45, 75, 90);
// Create the Pie Graph.
$graph = new \PieGraph(350, 200);
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set("Example 1 3D Pie plot");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 18);
$graph->title->SetColor("darkblue");
$graph->legend->Pos(0.1, 0.2);
// Create pie plot
$p1 = new \PiePlot3D($data);
$p1->SetTheme("sand");
$p1->SetCenter(0.4);
$p1->SetAngle(30);
$p1->value->SetFont(FF_ARIAL, FS_NORMAL, 12);
$p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct"));
$graph->Add($p1);
$graph->Stroke();
示例#3
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
\JpGraph\JpGraph::load();
\JpGraph\JpGraph::module('pie');
// Some data
$data = array(40, 21, 17, 14, 23);
// Create the Pie Graph.
$graph = new \PieGraph(350, 300);
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set("Multiple - Pie plot");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create plots
$size = 0.13;
$p1 = new \PiePlot($data);
$p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May"));
$p1->SetSize($size);
$p1->SetCenter(0.25, 0.32);
$p1->value->SetFont(FF_FONT0);
$p1->title->Set("2001");
$p2 = new \PiePlot($data);
$p2->SetSize($size);
$p2->SetCenter(0.65, 0.32);
$p2->value->SetFont(FF_FONT0);
$p2->title->Set("2002");
$p3 = new \PiePlot($data);
$p3->SetSize($size);
$p3->SetCenter(0.25, 0.75);
$p3->value->SetFont(FF_FONT0);
示例#4
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $userstories = Userstory::all();
     $selectedUserStories = array();
     $i = 0;
     foreach ($userstories as $userstory) {
         if ($userstory->project_id == $id) {
             $selectedUserStories[$i] = $userstory;
             $i++;
         }
     }
     $sprints = Sprint::all();
     $realisedUS = array();
     $somme = 0;
     for ($i = 0; $i < count($selectedUserStories); $i++) {
         $somme = $somme + $selectedUserStories[$i]->difficulty;
     }
     $cptt = 0;
     $cpt = $somme;
     foreach ($sprints as $sprint) {
         for ($i = 0; $i < count($selectedUserStories); $i++) {
             if ($selectedUserStories[$i]->sprint_id == $sprint->id && $selectedUserStories[$i]->status == 1) {
                 $cptt = $cptt + $selectedUserStories[$i]->difficulty;
             }
         }
         $realisedUS[$sprint->id] = $cpt - $cptt;
     }
     //dd($realisedUS);
     $j = 1;
     $userstori = array();
     $time = array();
     $userstori[0] = $somme;
     $time[0] = 0;
     //dd($realisedUS);
     foreach ($realisedUS as $key => $value) {
         $userstori[$j] = $value;
         $time[$j] = $key;
         $j++;
     }
     //dd($time);
     //$userstori[0] = count($selectedUserStories);
     JpGraph::load();
     JpGraph::module('line');
     //$time = array_keys($realisedUS);
     //dd($realisedUS);
     //dd($time);
     //dd($userstori);
     $graph = new \Graph(900, 300);
     $ydata = $userstori;
     $xdata = $time;
     //dd($time);
     //dd($userstori);
     $graph->SetScale('intint');
     $lineplot = new \LinePlot($ydata, $xdata);
     $lineplot->SetColor('forestgreen');
     $graph->Add($lineplot);
     $graph->title->Set('BurnDownChart');
     $graph->xaxis->title->Set('Sprint\'s Time');
     $graph->yaxis->title->Set('Difficulties');
     $lineplot->SetWeight(3);
     $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
     //Start buffering
     ob_start();
     //Print the data stream to the buffer
     $graph->img->Stream();
     //Get the contents of the buffer
     $image_data = ob_get_contents();
     //Stop the buffer/clear it.
     ob_end_clean();
     //Set the variable equal to the base 64 encoded value of the stream.
     //This gets passed to the browser and displayed.
     $image = base64_encode($image_data);
     return view('bdchart.index', compact('realisedUS', 'id', 'data', 'texte', 'image'));
 }
 /**
  *
  * @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;
 }
 public function getGrafmayorcosto()
 {
     JpGraph::module('bar');
     $graph = new Graph(680, 300);
     $graph->SetScale("textlin");
     $graph->yscale->SetGrace(5);
     $graph->SetBox(true);
     $labels = array();
     $valores = array();
     foreach (Activo::where('id', '>', '0')->orderBy('costo', 'desc')->take(10)->get() as $activo) {
         $labels[] = $activo->num_activo;
         $valores[] = $activo->costo;
     }
     //titulo de la grafica
     $graph->title->SetColor('black');
     $graph->title->Set('Gráfica: Activos con Mayor Costo');
     //valores de los labels en ambas axis y como se ubicaran
     $graph->xaxis->SetTickLabels($labels);
     $graph->xaxis->SetLabelAlign('center', 'top', 'center');
     $graph->ygrid->SetFill(false);
     $graph->yaxis->HideLabels(false);
     $graph->yaxis->HideTicks(false, false);
     //Fonts para las axis
     $graph->xaxis->SetColor('black');
     $graph->yaxis->SetColor('black');
     //grafica de activos con mayor costo
     $mayorCosto = new BarPlot($valores);
     $mayorCosto->SetColor('white');
     $mayorCosto->SetWidth(0.6);
     //agrega la grafica generada a la instancia de la grafica
     $graph->Add($mayorCosto);
     //Despliega la grafica
     $graph->Stroke();
 }