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); } } }
// Some data and the labels $data = array(19, 12, 4, 7, 3, 12, 3); $labels = array("First\n(%.1f%%)", "Second\n(%.1f%%)", "Third\n(%.1f%%)", "Fourth\n(%.1f%%)", "Fifth\n(%.1f%%)", "Sixth\n(%.1f%%)", "Seventh\n(%.1f%%)"); // 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(); ?>
$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); // 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('black'); // Add and stroke
if (strlen($lastTLD)) { getColors($colors, $count, $index); } // reset the counter $count = 0; $lastTLD = $tld; } $count++; } if (strlen($lastTLD)) { getColors($colors, $count, $index); } $graph = new PieGraph($width, $height); $graph->SetFrame(false); $graph->SetAntiAliasing(); $pie = new PiePlot($values); // set the actual labels for the wedges $pie->SetLabels($labels, 1.1); if (count($colors)) { $pie->SetSliceColors($colors); } // set other options $pie->SetGuideLines(true, true, true); $graph->title->SetFont(FF_FONT2, FS_BOLD); $graph->title->Set($chartType); $pie->ShowBorder(true, true); $pie->SetSize(0.25); $graph->Add($pie); $graph->img->SetExpired(false); $graph->Stroke(); }
//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(); */