function execute() { $this->set_title('Statistics Center'); $this->tree('Statistics Center'); if (!extension_loaded('gd')) { return $this->message('JpGraph Error', 'You need to install the correct GD libraries to run the Statistics centre (GD Libraries were not detected)'); } include '../lib/jpgraph/jpgraph.php'; include '../lib/jpgraph/jpgraph_bar.php'; if (!defined('IMG_PNG')) { return $this->message('JpGraph Error', 'This PHP installation is not configured with PNG support. Please recompile PHP with GD and JPEG support to run JpGraph. (Constant IMG_PNG does not exist)'); } /** * Posts */ $query = $this->db->query("\r\n\t\tSELECT\r\n\t\t COUNT(post_id) AS posts,\r\n\t\t FROM_UNIXTIME(post_time, '%b %y') AS month\r\n\t\tFROM {$this->pre}posts\r\n\t\tGROUP BY month\r\n\t\tORDER BY post_time"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['posts']; } if (!$data) { $data = array(0, 0); } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set('Posts by Month'); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}1.png"); /** * Registrations */ $query = $this->db->query("\r\n\t\tSELECT\r\n\t\t COUNT(user_id) AS users,\r\n\t\t FROM_UNIXTIME(user_joined, '%b %y') AS month\r\n\t\tFROM {$this->pre}users\r\n\t\tWHERE user_joined != 0\r\n\t\tGROUP BY month\r\n\t\tORDER BY user_joined"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['users']; } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set('Registrations by Month'); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}2.png"); return $this->message('Statistics Center', "<img src='{$this->time}1.png' alt='Posts by Month' /><br /><br />\r\n\t\t<img src='{$this->time}2.png' alt='Registrations by Month' />"); }
function execute() { $this->set_title($this->lang->stats); $this->tree($this->lang->stats); include '../lib/jpgraph/jpgraph.php'; include '../lib/jpgraph/jpgraph_bar.php'; if (!defined('IMG_PNG')) { JpGraphError::Raise("This PHP installation is not configured with PNG support. Please recompile PHP with GD and JPEG support to run JpGraph. (Constant IMG_PNG does not exist)"); } /** * Posts */ $query = $this->db->query("SELECT COUNT(post_id) AS posts, FROM_UNIXTIME(post_time, '%%b %%y') AS month\n\t\t\tFROM %pposts GROUP BY month\tORDER BY post_time"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['posts']; } if (!$data) { $data = array(0, 0); } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_post_by_month); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("../stats/{$this->time}1.png"); /** * Registrations */ $query = $this->db->query("SELECT COUNT(user_id) AS users, FROM_UNIXTIME(user_joined, '%%b %%y') AS month\n\t\t\tFROM %pusers\n\t\t\tWHERE user_joined != 0\n\t\t\tGROUP BY month\n\t\t\tORDER BY user_joined"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['users']; } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_reg_by_month); $temp = array_values($data); $barplot = new BarPlot($temp); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("../stats/{$this->time}2.png"); return $this->message($this->lang->stats, "<img src='../stats/{$this->time}1.png' alt='{$this->lang->stats_post_by_month}' /><br /><br />\n\t\t<img src='../stats/{$this->time}2.png' alt='{$this->lang->stats_reg_by_month}' />"); }
function execute() { $this->set_title($this->lang->stats); $this->tree($this->lang->stats); include '../lib/jpgraph/jpgraph.php'; include '../lib/jpgraph/jpgraph_bar.php'; /** * Posts */ $query = $this->db->query("\n\t\tSELECT\n\t\t COUNT(post_id) AS posts,\n\t\t FROM_UNIXTIME(post_time, '%b %y') AS month\n\t\tFROM {$this->pre}posts\n\t\tGROUP BY month\n\t\tORDER BY post_time"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['posts']; } if (!$data) { $data = array(0, 0); } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_post_by_month); $barplot = new BarPlot(array_values($data)); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}1.png"); /** * Registrations */ $query = $this->db->query("\n\t\tSELECT\n\t\t COUNT(user_id) AS users,\n\t\t FROM_UNIXTIME(user_joined, '%b %y') AS month\n\t\tFROM {$this->pre}users\n\t\tWHERE user_joined != 0\n\t\tGROUP BY month\n\t\tORDER BY user_joined"); $data = array(); while ($item = $this->db->nqfetch($query)) { $data[$item['month']] = $item['users']; } $graph = new Graph(400, 300, 'auto'); $graph->SetScale('textint'); $graph->SetColor('aliceblue'); $graph->SetMarginColor('white'); $graph->xaxis->SetTickLabels(array_keys($data)); $graph->yaxis->scale->SetGrace(20); $graph->title->Set($this->lang->stats_reg_by_month); $barplot = new BarPlot(array_values($data)); $barplot->SetFillColor('darkorange'); $graph->add($barplot); $graph->Stroke("{$this->time}2.png"); return $this->message($this->lang->stats, "<img src='{$this->time}1.png' alt='{$this->lang->stats_post_by_month}' /><br /><br />\n\t\t<img src='{$this->time}2.png' alt='{$this->lang->stats_reg_by_month}' />"); }
function plot() { $this->_setValues(); $graph = new Graph(380, 250); $graph->img->SetMargin(50, 30, 40, 40); $graph->SetShadow(); $graph->SetColor("lightyellow"); $graph->SetScale("textlin"); $graph->title->Set($this->_graphTitle); $graph->yaxis->SetColor("blue"); $graph->xaxis->SetColor("blue"); $graph->title->SetFont(FONT1_BOLD); $graph->xaxis->SetTickLabels($this->_xaxisValues); $lineplot = new LinePlot($this->_yaxisValues); $lineplot->SetColor("red"); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); }
public function executeBarGraph() { //Set the response header to a image JPEG datastream $this->getResponse()->setContent('image/jpeg'); // Change this defines to where Your fonts are stored DEFINE("TTF_DIR", "/usr/share/fonts/truetype/freefont/"); // Change this define to a font file that You know that You have DEFINE("TTF_SANS", "FreeSans.ttf"); $util = new util(); $dataDVDrip = $util->getTotalFormat('DVDrip', 'movies'); $dataHDrip = $util->getTotalFormat('HDrip', 'movies'); $data720p = $util->getTotalFormat('720p', 'movies'); $data1080p = $util->getTotalFormat('1080p', 'movies'); $datay = array($dataDVDrip, $dataHDrip, $data720p, $data1080p); $graph = new Graph(199, 145); $graph->SetScale('textlin'); $graph->SetColor('black'); $graph->SetMarginColor('#393939'); $graph->SetFrame(true, '#393939'); $top = 25; $bottom = 20; $left = 50; $right = 20; $graph->Set90AndMargin($left, $right, $top, $bottom); // Setup labels $lbl = array("DVDrip", "HDrip", "720p", "1080p"); $graph->xaxis->SetTickLabels($lbl); $graph->xaxis->SetColor('white'); $graph->xaxis->SetLabelAlign('right', 'center', 'right'); $graph->yaxis->SetLabelAlign('center', 'bottom'); $graph->yaxis->SetColor('white'); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetWidth(0.5); $bplot->SetFillGradient(array(250, 2, 2), array(109, 2, 2), GRAD_VERT); $graph->Add($bplot); $graph->Stroke(); return sfView::NONE; }
for ($i = 0; $i < $n; ++$i) { $y2data[] = $ydata[$i] + 10; } // Negate all data $n = count($ydata); for ($i = 0; $i < $n; ++$i) { $ydata[$i] = round(-$ydata[$i]); $y2data[$i] = round(-$y2data[$i]); } // Basic graph setup $graph = new Graph(400, 300); $graph->SetScale("linlin"); $graph->SetY2Scale("lin"); $graph->SetMargin(50, 50, 60, 40); $graph->SetMarginColor('darkblue'); $graph->SetColor('darkblue'); // Setup titles $graph->title->Set("Inverting both Y-axis"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->title->SetColor("white"); $graph->subtitle->Set("(Negated Y & Y2 axis)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $graph->subtitle->SetColor("white"); // Setup axis $graph->yaxis->SetLabelFormatCallback("_cb_negate"); $graph->xaxis->SetColor("lightblue", "white"); $graph->yaxis->SetColor("lightblue", "white"); $graph->ygrid->SetColor("blue"); // Setup Y2 axis $graph->y2axis->SetLabelFormatCallback("_cb_negate"); $graph->y2axis->SetColor("darkred", "white");
$timeline .= "bis {$day}.{$month}.{$year} "; } else { list($month, $year) = split('[/]', $thestart); $thestart = "{$year}-{$month}-01 00:00:00"; $timeline = "vom 1.{$month}.{$year} "; list($month, $year) = split('[/]', $theend); $theend = "{$year}-{$month}-01 00:00:00"; $data = $statistics->get($thestart, $theend, $thecat3, $from_clock3, $till_clock3); $timeline .= "bis 1.{$month}.{$year} "; } for ($i = 0; $i < count($data); $i++) { $labels[$i] = $data[$i]['description']; $gdata[$i] = $data[$i]['num']; } $graph = new Graph(700, 500, "auto"); $graph->SetColor("white"); $graph->SetFrame(false); $graph->SetScale("textlin"); $graph->title->Set("Verkaufte Artikel {$timeline}"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->title->Set("Artikel"); $graph->yaxis->title->Set("Stückzahl"); $graph->yaxis->SetTitleMargin(45); $graph->xaxis->SetTickLabels($labels); $graph->img->SetMargin(60, 40, 40, 150); $barplot = new BarPlot($gdata); $barplot->SetColor(array("red", "green", "blue", "gray", "yellow")); $barplot->SetFillColor(array("red", "green", "blue", "gray", "yellow"));
<?php include "../jpgraph.php"; include "../jpgraph_line.php"; $f = new FuncGenerator('cos($i)', '$i*$i*$i'); list($xdata, $ydata) = $f->E(-M_PI, M_PI, 25); $graph = new Graph(350, 430, "auto"); $graph->SetScale("linlin"); $graph->SetShadow(); $graph->img->SetMargin(50, 50, 60, 40); $graph->SetBox(true, 'black', 2); $graph->SetMarginColor('white'); $graph->SetColor('lightyellow'); $graph->SetAxisStyle(AXSTYLE_BOXIN); $graph->xgrid->Show(); //$graph->xaxis->SetLabelFormat('%.0f'); $graph->img->SetMargin(50, 50, 60, 40); $graph->title->Set("Function plot"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->subtitle->Set("(BOXIN Axis style)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $lp1 = new LinePlot($ydata, $xdata); $lp1->SetColor("blue"); $lp1->SetWeight(2); $graph->Add($lp1); $graph->Stroke(); ?>
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; // Some data $datay = array(7, 19, 11, 4, 20); // Create the graph and setup the basic parameters $graph = new Graph(300, 200, 'auto'); $graph->img->SetMargin(40, 30, 40, 50); $graph->SetScale("textint"); $graph->SetFrame(true, 'blue', 1); $graph->SetColor('lightblue'); $graph->SetMarginColor('lightblue'); // Setup X-axis labels $a = $gDateLocale->GetShortMonth(); $graph->xaxis->SetTickLabels($a); $graph->xaxis->SetFont(FF_FONT1); $graph->xaxis->SetColor('darkblue', 'black'); // Setup "hidden" y-axis by given it the same color // as the background (this could also be done by setting the weight // to zero) $graph->yaxis->SetColor('lightblue', 'darkblue'); $graph->ygrid->SetColor('white'); // Setup graph title ands fonts $graph->title->Set('Using grace = 50%'); $graph->title->SetFont(FF_FONT2, FS_BOLD); $graph->xaxis->SetTitle('Year 2002', 'center'); $graph->xaxis->SetTitleMargin(10); $graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD); // Add some grace to the top so that the scale doesn't
<?php include "../jpgraph.php"; include "../jpgraph_bar.php"; //include ("../jpgraph_flags.php"); // Some data $datay1 = array(140, 110, 50); $datay2 = array(35, 90, 190); $datay3 = array(20, 60, 70); // Create the basic graph $graph = new Graph(300, 200); $graph->SetScale("textlin"); $graph->SetMargin(40, 20, 20, 40); $graph->SetMarginColor('white:0.9'); $graph->SetColor('white'); $graph->SetShadow(); // Adjust the position of the legend box $graph->legend->Pos(0.03, 0.1); // Adjust the color for theshadow of the legend $graph->legend->SetShadow('darkgray@0.5'); $graph->legend->SetFillColor('lightblue@0.1'); $graph->legend->Hide(); // Get localised version of the month names $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); //$graph->SetBackgroundCountryFlag('mais',BGIMG_COPY,50); // Set axis titles and fonts $graph->xaxis->title->Set('Year 2002'); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetColor('white'); $graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetColor('navy');
$mph[] = $thisMPH; $alti[] = $thisALTI; } $lts = $timestamp; } // End of while include "../../../include/jpgraph/jpgraph.php"; include "../../../include/jpgraph/jpgraph_line.php"; include "../../../include/jpgraph/jpgraph_date.php"; include "../../../include/jpgraph/jpgraph_scatter.php"; // Create the graph. These two calls are always required $graph = new Graph(640, 480); $graph->SetScale('datlin', 0, 360); $graph->SetYScale(0, 'lin', 0, 60); $graph->SetYScale(1, 'lin'); $graph->SetColor("#f0f0f0"); $graph->img->SetMargin(55, 110, 55, 60); $graph->title->Set("Polk City, Iowa SchoolNet Sub 1 Minute Time Series"); $graph->title->SetFont(FF_FONT1, FS_BOLD, 20); $graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetTitle("Times on the morning of 2 Oct 2007"); $graph->xaxis->SetTitleMargin(27); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD, 12); $graph->xaxis->SetPos("min"); $graph->xaxis->SetLabelFormatString("h:i", true); $graph->xaxis->scale->SetTimeAlign(MINADJ_1); $graph->xaxis->SetLabelAngle(90); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD, 14); $graph->yaxis->scale->ticks->Set(45, 15); $graph->yaxis->SetTitle("Wind Direction (blue dots)"); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$data = $datavalue[$i]; $target = $target_val[$i]; $graph_data = explode(",", $data); $data[$i] = $data; $bplot[$i] = new BarPlot($graph_data); $bplot[$i]->SetFillColor($color_array[$i]); $bplot[$i]->SetWidth(10); $bplot[$i]->value->Show(); $bplot[$i]->value->SetFont(FF_FONT1, FS_NORMAL, 8); $bplot[$i]->value->SetColor("black"); $bplot[$i]->value->SetFormat('%d'); $bplot[$i]->SetValuePos('max'); } $gbplot = new AccBarPlot($bplot); $gbplot->SetWidth(0.7); // Add the bar to the graph $graph->Add($gbplot); $graph->xaxis->SetTickLabels($datax); $graph->title->Set($title); $graph->Set90AndMargin($left, $right, $top, $bottom); //$graph->SetFrame(false); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->SetColor("#7D9CB8"); $graph->SetMarginColor("#3D6A93"); // Display the graph $graph->Stroke(); ?>
require_once 'jpgraph/jpgraph_log.php'; // Matrix size rxr $r = 10; // Max Interpolation factor $f = 5; for ($i = 1; $i <= $f; ++$i) { $xdata[] = $i; $ydata[] = pow($r * pow(2, $i - 1) - (pow(2, $i) - 1), 2); } $graph = new Graph(400, 240); $graph->SetScale('intlog'); $graph->SetMargin(50, 50, 20, 30); $graph->SetFrame(false); $graph->SetBox(true, 'black', 2); $graph->SetMarginColor('white'); $graph->SetColor('lightyellow@0.7'); $graph->title->Set('Interpolation growth for size 10x10'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetTitle('Interpolation factor', 'center'); $graph->xaxis->SetTitleMargin(10); $graph->SetAxisStyle(AXSTYLE_YBOXIN); $graph->xgrid->Show(); $lp1 = new LinePlot($ydata, $xdata); $lp1->SetColor('darkred'); $lp1->SetWeight(3); $graph->Add($lp1); $graph->Stroke(); ?>
$data_closed_count_arr[] = get_closed_count_by_date($val); } foreach ($data_date_arr as $key => $val) { $data_date_arr[$key] = $val . ' '; } $proj_name = project_get_field($t_project_id, 'name'); # Setup Graph # --- $graph = new Graph(800, 600, "auto"); $graph->img->SetMargin(40, 20, 40, 90); if (ON == config_get_global('jpgraph_antialias')) { $graph->img->SetAntiAliasing("white"); } $graph->SetScale("textlin"); $graph->SetShadow(); $graph->SetColor('whitesmoke'); $graph->title->Set("Cumulative - New, Resolved and Closed: {$proj_name}"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetFont(FF_FONT1, FS_NORMAL, 5); $graph->xaxis->SetTickLabels($data_date_arr); $graph->xaxis->SetLabelAngle(90); $graph->legend->Pos(0.75, 0.2); # OPEN $p1 = new LinePlot($data_open_count_arr); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("blue"); $p1->mark->SetWidth(3); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend("Total"); $graph->Add($p1);
// content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_utils.inc.php'; $f = new FuncGenerator('cos($x)*$x'); list($xdata, $ydata) = $f->E(-1.2 * M_PI, 1.2 * M_PI); $f = new FuncGenerator('$x*$x'); list($x2data, $y2data) = $f->E(-2, 2); // Setup the basic graph $graph = new Graph(450, 350); $graph->SetScale("linlin"); //$graph->SetShadow(); $graph->img->SetMargin(5, 10, 60, 9); $graph->SetBox(true, 'green', 2); $graph->SetMarginColor('black'); $graph->SetColor('black'); // ... and titles $graph->title->Set('Example of Function plot'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->title->SetColor('lightgreen'); $graph->subtitle->Set("(With some more advanced axis formatting\nHiding first and last label)"); $graph->subtitle->SetFont(FF_FONT1, FS_NORMAL); $graph->subtitle->SetColor('lightgreen'); $graph->xgrid->Show(); $graph->xgrid->SetColor('darkgreen'); $graph->ygrid->SetColor('darkgreen'); $graph->yaxis->SetPos(0); $graph->yaxis->SetWeight(2); $graph->yaxis->HideZeroLabel(); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetColor('green', 'green');
include "../../../include/jpgraph/jpgraph_bar.php"; include "../../../include/jpgraph/jpgraph_date.php"; include "../../../include/jpgraph/jpgraph_led.php"; if (pg_num_rows($rs) == 0) { $led = new DigitalLED74(); $led->StrokeNumber('NO TRAFFIC DATA AVAILABLE', LEDC_GREEN); die; } include "../../../include/network.php"; $nt = new NetworkTable("IA_RWIS"); $cities = $nt->table; // Create the graph. These two calls are always required $graph = new Graph(650, 550, "example1"); $graph->SetScale("datlin"); $graph->SetMarginColor("white"); $graph->SetColor("lightyellow"); $graph->img->SetMargin(40, 55, 105, 105); //$graph->xaxis->SetFont(FS_FONT1,FS_BOLD); $graph->yaxis->SetTitle("Average Speed [mph]"); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12); $graph->xaxis->SetTitle("Time Period: " . date('Y-m-d h:i A', $times[0][0]) . " thru " . date('Y-m-d h:i A', max($times[0]))); $graph->xaxis->SetTitleMargin(67); $graph->xaxis->title->SetFont(FF_VERA, FS_BOLD, 12); $graph->xaxis->title->SetColor("brown"); $graph->xaxis->SetPos("min"); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetLabelFormatString("M-j h A", true); $graph->legend->Pos(0.01, 0.01); $graph->legend->SetLayout(LEGEND_VERT); $colors = array(0 => "green", 1 => "black", 2 => "blue", 3 => "red", 4 => "purple", 5 => "tan", 6 => "pink", 7 => "lavendar"); while (list($k, $v) = each($times)) {
public static function show() { $level_id = wbRequest::getVarClean('level_id', 'int', 0); $tahun = wbRequest::getVarClean('tahun', 'str', ''); //timestamp $t = wbRequest::getVarClean('t', 'str', ''); if (empty($level_id) or empty($tahun)) { exit; } try { $ws_client = self::getNusoap(); $params = array('search' => '', 'getParams' => json_encode($_GET), 'controller' => json_encode(array('module' => 'bds', 'class' => 'dashboard_pendidikan', 'method' => 'show', 'type' => '')), 'postParams' => json_encode($_POST), 'jsonItems' => '', 'start' => $start, 'limit' => $limit); $ws_data = self::getResultData($ws_client, $params); $data['items'] = $ws_data['data']; $data['total'] = $ws_data['total']; $data['message'] = $ws_data['message']; $data['success'] = $ws_data['success']; } catch (Exception $e) { $data['message'] = $e->getMessage(); } $items = $data['items']['items']; $itemLevel = $data['items']['itemLevel']; //$items = $tSchoolType->getAllByLevelID($level_id, $tahun); //$itemLevel = $tSchoolLevel->get($level_id); $print = wbRequest::getVarClean('print', 'int', 0); if (!empty($print)) { wbUtil::startExcel('pendidikan_dashboard.xls'); } echo '<div class="body-wrap">'; echo '<div style="float:left;margin:5 5 0 5;">'; echo '<div><h3>JUMLAH SISWA ' . strtoupper($itemLevel['description']) . ' <br/>BERDASARKAN JENISNYA - TAHUN ' . $tahun . '</h3></div>'; if (!empty($print)) { echo '<table border="1" width ="100%">'; } else { echo '<table border="0" class="table-data" width ="100%">'; } echo '<tr> <th width="15">No</th> <th width="150">Jenis ' . $itemLevel['description'] . '</th> <th width="100">Jumlah Masuk </th> <th width="100">Jumlah Lulus </th> <th width="100">Jumlah Aktif </th> </tr>'; $i = 1; $datay = array(); $dataCode = array(); foreach ($items as $item) { $datay[] = $item['jml_masuk']; $dataCode[] = $item['code']; echo '<tr>'; echo '<td>' . $i++ . '</td>'; echo '<td>' . $item['code'] . '</td>'; echo '<td align="right">' . wbUtil::numberFormat($item['jml_masuk'], 0) . '</td>'; echo '<td align="right">' . wbUtil::numberFormat($item['jml_lulus'], 0) . '</td>'; echo '<td align="right">' . wbUtil::numberFormat($item['jml_aktif'], 0) . '</td>'; echo '</tr>'; } echo '</table>'; wbCore::loadJPGraph(); // Create the graph and setup the basic parameters $graph = new Graph(550, 300, 'auto'); $graph->img->SetMargin(40, 30, 40, 40); $graph->SetScale("textint"); $graph->SetFrame(true, 'white', 1); $graph->SetColor('#C9C9C9'); $graph->SetMarginColor('#D0DEF0'); // Add some grace to the top so that the scale doesn't // end exactly at the max value. //$graph->yaxis->scale->SetGrace(20); // Setup X-axis labels $graph->xaxis->SetTickLabels($dataCode); $graph->xaxis->SetFont(FF_FONT1); $graph->xaxis->SetColor('#400000', 'black'); // Stup "hidden" y-axis by given it the same color // as the background $graph->yaxis->SetColor('lightblue', '#004080'); $graph->ygrid->SetColor('white'); // Setup graph title ands fonts $graph->title->Set('GRAFIK SISWA ' . strtoupper($itemLevel['description']) . ' - TAHUN ' . $tahun); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetFillColor('#6C6CFF'); $bplot->SetColor('darkblue'); $bplot->SetWidth(0.5); $bplot->SetShadow('darkgray'); // Setup the values that are displayed on top of each bar $bplot->value->Show(); // Must use TTF fonts if we want text at an arbitrary angle $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8); $bplot->value->SetFormat('%d'); // Black color for positive values and darkred for negative values $bplot->value->SetColor("black", "darkred"); $graph->Add($bplot); // Finally stroke the graph $graph->Stroke('var/dashboard/dashboard_pendidikan.png'); echo '</div>'; echo '</div>'; echo '<div style="float:right;margin:15 5 0 5;"> <img src="' . wbServer::getBaseURL() . 'var/dashboard/dashboard_pendidikan.png?' . $t . '" alt="' . $t . '" /> </div>'; exit; }
public static function show() { $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); $jenis_jalan = wbRequest::getVarClean('jenis_jalan', 'int', 0); if (empty($jenis_jalan)) { exit; } try { $ws_client = self::getNusoap(); $params = array('search' => '', 'getParams' => json_encode($_GET), 'controller' => json_encode(array('module' => 'bds', 'class' => 'dashboard_jalan', 'method' => 'show', 'type' => '')), 'postParams' => json_encode($_POST), 'jsonItems' => '', 'start' => $start, 'limit' => $limit); $ws_data = self::getResultData($ws_client, $params); $data['items'] = $ws_data['data']; $data['total'] = $ws_data['total']; $data['message'] = $ws_data['message']; $data['success'] = $ws_data['success']; } catch (Exception $e) { $data['message'] = $e->getMessage(); } $items = $data['items']; echo '<div class="body-wrap">'; echo '<div style="float:left;margin:5 5 0 5;">'; echo '<div><h3>DATA JALAN</h3></div>'; echo '<table class="table-data">'; echo '<tr> <th width="30">No</th> <th width="200">Jenis Jalan</th> <th width="100">Panjang(Km)</th> </tr>'; $i = 1; $datay = array(); $dataCode = array(); foreach ($items as $item) { $datay[] = $item['panjang']; $dataCode[] = $item['param_name']; echo '<tr>'; echo '<td>' . $i++ . '</td>'; echo '<td>' . $item['param_name'] . '</td>'; echo '<td align="right">' . wbUtil::numberFormat($item['panjang'], 0) . '</td>'; echo '</tr>'; } echo '</table>'; wbCore::loadJPGraph(); // Create the graph and setup the basic parameters $graph = new Graph(550, 300, 'auto'); $graph->img->SetMargin(40, 30, 40, 40); $graph->SetScale("textint"); $graph->SetFrame(true, 'white', 1); $graph->SetColor('#C9C9C9'); $graph->SetMarginColor('#D0DEF0'); // Add some grace to the top so that the scale doesn't // end exactly at the max value. //$graph->yaxis->scale->SetGrace(20); // Setup X-axis labels $graph->xaxis->SetTickLabels($dataCode); $graph->xaxis->SetFont(FF_FONT1); $graph->xaxis->SetColor('#400000', 'black'); // Stup "hidden" y-axis by given it the same color // as the background $graph->yaxis->SetColor('lightblue', '#004080'); $graph->ygrid->SetColor('white'); // Setup graph title ands fonts $graph->title->Set('DATA JALAN'); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetFillColor('#6C6CFF'); $bplot->SetColor('darkblue'); $bplot->SetWidth(0.5); $bplot->SetShadow('darkgray'); // Setup the values that are displayed on top of each bar $bplot->value->Show(); // Must use TTF fonts if we want text at an arbitrary angle $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8); $bplot->value->SetFormat('%d'); // Black color for positive values and darkred for negative values $bplot->value->SetColor("black", "darkred"); $graph->Add($bplot); // Finally stroke the graph $graph->Stroke('var/dashboard/dashboard_jalan.png'); echo '</div>'; echo '</div>'; echo '<div style="float:right;margin:15 5 0 5;"> <img src="var/dashboard/dashboard_jalan.png?' . $t . '" alt="' . $t . '" /> </div>'; exit; }
$graph->xaxis->SetLabelFormatString("h A", true); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetTitleMargin(50); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 14); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD, 12); //$graph->yaxis->title->SetBox( array(150,150,150), $tcolor, true); //$graph->yaxis->title->SetColor( $tcolor ); $graph->yaxis->SetTitleMargin(50); $graph->yscale->SetGrace(10); $graph->y2axis->title->SetFont(FF_FONT1, FS_BOLD, 14); $graph->y2axis->SetFont(FF_FONT1, FS_BOLD, 12); //$graph->y2axis->title->SetBox( array(150,150,150), $tcolor, true); //$graph->y2axis->title->SetColor( $tcolor ); $graph->y2axis->SetTitleMargin(40); $graph->tabtitle->SetFont(FF_FONT1, FS_BOLD, 16); $graph->SetColor('wheat'); $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->SetPos(0.01, 0.9399999999999999, 'left', 'top'); $graph->legend->SetLineSpacing(3); $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCEE@0.5'); $graph->ygrid->Show(); $graph->xgrid->Show(); $graph->yaxis->scale->ticks->SetLabelFormat("%5.1f"); $graph->yaxis->scale->ticks->SetLabelFormat("%5.0f"); $graph->y2axis->scale->ticks->Set(100, 25); $graph->y2axis->scale->ticks->SetLabelFormat("%-4.0f"); // Create the linear plot $lineplot = new LinePlot($temps, $times); $lineplot->SetLegend("Temperature"); $lineplot->SetColor("red"); //$lineplot->SetWeight(2);
case 50: $low_count_arr[2] = $count; break; case 60: $none_count_arr[2] = $count; break; case 70: $duplicate_count_arr[2] = $count; break; } } $proj_name = project_get_field($t_project_id, 'name'); # Setup Graph # --- $graph = new Graph(800, 600, 'auto'); $graph->SetColor("whitesmoke"); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->img->SetMargin(40, 30, 40, 40); $graph->xaxis->SetTickLabels(array('Open', 'Resolved', 'Closed')); $graph->xaxis->title->Set("Status"); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->title->Set("Severity vs. Status Distribution: {$proj_name}"); $graph->title->SetFont(FF_FONT1, FS_BOLD); # Create graph $bplot1 = new BarPlot($critical_count_arr); $bplot2 = new BarPlot($high_count_arr); $bplot3 = new BarPlot($medium_count_arr); $bplot4 = new BarPlot($low_count_arr); $bplot5 = new BarPlot($none_count_arr); $bplot6 = new BarPlot($duplicate_count_arr);
function top($VAR) { global $smarty, $C_translate, $C_auth; # Get the period type, default to month if (empty($VAR['period'])) { $p = 'm'; } else { $p = $VAR['period']; } # Load the jpgraph class include PATH_GRAPH . "jpgraph.php"; include PATH_GRAPH . "jpgraph_bar.php"; # check the validation for this function if (!$C_auth->auth_method_by_name($this->module, 'search')) { $error = $C_translate->translate('module_non_auth', '', ''); include PATH_GRAPH . "jpgraph_canvas.php"; $graph = new CanvasGraph(460, 55, "auto"); $t1 = new Text($error); $t1->Pos(0.2, 0.5); $t1->SetOrientation("h"); $t1->SetBox("white", "black", 'gray'); $t1->SetFont(FF_FONT1, FS_NORMAL); $t1->SetColor("black"); $graph->AddText($t1); $graph->Stroke(); exit; } # Get the period start & end switch ($p) { # By Weeks: case 'w': $interval = "1"; $width = ".9"; $title = 'Top Accounts for Last Last Week'; $dow = date('w'); $start_str = mktime(0, 0, 0, date('m'), date('d') - $dow, date('y')); $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y')); break; # By Months: # By Months: case 'm': $interval = "3"; $width = ".6"; $title = 'Top Accounts for Last Last Month'; $start_str = mktime(0, 0, 0, date('m'), 1, date('y')); $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y')); break; # By Years: # By Years: case 'y': $interval = "1"; $width = ".8"; $title = 'Top Accounts for Last Last Year'; $start_str = mktime(0, 0, 0, 1, 1, date('y')); $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y')); break; } ##############################@@@@@@@@ # Get accounts & sales for this period ##############################@@@@@@@@ $db =& DB(); $sql = 'SELECT account_id,total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE date_orig >= ' . $db->qstr($start_str) . ' AND date_orig <= ' . $db->qstr($end_str) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $result = $db->Execute($sql); if (@$result->RecordCount() == 0) { $file = fopen(PATH_THEMES . 'default_admin/images/invisible.gif', 'r'); fpassthru($file); exit; } while (!$result->EOF) { $amt = $result->fields['total_amt']; $acct = $result->fields['account_id']; if (!isset($arr[$acct])) { $arr[$acct] = 0; } $arr[$acct] += $amt; $result->MoveNext(); } $i = 0; while (list($key, $var) = each(@$arr)) { # Get the user name $sql = 'SELECT first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account WHERE id = ' . $db->qstr($key) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $rs = $db->Execute($sql); $_lbl[] = strtoupper(substr($rs->fields['first_name'], 0, 1)) . ". " . $rs->fields['last_name']; $_datay[] = $var; $i++; } ### Sort the arrays array_multisort($_datay, SORT_DESC, SORT_NUMERIC, $_lbl); ### Limit the results to 10 or less for ($i = 0; $i < count($_lbl); $i++) { $lbl[$i] = $_lbl[$i]; $datay[$i] = $_datay[$i]; if ($i >= 9) { $i = count($_lbl); } } $i = count($lbl); # Get the Currency $sql = 'SELECT symbol FROM ' . AGILE_DB_PREFIX . 'currency WHERE id = ' . $db->qstr(DEFAULT_CURRENCY) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $rs = $db->Execute($sql); $currency_iso = $rs->fields['symbol']; // Size of graph $width = 265; $height = 75 + $i * 15; // Set the basic parameters of the graph $graph = new Graph($width, $height, 'auto'); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(50); $graph->SetMarginColor('#F9F9F9'); $graph->SetFrame(true, '#CCCCCC', 1); $graph->SetColor('#FFFFFF'); $top = 45; $bottom = 10; $left = 95; $right = 15; $graph->Set90AndMargin($left, $right, $top, $bottom); // Label align for X-axis $graph->xaxis->SetLabelAlign('right', 'center', 'right'); // Label align for Y-axis $graph->yaxis->SetLabelAlign('center', 'bottom'); $graph->xaxis->SetTickLabels($lbl); // Titles $graph->title->SetFont(FF_FONT1, FS_BOLD, 9.5); $title = $C_translate->translate('graph_top', 'account_admin', ''); $graph->title->Set($title); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetFillColor("#506DC7"); $bplot->SetWidth(0.2); // Show the values $bplot->value->Show(); $bplot->value->SetFont(FF_FONT1, FS_NORMAL, 8); $bplot->value->SetAlign('center', 'center'); $bplot->value->SetColor("black", "darkred"); $bplot->value->SetFormat($currency_iso . '%.2f'); $graph->Add($bplot); $graph->Stroke(); return; }
function BAR_graph($module, $type, $start, $extra_fields) { global $C_translate, $C_auth; include_once PATH_CORE . 'validate.inc.php'; $dt = new CORE_validate(); include PATH_GRAPH . "jpgraph.php"; #################################################################### ### Check if 'search' is authorized for this account #################################################################### # check the validation for this function if ($C_auth->auth_method_by_name($module, 'search')) { # validate this file exists, and include it. if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) { include_once PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'; } else { ### Not exist! $error = $C_translate->translate('module_non_existant', '', ''); } } else { ### Not auth $error = $C_translate->translate('module_non_auth', '', ''); } if (isset($error)) { include PATH_GRAPH . "jpgraph_canvas.php"; // Create the graph. $graph = new CanvasGraph(460, 55, "auto"); $t1 = new Text($error); $t1->Pos(0.2, 0.5); $t1->SetOrientation("h"); $t1->SetBox("white", "black", 'gray'); $t1->SetFont(FF_FONT1, FS_NORMAL); $t1->SetColor("black"); $graph->AddText($t1); $graph->Stroke(); exit; } #################################################################### ### BY WEEK #################################################################### if ($type == 'week') { $FONT_SIZE = 7; $AbsWidth = 12; $interval = 4; $type = $C_translate->translate('week', '', ''); if ($start == "" || $start <= 12) { ## Get the beginning/end of this week $start_str = mktime(24, 0, 0, 12, 31, date("Y") - 1); $start = date(UNIX_DATE_FORMAT, $start_str); $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str)); $end = date(UNIX_DATE_FORMAT, $end_str); } else { ## Get the beginning/end of the specified week $start_str = mktime(24, 0, 0, 12, 31, date("{$start}") - 1); $start = date(UNIX_DATE_FORMAT, $start_str); $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str)); $end = date(UNIX_DATE_FORMAT, $end_str); } ### Set the constraint array: $curr_str = $start_str; while ($curr_str <= $end_str) { $new_curr_str = mktime(0, 0, 0, date("m", $curr_str), date("d", $curr_str) + 7, date("Y", $curr_str)); $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str); $curr_str = $new_curr_str; $default_array[] = 0; } } else { if ($type == 'month') { $FONT_SIZE = 10; $AbsWidth = 12; $TickLables = $gDateLocale->GetShortMonth(); $interval = 1; $type = $C_translate->translate('month', '', ''); if ($start == "" || $start < 12) { ## Get the beginning/end of this week $start_str = mktime(24, 0, 0, 12, 31, date("Y") - 1); $start = date(UNIX_DATE_FORMAT, $start_str); $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str)); $end = date(UNIX_DATE_FORMAT, $end_str); } else { ## Get the beginning/end of the specified week ## Get the beginning/end of this week $start_str = mktime(24, 0, 0, 12, 31, date("{$start}") - 1); $start = date(UNIX_DATE_FORMAT, $start_str); $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str)); $end = date(UNIX_DATE_FORMAT, $end_str); } ### Set the constraint array: $curr_str = $start_str; while ($curr_str <= $end_str) { $new_curr_str = mktime(0, 0, 0, date("m", $curr_str) + 1, date("d", $curr_str), date("Y", $curr_str)); $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str); $curr_str = $new_curr_str; $default_array[] = 0; } } else { if ($type == 'year') { $FONT_SIZE = 10; $interval = 1; $AbsWidth = 13; $type = $C_translate->translate('year', '', ''); ## Get the beginning/end of this year - 10 $start_str = mktime(0, 0, 0, 1, 1, date("Y") - 9); $start = date(UNIX_DATE_FORMAT, $start_str); $end_str = mktime(0, 0, 0, 12, 30, date("Y", $start_str) + 9); $end = date(UNIX_DATE_FORMAT, $end_str); ### Set the constraint array: $curr_str = $start_str; while ($curr_str <= $end_str) { $new_curr_str = mktime(0, 0, 0, date("m", $curr_str), date("d", $curr_str), date("Y", $curr_str) + 1); $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str); $TickLables[] = date("Y", $curr_str); $curr_str = $new_curr_str; $default_array[] = 0; } } else { $FONT_SIZE = 8; $interval = 3; $AbsWidth = 4; $type = $C_translate->translate('day', '', ''); if ($start == "" || $start > 12 || $start < 1) { ## Get the beginning/end of this week $start_str = mktime(0, 0, 0, date("m"), 1, date("Y")); $start = date(UNIX_DATE_FORMAT, $start_str); $end_str = mktime(0, 0, 0, date("m", $start_str) + 1, 1, date("Y", $start_str)); $end = date(UNIX_DATE_FORMAT, $end_str); } else { ## Get the beginning/end of the specified week $start_str = mktime(0, 0, 0, date("{$start}"), 1, date("Y")); $start = date(UNIX_DATE_FORMAT, $start_str); $end_str = mktime(0, 0, 0, date("m", $start_str) + 1, 1, date("Y", $start_str)); $end = date(UNIX_DATE_FORMAT, $end_str); } ### Set the constraint array: $curr_str = $start_str; while ($curr_str < $end_str) { $new_curr_str = mktime(0, 0, 0, date("m", $curr_str), date("d", $curr_str) + 1, date("Y", $curr_str)); $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str); $TickLables[] = date("j", $curr_str); $curr_str = $new_curr_str; $default_array[] = 0; } } } } # initialize the module, if it has not already been initialized $eval = '$' . $module . ' = new ' . $module . '; '; $eval .= '$this_Obj = $' . $module . ';'; eval($eval); # run the function $array = call_user_func(array($module, "graph"), $start_str, $end_str, $constraint_array, $default_array, $extra_fields); include PATH_GRAPH . "jpgraph_bar.php"; $datay = $array['results']; // Create the graph. These two calls are always required $graph = new Graph(550, 200, "auto"); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(25); $graph->SetMarginColor('#F9F9F9'); $graph->SetFrame(true, 'darkgreen', 0); $graph->SetColor('#FFFFFF'); #$graph->SetFrame(false); // Adjust the margin a bit to make more room for titles $graph->img->SetMargin(45, 10, 15, 25); // Create a bar pot $bplot = new BarPlot($datay); // Set the X if (isset($TickLables)) { $graph->xaxis->SetTickLabels($TickLables); } $graph->xaxis->SetTextLabelInterval($interval); $graph->xaxis->SetColor("navy"); $graph->yaxis->SetColor("navy"); // Adjust fill color $bplot->SetFillColor('#506DC7'); $bplot->value->Show(); $bplot->value->SetFont(FF_FONT1, FS_NORMAL, $FONT_SIZE); $bplot->value->SetAngle(90); $bplot->value->SetFormat('%0.0f'); $bplot->value->SetColor("darkblue"); $graph->Add($bplot); // Setup the titles $title = $array['title']; $graph->title->Set($title . " {$start} - {$end}"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->title->SetColor("black"); // Display the graph $graph->Stroke(); }
// TITRE: marge et apparence $graph->title->SetFont(FF_FONT1, FS_BOLD, 11); // Couleurs et transparence par histogramme $bplot = new BarPlot($data1); $bplot->SetFillColor('teal'); $bplot->value->Show(); $bplot->value->SetFormat('%01.3f'); $bplot->value->SetColor("black", "darkred"); $bplot->SetShadow('black'); $bplot->SetWidth(0.3); $graph->Add($bplot); //graphique2 // Création du graphique conteneur $graph1 = new Graph(700, 250); //$graph1->SetBackgroundImage('../fond.png',BGIMG_COPY); $graph1->SetColor("lightgray"); // Type d'échelle $graph1->SetScale("textlin"); // Fixer les marges $graph1->img->SetMargin(60, 100, 30, 40); // Positionner la légende $graph1->legend->Pos(0, 0.05); // Couleur de l'ombre et du fond de la légende $graph1->legend->SetShadow('darkgray'); $graph1->legend->SetFillColor('lightblue'); $graph1->xaxis->SetTickLabels($data); $graph1->xaxis->title->Set('real time linux'); $graph1->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph1->xaxis->title->SetColor('black'); $graph1->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph1->xaxis->SetColor('black');
$graph->img->SetMargin($marginleft, $marginright, $margintop, $marginbottom); $graph->SetMarginColor($margincolor); $graph->img->SetAntiAliasing(); $graph->SetColor($color); $graph->SetShadow(); $graph->xaxis->SetTitleMargin($marginbottom - 35); $graph->yaxis->SetTitleMargin(50); $graph->yaxis->SetTitleMargin($marginleft - 15); $graph->title->Set($title); } else { $graph = new Graph($width, $height, "auto"); $graph->SetScale("textlin"); $graph->img->SetMargin($marginleft, $marginright, $margintop, $marginbottom); $graph->SetMarginColor($margincolor); $graph->img->SetAntiAliasing(); $graph->SetColor($color); $graph->SetShadow(); $graph->xaxis->SetTitleMargin($marginbottom - 35); $graph->yaxis->SetTitleMargin(50); $graph->yaxis->SetTitleMargin($marginleft - 15); } $lplot = array(); $lplotct = 0; foreach ($plot as $k => $v) { switch ($v["type"]) { case "PIE": $lplot[$lplotct] = new PiePlot($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); foreach ($xlabels as $k => $v) { $xlabels[$k] = $v . "\n %.1f%%"; }
function generate_graph_image() { // Create the graph. // Set up Font Mapping Arrays $fontfamilies = array("Font 0" => FF_FONT0, "Font 1" => FF_FONT1, "Font 2" => FF_FONT2, "Font0" => FF_FONT0, "Font1" => FF_FONT1, "Font2" => FF_FONT2, "Arial" => FF_ARIAL, "Verdana" => FF_VERDANA, "Courier" => FF_COURIER, "Comic" => FF_COMIC, "Times" => FF_TIMES, "Georgia" => FF_GEORGIA, "Trebuchet" => FF_TREBUCHE, "advent_light" => advent_light, "Bedizen" => Bedizen, "Mukti_Narrow" => Mukti_Narrow, "calibri" => calibri, "Forgotte" => Forgotte, "GeosansLight" => GeosansLight, "MankSans" => MankSans, "pf_arma_five" => pf_arma_five, "Silkscreen" => Silkscreen, "verdana" => verdana, "Vera" => FF_VERA); $fontstyles = array("Normal" => FS_NORMAL, "Bold" => FS_BOLD, "Italic" => FS_ITALIC, "Bold+Italic" => FS_BOLDITALIC); $this->apply_defaults(); if (!function_exists("imagecreatefromstring")) { handle_error("Graph Option Not Available. Requires GD2"); return; } if ($this->plot[0]["type"] == "PIE" || $this->plot[0]["type"] == "PIE3D") { $graph = new PieGraph($this->width_actual, $this->height_actual, "auto"); $graph->SetScale("textlin"); $graph->img->SetMargin($this->marginleft_actual, $this->marginright_actual, $this->margintop_actual, $this->marginbottom_actual); $graph->SetMarginColor($this->margincolor_actual); $graph->img->SetAntiAliasing(); $graph->SetColor($this->graphcolor_actual); $graph->SetShadow(); $graph->xaxis->SetTitleMargin($this->marginbottom_actual - 45); $graph->yaxis->SetTitleMargin($this->marginleft_actual - 25); } else { $graph = new Graph($this->width_actual, $this->height_actual, "auto"); $graph->SetScale("textlin"); $graph->img->SetMargin($this->marginleft_actual, $this->marginright_actual, $this->margintop_actual, $this->marginbottom_actual); $graph->SetMarginColor($this->margincolor_actual); $graph->img->SetAntiAliasing(); $graph->SetColor($this->graphcolor_actual); $graph->SetShadow(); $graph->xaxis->SetTitleMargin($this->marginbottom_actual - 45); $graph->yaxis->SetTitleMargin($this->marginleft_actual - 25); } $lplot = array(); $lplotct = 0; foreach ($this->plot as $k => $v) { switch ($v["type"]) { case "PIE": $lplot[$lplotct] = new PiePlot($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); foreach ($xlabels as $k => $v) { $xlabels[$k] = $v . "\n %.1f%%"; } $lplot[$lplotct]->SetLabels($xlabels, 1.0); $graph->Add($lplot[$lplotct]); break; case "PIE3D": $lplot[$lplotct] = new PiePlot3D($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); foreach ($xlabels as $k => $v) { $xlabels[$k] = $v . "\n %.1f%%"; } $lplot[$lplotct]->SetLabels($xlabels, 1.0); $graph->Add($lplot[$lplotct]); break; case "STACKEDBAR": case "BAR": $lplot[$lplotct] = new BarPlot($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); $lplot[$lplotct]->SetWidth(0.8); //$lplot[$lplotct]->SetWeight(5); if ($v["fillcolor"]) { $lplot[$lplotct]->SetFillColor($v["fillcolor"]); } if ($v["legend"]) { $lplot[$lplotct]->SetLegend($v["legend"]); } $graph->Add($lplot[$lplotct]); break; case "LINE": default: if (count($v["data"]) == 1) { $v["data"][] = 0; } $lplot[$lplotct] = new LinePlot($v["data"]); $lplot[$lplotct]->SetColor($v["linecolor"]); //$lplot[$lplotct]->SetWeight(5); if ($v["fillcolor"]) { $lplot[$lplotct]->SetFillColor($v["fillcolor"]); } if ($v["legend"]) { $lplot[$lplotct]->SetLegend($v["legend"]); } $graph->Add($lplot[$lplotct]); break; } $lplotct++; } $graph->title->Set($this->title_actual); $graph->xaxis->title->Set($this->xtitle_actual); $graph->yaxis->title->Set($this->ytitle_actual); $graph->xgrid->SetColor($this->xgridcolor_actual); $graph->ygrid->SetColor($this->ygridcolor_actual); switch ($this->xgriddisplay_actual) { case "all": $graph->xgrid->Show(true, true); break; case "major": $graph->xgrid->Show(true, false); break; case "minor": $graph->xgrid->Show(false, true); break; case "none": default: $graph->xgrid->Show(false, false); break; } switch ($this->ygriddisplay_actual) { case "all": $graph->ygrid->Show(true, true); break; case "major": $graph->ygrid->Show(true, false); break; case "minor": $graph->ygrid->Show(false, true); break; case "none": default: $graph->ygrid->Show(false, false); break; } $graph->title->SetFont($fontfamilies[$this->titlefont_actual], $fontstyles[$this->titlefontstyle_actual], $this->titlefontsize_actual); $graph->title->SetColor($this->titlecolor_actual); $graph->xaxis->SetFont($fontfamilies[$this->xaxisfont_actual], $fontstyles[$this->xaxisfontstyle_actual], $this->xaxisfontsize_actual); $graph->xaxis->SetColor($this->xaxiscolor_actual, $this->xaxisfontcolor_actual); $graph->yaxis->SetFont($fontfamilies[$this->yaxisfont_actual], $fontstyles[$this->yaxisfontstyle_actual], $this->yaxisfontsize_actual); $graph->yaxis->SetColor($this->yaxiscolor_actual, $this->yaxisfontcolor_actual); $graph->xaxis->title->SetFont($fontfamilies[$this->xtitlefont_actual], $fontstyles[$this->xtitlefontstyle_actual], $this->xtitlefontsize_actual); $graph->xaxis->title->SetColor($this->xtitlecolor_actual); $graph->yaxis->title->SetFont($fontfamilies[$this->ytitlefont_actual], $fontstyles[$this->ytitlefontstyle_actual], $this->ytitlefontsize_actual); $graph->yaxis->title->SetColor($this->ytitlecolor_actual); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetLabelMargin(5); $graph->yaxis->SetLabelMargin(5); $graph->xaxis->SetTickLabels($this->xlabels); $graph->xaxis->SetTextLabelInterval($this->xticklabelinterval_actual); $graph->yaxis->SetTextLabelInterval($this->yticklabelinterval_actual); $graph->xaxis->SetTextTickInterval($this->xtickinterval_actual); $graph->yaxis->SetTextTickInterval($this->ytickinterval_actual); $graph->SetFrame(true, 'darkblue', 2); $graph->SetFrameBevel(2, true, 'black'); if ($this->gridpos_actual == "front") { $graph->SetGridDepth(DEPTH_FRONT); } // Display the graph $handle = $graph->Stroke(_IMG_HANDLER); return $handle; }
function arh_graph($titre, $xtitre, $ytitre, $ydata, $legende, $couleurs, $x, $y, $fichier, $xdata, $angle, $couleurfond, $type, $couleurfondgraph = '#FFFFFF', $format = '') { /* Cette fonction trace un graphique dans un fichier temporaire. $titre => C'est le titre du graphique qui sera affiché. $xtitre => Nom des unités en abscisse. $ytitre => Nom des unités en ordonnées. $ydata => Tableau à deux dimensions contenant les différentes courbes : un tableau de tableau avec les coordonnées en ordonnée des points de chaque courbe... $legende => Un tableau contenant les légendes des courbes. $couleurs => Les couleurs des courbes : L'idéal est d'en avoir autant que de courbes. $x => Largeur en pixels de l'image générée. $y => Hauteur en pixels de l'image générée. $fichier => Nom du fichier généré. $xdata => Tableau contenant le nom des abscisses. $angle => Ici, nous avon l'angle d'inclinaison des noms des indexes en abscisse. $couleurfond => La couleur qui encadre le graphique. $type => Trois types de graphiques sont gérés : line, accbar, groupbar. $couleurfondgraph => La couleur de fond du graphique. */ include_once "modules/jpgraph/jpgraph.php"; include_once "modules/jpgraph/jpgraph_log.php"; include_once "modules/jpgraph/jpgraph_line.php"; include_once "modules/jpgraph/jpgraph_bar.php"; // Création du graphique. $graph = new Graph($x, $y); $graph->SetScale("textlin"); $graph->SetColor($couleurfondgraph); // $graph -> SetShadow ( ) ; // Réglage de la marge autour du graphique ( G, D, H, B ). $graph->img->SetMargin(55, 20, 20, 70); $graph->SetMarginColor($couleurfond); // $graph->SetBackgroundImage((defined('URLIMGXHAM')?URLIMGXHAM:'images/xham.jpg'),BGIMG_FILLFRAME); if (isset($ydata)) { if ($type == "accbar") { // Création des différentes courbes et ajout des données au graph. for ($i = 0; $i < count($ydata); $i++) { $barplot[$i] = new BarPlot($ydata[$i]); $barplot[$i]->SetLegend($legende[$i]); //$barplot[$i] -> SetFillColor( $couleurs[$i] ) ; $barplot[$i]->SetFillGradient($couleurs[$i], "lightsteelblue", GRAD_VER); } $accbar = new AccBarPlot($barplot); $graph->Add($accbar); } else { if ($type == "groupbar") { // Creation des différentes courbes et ajout des données au graph. $j = 0; for ($i = 0; $i < count($ydata); $i++) { // On crée un histogramme seulement si le tableau contient des données. if ($this->existe($ydata[$i])) { $barplot[$j] = new BarPlot($ydata[$i]); $barplot[$j]->SetLegend($legende[$i]); //$barplot[$j] -> SetFillColor( $couleurs[$i] ) ; $barplot[$j]->SetFillGradient($couleurs[$i], "lightsteelblue", GRAD_VER); if ($format) { $barplot[$j]->value->SetFormat($format, 70); $barplot[$j]->value->SetFont(FF_ARIAL, FS_NORMAL, 9); $barplot[$j]->value->SetColor("blue"); $barplot[$j]->value->SetAngle(90); $barplot[$j]->value->Show(); } $j++; } } // On vérifie qu'il y a au moins un histogramme à tracer. if (isset($barplot) and count($barplot)) { $accbar = new GroupBarPlot($barplot); $graph->Add($accbar); // Dans le cas contraire, on fait simule la présence d'une courbe vide. } else { $lineplot[0] = new LinePlot($ydata[0]); $graph->Add($lineplot[0]); } } else { if ($type == "line") { // Création des différentes courbes et ajout des données au graph. for ($i = 0; $i < count($ydata); $i++) { /*print "**************************Courbe $i***********************" ; newfct ( gen_affiche_tableau, $ydata[$i] ) ; */ $lineplot[$i] = new LinePlot($ydata[$i]); $graph->Add($lineplot[$i]); $lineplot[$i]->SetWeight(1); $lineplot[$i]->SetLegend($legende[$i]); $lineplot[$i]->SetColor($couleurs[$i]); } } } } } // Configuration des noms à afficher. $graph->title->SetFont(FF_ARIAL); $graph->title->Set("{$titre}"); $graph->xaxis->SetFont(FF_ARIAL); $graph->xaxis->SetTickLabels($xdata); $graph->xaxis->SetLabelAngle($angle); $graph->xaxis->title->SetFont(FF_ARIAL); $graph->xaxis->title->Set("{$xtitre}"); $graph->yaxis->SetFont(FF_ARIAL); $graph->yaxis->title->SetFont(FF_ARIAL); $graph->yaxis->title->Set("{$ytitre}"); $graph->legend->Pos(0.02, 0.1, "right", "center"); if (isset($ydata)) { // Création de l'image dans un fichier temporaire. $graph->Stroke(URLCACHE . "{$fichier}"); } }
${$temp}->SetColor($color_val); ${$temp}->SetLegend($name); $x_thick = $thick - $i; if ($x_thick <= 1) { $x_thick = 1; } ${$temp}->SetWeight($x_thick); $graph->Add(${$temp}); $max = 0; for ($j = 0; $j < count($graph_data); $j++) { $x = $graph_data[$j]; if ($x >= $max) { $max = $x; } else { $max = $max; } } } if ($max >= 5) { $graph->yaxis->SetLabelFormat('%d'); } $graph->legend->Pos(0, 0.4, "right", "center"); // Set some other color then the boring default $graph->SetColor("#6F96FF"); //$graph->SetColor("#CCDFCC"); $graph->SetMarginColor("#2447A7"); //$graph->SetMarginColor("#98C098"); $graph->xaxis->SetTickLabels($datax); $graph->xaxis->SetLabelAngle(90); // Output line $graph->Stroke();
function setupGraph($XUnits = "hours", $startTime, $count, $options = array()) { global $conf; $graph = new Graph($conf['graph']['width'], $conf['graph']['height'], "auto"); $graph->SetScale("intlin"); //$graph->SetScale("linlin",$mintemp,$maxtemp,$mintime, $maxtime); //$graph->SetShadow(); $rightMargin = 20; if (isset($options['showMargin']) && $options['showMargin'] == 1) { $rightMargin = 110; } $graph->img->SetMargin(50, $rightMargin, 20, 40); $graph->SetBox(true, 'black', 2); $graph->SetColor($conf['graph']['bgcolor']); $graph->SetMarginColor($conf['html']['bgcolor']); //$graph->title->Set("Digitemp Activity"); $graph->title->Set("Digitemp Activity starting " . date("H:i:s m/d/Y", $startTime)); /** $txt =new Text("Starting ".date("H:i:s m/d/Y", $startTime)); $txt->Pos( 0.59,0.01); $txt->SetColor( "blue"); $graph->AddText( $txt); **/ //junk: $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->xgrid->Show(); $graph->legend->Pos(0.02, 0.02, "right", "top"); /* $graph->yaxis->SetPos(0); $graph->yaxis->SetWeight(2); $graph->yaxis->SetFont(FF_FONT1,FS_BOLD); $graph->yaxis->SetColor('black','darkblue'); */ $graph->xaxis->SetWeight(2); $graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetColor('black', 'darkblue'); // echo "Setting limits to $mintime, $maxtime, $mintemp, $maxtemp"; //$graph->SetScale("linlin",$mintemp,$maxtemp,$mintime, $maxtime); $graph->xaxis->title->Set("Time ({$XUnits})"); $graph->yaxis->title->Set('Temperature (' . $options['units'] . ')'); $txt2 = new Text("Measurements shown: {$count}"); $txt2->Pos(0.02, 0.96); $txt2->SetColor("blue"); $graph->AddText($txt2); return $graph; }
$data5['value'][$value['var3'] - 1] = $value['var2']; } } // require_once 'ossim_conf.inc'; $conf = $GLOBALS["CONF"]; $jpgraph = $conf->get_conf("jpgraph_path"); require_once "{$jpgraph}/jpgraph.php"; require_once "{$jpgraph}/jpgraph_line.php"; // Setup the graph. $graph = new Graph(600, 300, "auto"); $graph->SetScale("textlin"); $graph->SetMargin(100, 10, 20, 86); $graph->SetMarginColor("#fafafa"); $graph->xaxis->SetTickLabels(array(_("Ene"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"), _("Jul"), _("Ago"), _("Sep"), _("Oct"), _("Nov"), _("Dic"))); $graph->SetColor("#fafafa"); $graph->SetFrame(true, '#fafafa', 0); $dplot[0] = new LinePLot($data1['value']); $dplot[1] = new LinePLot($data2['value']); $dplot[2] = new LinePLot($data3['value']); $dplot[3] = new LinePLot($data4['value']); $dplot[4] = new LinePLot($data5['value']); $dplot[0]->SetColor(COLOR1); $dplot[0]->SetLegend('QoS-Impact'); $dplot[0]->mark->SetType(MARK_SQUARE); $dplot[0]->mark->SetColor(COLOR1); $dplot[0]->mark->SetFillColor(COLOR1); // $dplot[1]->SetColor(COLOR2); $dplot[1]->SetLegend('Information-Leak-Impact'); $dplot[1]->mark->SetType(MARK_UTRIANGLE);
<?php include "../jpgraph.php"; include "../jpgraph_line.php"; include "../jpgraph_error.php"; include "../jpgraph_bar.php"; $l1datay = array(11, 9, 2, 4, 3, 13, 17); $l2datay = array(23, 12, 5, 19, 17, 10, 15); $datax = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"); // Create the graph. $graph = new Graph(350, 200, "auto"); $graph->img->SetMargin(40, 70, 20, 40); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->SetColor(array(250, 250, 250)); $graph->img->SetTransparent("white"); $t1 = new Text("This is a text"); $t1->SetPos(0.5, 0.5); $t1->SetOrientation("h"); $t1->SetFont(FF_FONT1, FS_BOLD); $t1->SetBox("white", "black", "gray"); $t1->SetColor("black"); $graph->AddText($t1); // Create the linear error plot $l1plot = new LinePlot($l1datay); $l1plot->SetColor("blue"); $l1plot->SetWeight(2); $l1plot->SetLegend("Prediction"); // Create the bar plot $l2plot = new BarPlot($l2datay); $l2plot->SetFillColor("orange");