Exemplo n.º 1
0
 private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False)
 {
     require_once 'jpgraph_pie.php';
     if ($dimensions == '3d') {
         require_once 'jpgraph_pie3d.php';
     }
     $this->_renderPiePlotArea($doughnut);
     $iLimit = $multiplePlots ? $groupCount : 1;
     for ($groupID = 0; $groupID < $iLimit; ++$groupID) {
         $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
         $exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
         if ($groupID == 0) {
             $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
             if ($labelCount > 0) {
                 $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
                 $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount);
             }
         }
         $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
         $seriesPlots = array();
         //	For pie charts, we only display the first series: doughnut charts generally display all series
         $jLimit = $multiplePlots ? $seriesCount : 1;
         //	Loop through each data series in turn
         for ($j = 0; $j < $jLimit; ++$j) {
             $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
             //	Fill in any missing values in the $dataValues array
             $testCurrentIndex = 0;
             foreach ($dataValues as $k => $dataValue) {
                 while ($k != $testCurrentIndex) {
                     $dataValues[$testCurrentIndex] = null;
                     ++$testCurrentIndex;
                 }
                 ++$testCurrentIndex;
             }
             if ($dimensions == '3d') {
                 $seriesPlot = new PiePlot3D($dataValues);
             } else {
                 if ($doughnut) {
                     $seriesPlot = new PiePlotC($dataValues);
                 } else {
                     $seriesPlot = new PiePlot($dataValues);
                 }
             }
             if ($multiplePlots) {
                 $seriesPlot->SetSize(($jLimit - $j) / ($jLimit * 4));
             }
             if ($doughnut) {
                 $seriesPlot->SetMidColor('white');
             }
             $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
             if (count($datasetLabels) > 0) {
                 $seriesPlot->SetLabels(array_fill(0, count($datasetLabels), ''));
             }
             if ($dimensions != '3d') {
                 $seriesPlot->SetGuideLines(false);
             }
             if ($j == 0) {
                 if ($exploded) {
                     $seriesPlot->ExplodeAll();
                 }
                 $seriesPlot->SetLegends($datasetLabels);
             }
             $this->_graph->Add($seriesPlot);
         }
     }
 }
Exemplo n.º 2
0
<?php

include "../jpgraph.php";
include "../jpgraph_pie.php";
$data = array(40, 60, 31, 35);
// A new pie graph
$graph = new PieGraph(250, 200, "auto");
$graph->SetShadow();
// Title setup
$graph->title->Set("Exploding all slices");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Setup the pie plot
$p1 = new PiePlot($data);
// Adjust size and position of plot
$p1->SetSize(0.35);
$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.65);
// Explode all slices
$p1->ExplodeAll(10);
// Add drop shadow
$p1->SetShadow();
// Finally add the plot
$graph->Add($p1);
// ... and stroke it
$graph->Stroke();
Exemplo n.º 3
0
 // Create the Pie Graph.
 $graph = new PieGraph(890, 770);
 $graph->SetAntiAliasing();
 $graph->SetShadow();
 // Set A title for the plot
 $graph->title->Set($m);
 $graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
 $graph->title->SetColor('black');
 $graph->title->SetMargin(10);
 $graph->subtitle->SetFont(FF_ARIAL, FS_BOLD, 10);
 $graph->subtitle->Set('Importe Total $ ' . $importe);
 // Create pie plot
 $p1 = new PiePlot($datay);
 $p1->SetSize(0.3);
 $p1->SetCenter(0.5, 0.32);
 $p1->ExplodeAll(5);
 $p1->SetShadow();
 $p1->SetSliceColors($color);
 $p1->SetGuideLines(true, false);
 $p1->SetGuideLinesAdjust(1.1);
 $p1->SetStartAngle(200);
 // Setup the labels to be displayed
 $p1->SetLabels($name);
 $p1->SetLegends($datax);
 $graph->legend->SetPos(0.39, 0.97, 'center', 'bottom');
 $graph->legend->SetColumns(2);
 // 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.55);
