<?php include_once "../jpgraph.php"; include_once "../jpgraph_pie.php"; // Some data $data = array(40, 21, 17, 14, 23); // Create the Pie Graph. $graph = new PieGraph(300, 200, 'auto'); $graph->SetShadow(); // Set A title for the plot $graph->title->Set("Client side image map"); $graph->title->SetFont(FF_FONT1, FS_BOLD); // Create $p1 = new PiePlot($data); $p1->SetCenter(0.4, 0.5); $p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul")); $targ = array("pie_csimex1.php#1", "pie_csimex1.php#2", "pie_csimex1.php#3", "pie_csimex1.php#4", "pie_csimex1.php#5", "pie_csimex1.php#6"); $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d"); $p1->SetCSIMTargets($targ, $alts); $graph->Add($p1); // Send back the HTML page which will call this script again // to retrieve the image. $graph->StrokeCSIM('pie_csimex1.php'); ?>
$legends[] = $currentLabel . ' - ' . $amounts[$currentKey]->getFormatted(); } $targets = array(); foreach ($labels as $currentId => $currentLabel) { if ($currentId != 'none' && $currentId != 'other') { $targets[] = 'javascript:reachThroughCategory(\'' . substr($currentId, 1) . '\');'; } else { $targets[] = ''; } } $pie = new PiePlot3D($data); $pie->SetLegends($legends); $pie->SetCSIMTargets($targets, $dataNames); $pie->value->SetFont(FF_VERA); $pie->value->SetFormatCallback('formatPercentage'); $pie->SetCenter(0.33, 0.5); //$pie->SetSliceColors($chartColors); $graph->Add($pie); $graph->legend->SetFont(FF_VERA); $graph->legend->SetPos(0.03, 0.05); $graph->SetMargin(10, 10, 10, 10); $graph->SetShadow(); $graph->SetAntiAliasing(); $graph->StrokeCSIM(basename(__FILE__)); require_once BADGER_ROOT . "/includes/fileFooter.php"; function formatPercentage($val) { global $us; $str = sprintf('%1.2f %%', $val); return str_replace('.', $us->getProperty('badgerDecimalSeparator'), $str); }
// The label array values may have printf() formatting in them. The argument to the // form,at string will be the value of the slice (either the percetage or absolute // depending on what was specified in the SetLabelType() above. $lbl = array("adam\n%.1f%%", "bertil\n%.1f%%", "johan\n%.1f%%", "peter\n%.1f%%", "daniel\n%.1f%%", "erik\n%.1f%%"); $p1->SetLabels($lbl); // Uncomment this line to remove the borders around the slices // $p1->ShowBorder(false); // Add drop shadow to slices $p1->SetShadow(); // Explode all slices 15 pixels $p1->ExplodeAll(15); // Setup the CSIM targets $targ = array("piec_csimex1.php#1", "piec_csimex1.php#2", "piec_csimex1.php#3", "piec_csimex1.php#4", "piec_csimex1.php#5", "piec_csimex1.php#6"); $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d"); $p1->SetCSIMTargets($targ, $alts); $p1->SetMidCSIM("piec_csimex1.php#7", "Center"); // Setup a small help text in the image $txt = new Text("Note: This is an example of image map. Hold\nyour mouse over the slices to see the values.\nThe URL just points back to this page"); $txt->SetFont(FF_FONT1, FS_BOLD); $txt->SetPos(0.5, 0.97, 'center', 'bottom'); $txt->SetBox('yellow', 'black'); $txt->SetShadow(); $graph->AddText($txt); // Add plot to pie graph $graph->Add($p1); // .. and send the image on it's marry way to the browser $graph->StrokeCSIM(); ?>
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(); }