Esempio n. 1
0
 public function executePieGraph()
 {
     //Set the response header to a image JPEG datastream
     $this->getResponse()->setContent('image/jpeg');
     $util = new util();
     //echo $duales;
     $data1 = $util->getDualMedia('movies');
     $data2 = $util->getTotalMedia('movies') - $data1;
     $data = array($data2, $data1);
     $graph = new PieGraph(199, 120);
     $graph->SetMarginColor('#393939');
     $graph->SetFrame(true, '#393939');
     $graph->legend->SetPos(0.8, 0.9, 'center', 'bottom');
     $p1 = new PiePlot($data);
     $p1->SetSize(0.4);
     $p1->SetCenter(0.45);
     $p1->SetSliceColors(array('white', 'red'));
     $p1->value->SetColor('black');
     $p1->SetLegends(array("Spa", "Dual"));
     $p1->SetLabelPos(0.6);
     $graph->Add($p1);
     $graph->Stroke();
     return sfView::NONE;
 }
Esempio n. 2
0
 /**
  * chartService::renderPiePlot() - draw the Pie type plot
  *
  * @param array $data plot data array reference
  * @param array $xmlArr xml array reference
  * @return object refernce Pie plot object reference
  */
 public function renderPiePlot(&$data, &$xmlArr)
 {
     $id = $xmlArr['ATTRIBUTES']['ID'];
     $field = $xmlArr['ATTRIBUTES']['FIELD'];
     $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE'];
     $size = $xmlArr['ATTRIBUTES']['SIZE'];
     $center = $xmlArr['ATTRIBUTES']['CENTER'];
     $height = $xmlArr['ATTRIBUTES']['HEIGHT'];
     $angle = $xmlArr['ATTRIBUTES']['ANGLE'];
     $labelPos = $xmlArr['ATTRIBUTES']['LABELPOS'];
     $legendField = $xmlArr['ATTRIBUTES']['LAGENDFIELD'];
     if ($chartType == "Pie") {
         $plot = new PiePlot($data);
         $plot->SetLabelPos($labelPos);
     } else {
         if ($chartType == "Pie3D") {
             $plot = new PiePlot3D($data);
             $plot->SetHeight($height);
             $plot->SetAngle($angle);
         }
     }
     list($c1, $c2) = explode(',', $center);
     $plot->SetCenter($c1, $c2);
     $plot->SetSize($size);
     $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']);
     return $plot;
 }
    // Title setup
    $graph->title->Set($logtype);
    $graph->title->SetFont(FF_ARIAL, FS_NORMAL);
    //$graph ->legend->Pos( 0.25,0.8,"right" ,"bottom");
    // Setup the pie plot
    $p1 = new PiePlot($y);
    $p1->SetTheme("earth");
    $p1->value->SetFormat("%d");
    $p1->SetLabelType(PIE_VALUE_ABS);
    $p1->SetSliceColors(array('chartreuse3', 'chocolate2', 'wheat1'));
    // Adjust size and position of plot
    $p1->SetSize(0.35);
    $p1->SetCenter(0.25, 0.52);
    $f = tr("found");
    $dnf = tr("not_found");
    $com = tr("comment");
    // Setup slice labels and move them into the plot
    $xx = array($f, $dnf, $com);
    $p1->value->SetFont(FF_COURIER, FS_NORMAL);
    $p1->value->SetColor("black");
    $p1->SetLabelPos(0.65);
    $p1->SetLegends($xx);
    $graph->legend->SetFont(FF_ARIAL, FS_NORMAL);
    // Explode all slices
    //$p1->ExplodeAll(10);
    // Finally add the plot
    $graph->Add($p1);
    $graph->SetShadow();
    // ... and stroke it
    $graph->Stroke();
}
Esempio n. 4
0
// Create the Pie Graph.
$graph = new PieGraph(300, 300);
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set('String labels with values');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
$graph->title->SetColor('black');
// Create pie plot
$p1 = new PiePlot($data);
$p1->SetCenter(0.5, 0.5);
$p1->SetSize(0.3);
// Setup the labels to be displayed
$p1->SetLabels($labels);
// This method adjust the position of the labels. This is given as fractions
// of the radius of the Pie. A value < 1 will put the center of the label
// inside the Pie and a value >= 1 will pout the center of the label outside the
// Pie. By default the label is positioned at 0.5, in the middle of each slice.
$p1->SetLabelPos(1);
// Setup the label formats and what value we want to be shown (The absolute)
// or the percentage.
$p1->SetLabelType(PIE_VALUE_PER);
$p1->value->Show();
$p1->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1->value->SetColor('darkgray');
// Add and stroke
$graph->Add($p1);
$graph->Stroke();
?>


Esempio n. 5
0
 public function executePieGraphSingers(sfWebRequest $request)
 {
     $util = new util();
     $loko = $util->singersData();
     //Set the response header to a image JPEG datastream
     $this->getResponse()->setContent('image/jpeg');
     //echo $duales;
     $data1 = 300;
     $data2 = 200;
     //        $data_results = $util->singersData();
     $data = array($data2, $data1);
     $graph = new PieGraph(200, 174);
     $graph->SetMarginColor('#393939');
     $graph->SetFrame(true, '#393939');
     $graph->legend->SetPos(0.8, 0.9, 'center', 'bottom');
     $p1 = new PiePlot($data);
     $p1->SetSize(0.4);
     $p1->SetCenter(0.45);
     $p1->SetSliceColors(array('white', 'red'));
     $p1->value->SetColor('black');
     $p1->SetLegends(array("Spa", "Dual"));
     $p1->SetLabelPos(0.6);
     $graph->Add($p1);
     $graph->Stroke();
     return sfView::NONE;
 }
Esempio n. 6
0
<?php

// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_pie.php";
$data = array(40, 60, 31, 35);
// A new pie graph
$graph = new PieGraph(250, 200);
$graph->SetShadow();
// Title setup
$graph->title->Set("Adjusting the label pos");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Setup the pie plot
$p1 = new PiePlot($data);
// Adjust size and position of plot
$p1->SetSize(0.4);
$p1->SetCenter(0.5, 0.52);
// Setup slice labels and move them into the plot
$p1->value->SetFont(FF_FONT1, FS_BOLD);
$p1->value->SetColor("darkred");
$p1->SetLabelPos(0.6);
// Finally add the plot
$graph->Add($p1);
// ... and stroke it
$graph->Stroke();
        }
        // Create the Pie Graph.
        $graph = new PieGraph(200, 200);
        //$graph->SetShadow();
        // Set A title for the plot
        $graph->title->Set('New Users by Gender');
        $graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
        $graph->title->SetColor('black');
        // Create pie plot
        $p1 = new PiePlot($data);
        $p1->SetCenter(0.5, 0.5);
        $p1->SetSize(0.3);
        $p1->SetSliceColors(array('#1E90FF', '#2E8B57'));
        // Setup the labels to be displayed
        $p1->SetLabels($labels);
        // This method adjust the position of the labels. This is given as fractions
        // of the radius of the Pie. A value < 1 will put the center of the label
        // inside the Pie and a value >= 1 will pout the center of the label outside the
        // Pie. By default the label is positioned at 0.5, in the middle of each slice.
        $p1->SetLabelPos(0.5);
        // Setup the label formats and what value we want to be shown (The absolute)
        // or the percentage.
        $p1->SetLabelType(PIE_VALUE_PER);
        $p1->value->Show();
        $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
        $p1->value->SetColor('white');
        // Add and stroke
        $graph->Add($p1);
        $graph->Stroke();
    }
}