Exemplo n.º 4
0
 function parse($input, $parser)
 {
     global $jpgraphLabelType;
     foreach (split("\n", $input) as $line) {
         // skip empty line or comments
         if (preg_match("/^(\\s*)#.*\$|^(\\s*)\$/", $line)) {
             continue;
         }
         // Storing data
         $raw_data = split($this->fieldsep, $line);
         if (count($raw_data) == 2) {
             $this->labels[] = $raw_data[0];
             $this->datay[] = $raw_data[1];
         } else {
             $this->datay[] = $raw_data[0];
         }
     }
     if ($this->is3d) {
         $pie = new PiePlot3D($this->datay);
         $pie->SetAngle($this->angle);
     } else {
         $pie = new PiePlot($this->datay);
     }
     if ($this->center) {
         $tmp = split(",", $this->center);
         if (is_array($tmp) && count($tmp) == 2) {
             $pie->SetCenter($tmp[0], $tmp[1]);
         } else {
             if (is_array($tmp) && count($tmp) == 1) {
                 $pie->SetCenter($tmp[0]);
             }
         }
     }
     if ($this->labeltype) {
         $label_type = $jpgraphLabelType[$this->labeltype];
         if (!$label_type) {
             throw new JpgraphMWException("Unknown label type(" . $this->labeltype . "). Possible values are: " . implode(", ", array_keys($jpgraphLabelType)));
         }
         $pie->SetLabelType($label_type);
     }
     if ($this->labelformat) {
         $pie->value->SetFormat($this->labelformat);
     }
     if ($this->usettf) {
         $pie->value->SetFont($this->font);
     }
     $pie->value->Show($this->showlabel);
     $explode_pie_list = split(",", $this->explode);
     if (count($explode_pie_list) == 1) {
         $pie->ExplodeAll($explode_pie_list[0]);
     } else {
         $pie->Explode($explode_pie_list);
     }
     if (count($this->labels) == count($this->datay)) {
         $pie->SetLegends($this->labels);
     }
     $this->graph->Add($pie);
 }
Exemplo n.º 5
0
//echo $living;
//echo $transportation;
//echo $healthcare;
//echo $personal_loan;
//echo $eatingout;
//echo $entertainment;
//echo $children;
//echo $debtpayment;
if ($total > $salary) {
    header('Location:http://localhost/ExpenseTracker/index.html');
}
$data = array($housing, $utilities, $household, $groceries, $living, $transportation, $healthcare, $personal_loan, $eatingout, $entertainment, $children, $debtpayment);
//$data = array($a,$_POST['w1utilities'], $_POST['w1household'],$_POST['w1groceries'],$_POST['w1living'],$_POST['w1transport'],$_POST['w1health'],$_POST['w1loan'],$_POST['w1eat'],$_POST['w1entertain'],$_POST['w1child'],$_POST['w1debt']);
//$data2 = array($_POST['w2housing'],$_POST['w2utilities'], $_POST['w2household'],$_POST['w2groceries'],$_POST['w2living'],$_POST['w2transport'],$_POST['w2health'],$_POST['w2loan'],$_POST['w2eat'],$_POST['w2entertain'],$_POST['w2child'],$_POST['w2debt']);
$graph = new PieGraph(900, 800);
$lb1 = array("Housing\n%.1f%%", "Utilities\n%.1f%%", "HouseHold\n%.1f%%", "Groceries\n%.1f%%", "Living\n%.1f%%", "Transport\n%.1f%%", "HealthCare\n%.1f%%", "PersonalLoan\n%.1f%%", "EatingOut\n%.1f%%", "Entertainment\n%.1f%%", "Children%.1f%%", "DebtPayment%.1f%%");
$graph->SetShadow();
$graph->title->Set("Expense_Tracker");
$p1 = new PiePlot($data);
$p1->SetLabels($lb1);
$p1->ExplodeAll();
$graph->Add($p1);
$graph->Stroke();
//$pieplot->SetSize(0.5);
//$pieplot->SetCenter(0.5, 0.4);
/*$graph2 = new PieGraph(500, 400);
$graph2->SetShadow();
$graph2->title->Set("Week 2");
$p2 = new PiePlot($data2);
$graph2->Add($p2);
$graph2->Stroke(); */