function PieChart($w, $h, $title, $data, $dataL, $output) { $graph = new PieGraph($w, $h, "auto"); $graph->SetFrame(false); $graph->SetShadow(false); $graph->title->Set($title); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($data); $p1->SetAngle(20); $p1->SetSize(0.5); $p1->SetCenter(0.45); $p1->SetLegends($dataL); $graph->Add($p1); $graph->Stroke($output); }
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(); }
/** * 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; }
<?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();
function dansguardian_buildGraph_week(){ include_once(dirname(__FILE__).'/listener.graphs.php'); $sql="SELECT COUNT( sitename ) AS tcount ,TYPE FROM `dansguardian_events` WHERE YEARWEEK( zDate ) = YEARWEEK( NOW( ) ) GROUP BY TYPE ORDER BY tcount DESC LIMIT 0 , 30"; if(isset($_GET["dansguardian-stats-query"])){return dansguardian_buildGraph_by_type();} $md5=md5($sql); $q=new mysql(); $results=$q->QUERY_SQL($sql,'artica_events'); $html="<table style='width:100%'>"; while ($ligne = mysql_fetch_array($results)) { if($ligne["TYPE"]<>null){ $data[]=$ligne["tcount"]; $labels[]=$ligne["TYPE"]; $jsa="javascript:ShowGraphDansGuardianDetails('{$ligne["TYPE"]}','week');"; $html=$html . "<tr " . CellRollOver()."> <td width=1%><img src='img/fw_bold.gif'> <td><strong style='font-size:11px'>{$ligne["tcount"]}</td> <td><strong style='font-size:11px'><a href='#' OnClick=\"$jsa\">{$ligne["TYPE"]}</a></td> </tr> "; $js[]="$jsa"; } } $html=$html."</table>"; if (!is_array($data)){ die("<center>".ICON_DANSGUARDIAN_STATISTICS()."</center>"); } $tpl=new templates(); $p1 = new PiePlot3D($data); $p1->SetSize(.4); $p1->SetAngle(75); $p1->SetCSIMTargets($js,$labels); $p1->SetCenter(0.3,0.5); $p1->ExplodeAll(10); $p1->SetLegends($labels); //$p1->SetSliceColors(array('red','blue','green','navy','orange')); $graph = new PieGraph(470,350,'auto'); $graph->Add($p1); $graph->title->Set("Week"); $graph->title->SetFont(FF_FONT1,FS_BOLD); $graph->legend->Pos(0,0,'right','top'); $graph->legend->SetFillColor('white'); $graph->legend->SetLineWeight(0); //$graph->legend->SetLayout(LEGEND_HOR); //hori $graph->legend->SetColor('black'); $graph->legend->SetShadow("white",0); $graph->SetFrame(false); if(function_exists("imageantialias")){$graph->img->SetAntiAliasing();} $mapName = 'MapName'; $imgMap = $graph->GetHTMLImageMap($mapName); $graph->Stroke("ressources/logs/$md5.png"); $html= " <table style='width:100%'> <tr> <td valign='top'> $imgMap ".RoundedLightWhite(" <img src='ressources/logs/$md5.png' alt='graph' ismap usemap='#$mapName' border='0'>")." </td> <td valign='top'>".RoundedLightWhite($html)."</td> </tr> </table> "; return $html; }
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); }
$p1->SetLabelType(0); $p1->value->SetFormat("%d%%"); } else { $p1->SetLabelType(1); $p1->value->SetFormat("%d"); } // Set label properties $p1->SetLabelPos(1.0); $p1->SetSliceColors(array('#FFF584', '#CBFF84', '#FF6B9E', '#FF9584', '#EAFF84', '#7BFF51', '#51FFA6', '#51FF52', '#6BCFFF', '#5170FF', '#519CFF', '#EAE3AD', '#FFF184', '#8584FF', '#E698FF', '#C384FF', '#FF84EC', '#FF98A3', '#E5C285', '#FFDA98')); $p1->value->SetFont(FF_VERA, FS_NORMAL, 8); $p1->value->SetColor("black"); // Adjust other Pie Properties $p1->SetLabelMargin(5); $p1->SetCenter(0.4, 0.65); $p1->SetSize(0.3); $p1->SetAngle(60); $graph->Add($p1); } else { if ($content['chart_type'] == CHART_BARS_VERTICAL) { // Include additional code filers for this chart! include_once $gl_root_path . "classes/jpgraph/jpgraph_bar.php"; include_once $gl_root_path . "classes/jpgraph/jpgraph_line.php"; // Create Basic Image, and set basic properties! $graph = new Graph($content['chart_width'], $content['chart_width'], 'auto'); $graph->SetMargin(60, 20, 30, 50); // Adjust margin area $graph->SetScale("textlin"); $graph->SetMarginColor('white'); $graph->SetBox(); // Box around plotarea // Setup X-AXIS
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_pie.php'; require_once 'jpgraph/jpgraph_pie3d.php'; $data = array(40, 60, 21, 33); $graph = new PieGraph(300, 200); $graph->SetShadow(); $graph->title->Set("A simple Pie plot"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($data); $p1->SetAngle(20); $p1->SetSize(0.5); $p1->SetCenter(0.45); $p1->SetLegends($gDateLocale->GetShortMonth()); $graph->Add($p1); $graph->Stroke(); ?>
<?php $rutaJpGraph = "../jpgraph/src"; error_reporting(1); include "{$rutaJpGraph}/jpgraph_pie.php"; include "{$rutaJpGraph}/jpgraph_pie3d.php"; $data = array(1); $graph = new PieGraph(490, 300, "auto"); $graph->img->SetAntiAliasing(); $graph->SetMarginColor('white'); $graph->legend->Pos(0.75, 0.2); // Setup margin and titles $graph->title->SetFont(FF_FONT2, FS_NORMAL1, 5); $graph->title->Set("INFORME PQR "); $p1 = new PiePlot3D($data1y); //$_GET['datoss'][0]); $p1->SetSize(0.35); $p1->SetLabelMargin(5); $p1->SetAngle(65); $p1->SetCenter(0.52, 0.6); $p1->ExplodeSlice(3); // Setup slice labels and move them into the plot //$p1->SetLabelType(PIE_VALUE_ABS); $p1->value->SetFont(FF_FONT1, FS_BOLD, 5); $p1->value->SetColor("black"); $p1->SetLabelPos(0.6); $p1->SetLabels($nombPqrLbl, 0.2); $p1->SetLegends($nombPqr); //$_GET['nombres'][0]); $graph->Add($p1); $graph->Stroke($rutaImagen);
// 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 3 3D Pie plot"); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 18); $graph->title->SetColor("darkblue"); $graph->legend->Pos(0.1, 0.2); // Create 3D pie plot $p1 = new \PiePlot3D($data); $p1->SetTheme("sand"); $p1->SetCenter(0.4); $p1->SetSize(80); // Adjust projection angle $p1->SetAngle(45); // As a shortcut you can easily explode one numbered slice with $p1->ExplodeSlice(3); // Setup the slice values $p1->value->SetFont(FF_ARIAL, FS_BOLD, 11); $p1->value->SetColor("navy"); $p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")); $graph->Add($p1); $graph->Stroke();
$graph->legend->SetShadow('#fafafa', 0); //$graph->legend->SetFillColor('#fafafa'); $graph->legend->SetFrameWeight(0); } else { if (intval($w) == 2) { $graph->SetMarginColor('#FFFFFF'); $graph->legend->SetShadow('#FFFFFF', 0); $graph->legend->SetFillColor('#FFFFFF'); $graph->legend->SetFrameWeight(0); } } $p1 = new PiePlot3D($data); $graph->SetFrame(false, '#ffffff'); $p1->SetSize(0.5); $p1->SetStartAngle(290); $p1->SetAngle(50); $p1->SetCenter(0.35); $p1->SetLegends($legend); //$colors=array("#C835ED", "red", "orange", "green", "#eeeeee"); //$colors=array("#C835ED", "red", "orange", "#FFD700", "#F0E68C"); $p1->SetSliceColors($colors); $p1->ExplodeAll(8); //$dplot[0]->SetFillColor("blue"); //$dplot[1]->SetFillColor("green"); //$dplot[2]->SetFillColor("navy"); //$dplot[3]->SetFillColor("orange"); //$dplot[4]->SetFillColor("magenta"); //$dplot[5]->SetFillColor("yellow"); //$dplot[6]->SetFillColor("red"); $graph->Add($p1); $graph->Stroke();
function generatePie3D($data, $legend_index = 0, $chartData_index = 1, $image = false, $length = 500, $width = 300, $hasShadow = true, $fontFamily = FF_FONT1, $fontStyle = FS_BOLD, $fontSize = '', $fontColor = 'black') { include_once XHELP_JPGRAPH_PATH . '/jpgraph_pie.php'; include_once XHELP_JPGRAPH_PATH . '/jpgraph_pie3d.php'; $graph = new PieGraph($length, $width); if ($hasShadow) { // Add a shadow to the image $graph->setShadow(); } $graph->title->Set($this->meta['name']); $p1 = new PiePlot3D($data[$chartData_index]); $p1->SetSize(0.3); $p1->SetCenter(0.45); $p1->SetStartAngle(20); $p1->SetAngle(45); $p1->SetLegends($data[$legend_index]); $p1->value->SetFont($fontFamily, $fontStyle, $fontSize); $p1->value->SetColor($fontColor); $p1->SetLabelType(PIE_VALUE_PER); $a = array_search(max($data[$chartData_index]), $data[$chartData_index]); //Find the position of maximum value. $p1->ExplodeSlice($a); // Set graph background image if ($image != false) { $graph->SetBackgroundImage($image, BGIMG_FILLFRAME); } $graph->Add($p1); $graph->Stroke(); }
function pie_single_mailbox_user() { $tpl = new Templates(); $users = new usersMenus(); $uid = $_SESSION["uid"]; if ($users->cyrus_imapd_installed == 0) { return null; } $ldap = new clladp(); $hash = $ldap->UserDatas($_SESSION["uid"]); if ($hash["MailboxActive"] != 'TRUE') { return null; } $cyrus = new cyrus(); $res = $cyrus->get_quota_array($uid); $size = $cyrus->MailboxInfosSize($uid); $free = $cyrus->USER_STORAGE_LIMIT - $cyrus->USER_STORAGE_USAGE; if (!$cyrus->MailBoxExists($uid)) { return null; } $USER_STORAGE_USAGE = $cyrus->USER_STORAGE_USAGE; $USER_STORAGE_LIMIT = $cyrus->USER_STORAGE_LIMIT; $FREE = $free; writelogs("USER_STORAGE_USAGE={$USER_STORAGE_USAGE}", __FUNCTION__, __FILE__); writelogs("STORAGE_LIMIT={$USER_STORAGE_LIMIT}", __FUNCTION__, __FILE__); if ($USER_STORAGE_LIMIT == null) { $USER_STORAGE_LIMIT = 1000000; $USER_STORAGE_USAGE = 0; $FREE = $USER_STORAGE_LIMIT; } $USER_STORAGE_RESTANT = $USER_STORAGE_LIMIT - $USER_STORAGE_USAGE; if ($USER_STORAGE_RESTANT > 1) { $reste = round($USER_STORAGE_RESTANT / 1024); $data = array($USER_STORAGE_USAGE, $USER_STORAGE_RESTANT); } else { $data = array($USER_STORAGE_USAGE); } $title = $tpl->_ENGINE_parse_body("{your mailbox usage} ({$reste} mb free)"); writelogs("USER_STORAGE_USAGE={$USER_STORAGE_USAGE} - USER_STORAGE_LIMIT={$USER_STORAGE_LIMIT} FREE={$FREE}", __FUNCTION__, __FILE__); $date = date('Y-m-d'); $textes = array(); $donnees = array(); $zlabel = array(); $date = date('Y-m-d'); $donnees[] = $FREE; $textes[] = "{$FREE} Free"; $donnees[] = $USER_STORAGE_USAGE; $textes[] = "{$USER_STORAGE_USAGE} used"; $data = $donnees; $graph = new PieGraph(370, 350, 'auto'); //$graph->SetShadow(); $graph->title->Set($title); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($data); $p1->SetLabels($textes, 1); $p1->SetEdge('black', 0); $p1->SetAngle(55); $p1->SetLabelMargin(2); $p1->SetCenter(0.4, 0.5); $p1->ExplodeAll(10); $graph->Add($p1); $graph->SetFrame(false); $graph->StrokeCSIM(); }