static function graphs($name, $close) { // Setup the graph $graph = new Graph(1000, 653, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->SetFont(FF_FONT2, FS_BOLD, 20); $graph->title->Set("Stock Performance History for " . $name); $graph->SetBox(false); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->yaxis->title->SetFont(FF_FONT2, FS_BOLD, 20); $graph->yaxis->title->Set('Close Price'); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickPositions(array(0, 20, 40, 61, 82, 103, 124, 143)); $graph->xaxis->SetTickLabels(array('Nov 2014', 'Dec 2014', 'Jan 2015', 'Feb 2015', 'March 2015', 'April 2015', 'May 2015', 'June 2015')); $graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD, 20); $graph->xaxis->title->Set('Dates'); $graph->xgrid->SetColor('#E3E3E3'); // Create the first line $p1 = new LinePlot($close); $graph->Add($p1); $p1->SetColor("#6495ED"); $graph->legend->SetFrameWeight(2); // Output line $graph->Stroke(); }
function grafico_barra() { $data1y = array(47, 80, 40, 116); $data2y = array(61, 30, 82, 105); $data3y = array(115, 50, 70, 93); // Create the graph. These two calls are always required $graph = new Graph(350, 200, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135)); $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D')); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Create the bar plots $b1plot = new BarPlot($data1y); $b2plot = new BarPlot($data2y); $b3plot = new BarPlot($data3y); // Create the grouped bar plot $gbplot = new GroupBarPlot(array($b1plot, $b2plot, $b3plot)); // ...and add it to the graPH $graph->Add($gbplot); $b1plot->SetColor("white"); $b1plot->SetFillColor("#cc1111"); $b2plot->SetColor("white"); $b2plot->SetFillColor("#11cccc"); $b3plot->SetColor("white"); $b3plot->SetFillColor("#1111cc"); $graph->title->Set("Bar Plots"); // Display the graph $graph_temp_directory = 'temp'; // in the webroot (add directory to .htaccess exclude) $graph_file_name = 'test.png'; $graph_file_location = $graph_temp_directory . '/' . $graph_file_name; $graph->Stroke($graph_file_location); // create the graph and write to file $data['graph'] = $graph_file_location; $this->load->view('supervisor/prueba', $data); }
$marks[] = "MARK_STAR"; $marks[] = "MARK_X"; $marks[] = "MARK_LEFTTRIANGLE"; $marks[] = "MARK_RIGHTTRIANGLE"; $marks[] = "MARK_FLASH"; //$datay1 = array(20,15,23,15); //$datay2 = array(12,9,42,8); //$datay3 = array(5,17,32,24); $datay1 = $jpgraph_data[1]; $datay2 = $jpgraph_data[2]; $datay3 = $jpgraph_data[3]; // Setup the graph $graph = new Graph(960, 640); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(true); //$graph->title->Set('Filled Y-grid'); $graph->SetBox(false); $graph->SetMargin(35, 0, 0, 0); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); //$graph->xaxis->SetTickLabels(array('A','B','C','D')); $graph->xgrid->SetColor('#E3E3E3'); $i = 0; foreach ($jpgraph_data as $key => $value) { //echo "KEY: $key <br>";
<?php require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; require_once 'jpgraph/jpgraph_line.php'; $theme = isset($_GET['theme']) ? $_GET['theme'] : null; $data = array(0 => array(0 => 79, 1 => -25, 2 => -7, 3 => 85, 4 => -26, 5 => -32), 1 => array(0 => 76, 1 => 51, 2 => 86, 3 => 12, 4 => -7, 5 => 94), 2 => array(0 => 49, 1 => 38, 2 => 7, 3 => -40, 4 => 9, 5 => -7), 3 => array(0 => 69, 1 => 96, 2 => 49, 3 => 7, 4 => 92, 5 => -38), 4 => array(0 => 68, 1 => 16, 2 => 82, 3 => -49, 4 => 50, 5 => 7), 5 => array(0 => -37, 1 => 28, 2 => 32, 3 => 6, 4 => 13, 5 => 57), 6 => array(0 => 24, 1 => -11, 2 => 7, 3 => 10, 4 => 51, 5 => 51), 7 => array(0 => 3, 1 => -1, 2 => -12, 3 => 61, 4 => 10, 5 => 47), 8 => array(0 => -47, 1 => -21, 2 => 43, 3 => 53, 4 => 36, 5 => 34)); // Create the graph. These two calls are always required $graph = new Graph(400, 300); $graph->SetScale("textlin"); if ($theme) { $graph->SetTheme(new $theme()); } $theme_class = new RoseTheme(); $graph->SetTheme($theme_class); $plot = array(); // Create the bar plots for ($i = 0; $i < 4; $i++) { $plot[$i] = new BarPlot($data[$i]); $plot[$i]->SetLegend('plot' . ($i + 1)); } //$acc1 = new AccBarPlot(array($plot[0], $plot[1])); //$acc1->value->Show(); $gbplot = new GroupBarPlot(array($plot[2], $plot[1])); for ($i = 4; $i < 8; $i++) { $plot[$i] = new LinePlot($data[$i]); $plot[$i]->SetLegend('plot' . $i); $plot[$i]->value->Show(); } $graph->Add($gbplot); $graph->Add($plot[4]);
public function generateGraphbarrev($type) { // $type= "year"; if ($type == "year") { $start = date("Y-"); $start .= "01-01 00-00-00"; $end = date("Y-"); $end .= "12-31 23-59-59"; } elseif ($type == "month") { $start = date("Y-m-"); $start .= "01 00-00-00"; $end = date("Y-m-"); $end .= "31 23-59-59"; } elseif ($type == "day") { $start = date("Y-m-d"); $start .= " 00-00-00"; $end = date("Y-m-d"); $end .= " 23-59-59"; } elseif ($type == "week") { $date = date("Y-m-d"); } //$this->load->database(); if ($type == "week") { $sql = DB::select(DB::raw("SELECT `id` FROM `sales` WHERE YEARWEEK(`created_at`) = YEARWEEK('{$date}') AND `deleted` = '0' ")); } else { $sql = DB::select(DB::raw("SELECT `id` FROM `sales` WHERE (`created_at` BETWEEN '{$start}' AND '{$end}') AND `deleted` = '0' ")); } foreach ($sql as $row) { $sales_id[] = $row->id; } if (!isset($sales_id)) { $sales_id[] = 0; $sales_id[] = 0; } $ids = join(',', $sales_id); //$sql = "SELECT COUNT(sales_product.id) AS 'Count', item.name AS 'Name' FROM sales_product INNER JOIN item ON item.id = sales_product.product WHERE sales_product.sale_id IN ($ids) GROUP BY sales_product.product ORDER BY `Count` DESC"; $sql = DB::select(DB::raw("SELECT COUNT(sales_product.id) AS 'Count', item.name AS 'Name' FROM sales_product INNER JOIN item ON item.id = sales_product.product WHERE sales_product.sale_id IN ({$ids}) GROUP BY sales_product.product ORDER BY `Count` DESC")); foreach ($sql as $row) { $inq[] = $row->Count; $leg[] = $row->Name; } if (!isset($inq)) { $inq[] = 0; $leg[] = "null"; } if (sizeof($inq) > 5) { $c = sizeof($inq) - 1; $other = 0; for ($x = 4; $x <= $c; $x++) { $other = $other + $inq[$x]; unset($inq[$x]); unset($leg[$x]); } $inq[4] = $other; $leg[4] = "other"; } $data1y = $inq; echo public_path('plugins\\streaming\\protected\\start.php'); echo asset('asxcasx\\dsddsd'); // die(); // Create the graph. These two calls are always required $graph = new \Graph(350, 250, 'auto'); $graph->SetScale("textlin"); $theme_class = new \UniversalTheme(); $graph->SetTheme($theme_class); // $graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135)); $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels($leg); $graph->xaxis->title->Set('Products'); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->yaxis->title->Set('Sales'); // Create the bar plots $b1plot = new \BarPlot($data1y); // $b2plot = new BarPlot($data2y); // $b3plot = new BarPlot($data3y); // Create the grouped bar plot // $gbplot = new GroupBarPlot(array($b1plot,$b2plot,$b3plot)); $gbplot = new \GroupBarPlot(array($b1plot)); // ...and add it to the graPH $graph->Add($gbplot); $b1plot->SetColor("white"); $b1plot->SetFillColor("#6EDBFF"); $b1plot->SetWidth(45); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); $fileName = "assets/tmp/" . $type . "_bar_rev.png"; $graph->img->Stream($fileName); }
function calculating_statictis($class_id, $exam_id) { $this->load->model('Crud_model', 'c'); $data = $this->c->get_marks_by_exam_id($class_id, $exam_id); if (sizeof($data) > 0) { $marks = array(); $count = array(); $i = 1; foreach ($data as $d) { $marks[] = $d['mark_obtained']; $count[] = $i; $i++; } //library require_once 'assets/library/jpgraph.php'; require_once 'assets/library/jpgraph_line.php'; // Setup the graph $graph = new Graph(600, 500); //height,width of the canvas $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->Set('mark distribution'); //title of the page $graph->SetBox(false); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickLabels($count); $graph->xgrid->SetColor('#E3E3E3'); // Create the first line $p1 = new LinePlot($marks); $graph->Add($p1); $p1->SetColor("#6495ED"); $p1->SetLegend('marks gained by students'); $graph->legend->SetFrameWeight(1); // Output line $graph->Stroke(); } else { echo -1; } }
public function summary($id) { JpGraph\JpGraph::load(); JpGraph\JpGraph::module('line'); $targ1 = array(); $targ2 = array(); $targ3 = array(); $alts1 = array(); $alts2 = array(); $alts3 = array(); // Setup some dummy targets for the CSIM $n = 5; for ($i = 0; $i < $n; ++$i) { $targ1[$i] = "#{$i}"; $targ2[$i] = "#{$i}"; $targ3[$i] = "#{$i}"; $alts1[$i] = "val=%d"; $alts2[$i] = "val=%d"; $alts3[$i] = "val=%d"; } $datay1 = array(20, 15, 23, 15, 80, 20, 45, 10, 5, 45, 60); $datay2 = array(12, 9, 12, 8, 41, 15, 30, 8, 48, 36, 14, 25, 30, 35); $datay3 = array(5, 17, 32, 24, 4, 2, 36, 2, 9, 24, 21, 23); $dateStart = '2015-03-01'; $dateEnd = '2016-04-30'; $numberTotalDays = $this->numberDaysBetweenTwoDates($dateStart, $dateEnd); $numberTotalMonths = $this->numberMonthBetweenTwoDates($dateStart, $dateEnd); $yearStart = $this->obtainInfoDate($dateStart, "Y"); $monthStart = $this->obtainInfoDate($dateStart, 'n'); $dayStart = $this->obtainInfoDate($dateStart, 'd'); $yearEnd = $this->obtainInfoDate($dateEnd, "Y"); $monthEnd = $this->obtainInfoDate($dateEnd, "n"); $dayEnd = $this->obtainInfoDate($dateEnd, "d"); $arrayDays = array(); $result = array(); $result[] = 0; $monthCount = $monthStart; $yearCount = $yearStart; $daysElapsed = 0; $percentaje = 0; $days = 0; $counter = 0; for ($i = 1; $i <= $numberTotalMonths; $i++) { if ($i == 1) { $days = $this->numberDaysFirstMonth($yearCount, $monthCount, $dayStart); $arrayDays[] = $monthCount . '+' . $days; $daysElapsed = $daysElapsed + $days; $percentaje = $this->calculatePercentage($numberTotalDays, $daysElapsed); $result[] = $percentaje; } elseif ($i == $numberTotalMonths) { $days = $dayEnd; $arrayDays[] = $monthCount . '+' . $days; $daysElapsed = $daysElapsed + $days; $percentaje = $this->calculatePercentage($numberTotalDays, $daysElapsed); $result[] = $percentaje; } else { $days = $this->numberDaysPerMonth($yearCount, $monthCount); $arrayDays[] = $monthCount . '+' . $days; $daysElapsed = $daysElapsed + $days; $percentaje = $this->calculatePercentage($numberTotalDays, $daysElapsed); $result[] = $percentaje; } if ($monthCount == 12) { $monthCount = 0; $yearCount++; } $monthCount++; } $stringTmp = ''; foreach ($arrayDays as $var) { $stringTmp = $stringTmp . (string) $var . ' - '; } //$datay3 = $result; // Setup the graph $graph = new Graph(900, 350); //$graph->SetScale("textlin"); $graph->SetScale("intlin"); //$graph->SetYScale(0,'int'); //$graph->SetYScale(1,'int'); $theme_class = new UniversalTheme(); //$numberDays = $this->numberDaysBetweenTwoDates('2013-01-01','2014-01-01'); //$numberMonth = $this->numberMonthBetweenTwoDates('2013-01-01','2013-12-20'); //$month = $this->obtainInfoFromDate('2013-12-20'); //$yearStart = $this->obtainInfoDate('2013-12-20', "Y"); //$monthStart = $this->obtainInfoDate('2013-12-20', 'm'); //$dayStart = $this->obtainInfoDate('2013-12-20','d'); $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); //$numberTotalMonths = $this->numberMonthBetweenTwoDates($dateStart, $dateEnd); //$monthStart = $this->obtainInfoDate($dateStart, 'n'); //$monthEnd = $this->obtainInfoDate($dateEnd, 'n'); $monthNames = array('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'); // $result = array(); $counter = $monthStart - 1; $resultNames = array(); $resultNames[] = ''; for ($i = 0; $i < $numberTotalMonths; $i++) { $resultNames[] = $monthNames[$counter]; $counter++; if ($counter == 12) { $counter = 0; } } $graph->title->Set('Pedidos ' . $numberTotalMonths . ' , ' . $numberTotalDays . ' , ' . $daysElapsed . ' : ' . $stringTmp . ' ; ' . $monthStart); // $graph->title->Set('Evolución de pedidos ' . $numberTotalMonths . ' ' . $numberTotalDays . ' ' . $yearStart . ' ' . $monthStart . ' ' . $daysElapsed . ' ' . $percentaje . ' ' . $stringTmp); //$graph->title->Set('Evolución de pedidos ' . $numberTotalMonths);$arrayDays //$graph->title->Set('Evolución de pedidos'); $graph->SetBox(false); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); //$months = $this->buildArrayMonthName('2015-01-01','2016-01-01'); //$graph->xaxis->SetTickLabels(array('Ene','Feb','Mar','Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Nov', 'Oct', 'Dic', 'Aux')); $graph->xaxis->SetTickLabels($resultNames); $graph->xgrid->SetColor('#E3E3E3'); // Create the first line $p1 = new LinePlot($datay1); $graph->Add($p1); $p1->SetColor("#6495ED"); $p1->SetLegend('Tienda 1'); // Create the second line $p2 = new LinePlot($datay2); $graph->Add($p2); $p2->SetColor("#B22222"); $p2->SetLegend('Tienda 2'); // Create the third line $p3 = new LinePlot($result); $graph->Add($p3); // $p3->SetColor("#55bbdd"); $p3->SetColor("blue"); $p3->SetLegend('Tienda 3'); $p3->SetCSIMTargets($targ1, $alts1); //----------- //$p3->value->SetFormat('%d'); $p3->value->Show(); $p3->value->SetColor('red'); $graph->legend->SetFrameWeight(1); // Output line $graph->Stroke(); }
function generateGraphlinetotcalls($type) { for ($i = 0; $i < 4; $i++) { $time = DATE('Y-m-d'); $date = strtotime($time . ' -' . $i . $type); if ($type == "year") { $labels[] = date('Y', $date); $date = date('Y', $date); } elseif ($type == "month") { $labels[] = date('M', $date); $date = date('Y-m', $date); } elseif ($type == "week") { $labels = array(4, 3, 2, 1); $date = date('oW', $date); } else { $labels[] = date('d', $date); $date = date('Y-m-d', $date); } if ($type == "week") { $sql = DB::select(DB::raw("SELECT COUNT(*) AS 'count', `call_type` FROM `call_log` WHERE YEARWEEK(created_at,1) LIKE '{$date}' GROUP BY `call_type` ORDER BY `call_type`")); } else { $sql = DB::select(DB::raw("SELECT COUNT(*) AS 'count', `call_type` FROM `call_log` WHERE `created_at` LIKE '{$date}%' GROUP BY `call_type` ORDER BY `call_type`")); } foreach ($sql as $row) { $call[$row->call_type][$i] = $row->count; } if (!isset($call['Inquiry'][$i])) { $call['Inquiry'][$i] = "0"; } if (!isset($call['Sales'][$i])) { $call['Sales'][$i] = "0"; } if (!isset($call['Tickets'][$i])) { $call['Tickets'][$i] = "0"; } } $inquiry = $call['Inquiry']; $sales = $call['Sales']; $ticket = $call['Tickets']; // $datay3 = array(5,17,32,24); // Setup the graph $graph = new \Graph(300, 250); $graph->SetScale("textlin"); $theme_class = new \UniversalTheme(); $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); //$graph->title->Set('Last 4 weeks Sales vs Inquiry'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); $graph->SetBox(false); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->yaxis->title->Set('Calls'); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickLabels($labels); $graph->xgrid->SetColor('#E3E3E3'); $graph->xaxis->title->Set($type); $graph->legend->SetPos(0.4, 0.995, 'center', 'bottom'); // Create the second line $p2 = new \LinePlot($inquiry); $graph->Add($p2); $p2->SetColor("#ADFF2F"); $p2->SetLegend('Inquiry'); // Create the first line $p1 = new \LinePlot($sales); $graph->Add($p1); $p1->SetColor("#DC143C"); $p1->SetLegend('Sales'); //Create the third line $p3 = new \LinePlot($ticket); $graph->Add($p3); $p3->SetColor("#9966FF"); $p3->SetLegend('Ticket'); $graph->legend->SetFrameWeight(1); // Output line // $graph->Stroke(); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); $fileName = "assets/tmp/" . $type . "_line_tcall.png"; $graph->img->Stream($fileName); }
function generateGraphbartotcalls($type) { for ($i = 0; $i < 4; $i++) { $time = DATE('Y-m-d'); $date = strtotime($time . ' -' . $i . $type); if ($type == "year") { $labels[] = date('Y', $date); $date = date('Y', $date); } elseif ($type == "month") { $labels[] = date('M', $date); $date = date('Y-m', $date); } elseif ($type == "week") { $labels = array(4, 3, 2, 1); $date = date('oW', $date); } else { $labels[] = date('d', $date); $date = date('Y-m-d', $date); } if ($type == "week") { //$sql = "SELECT COUNT(*) AS 'count', `call_type` FROM `call_log` WHERE YEARWEEK(call_created_time,1) LIKE '$date' AND `deleted` = '0' GROUP BY `call_type` ORDER BY `call_type`"; $sql = DB::select(DB::raw("SELECT COUNT(*) AS 'count', `call_type` FROM `call_log` WHERE YEARWEEK(created_at,1) LIKE '{$date}' AND `deleted` = '0' GROUP BY `call_type` ORDER BY `call_type`")); } else { //$sql = "SELECT COUNT(*) AS 'count', `call_type` FROM `call_log` WHERE `call_created_time` LIKE '$date%' AND `deleted` = '0' GROUP BY `call_type` ORDER BY `call_type`"; $sql = DB::select(DB::raw("SELECT COUNT(*) AS 'count', `call_type` FROM `call_log` WHERE `created_at` LIKE '{$date}%' AND `deleted` = '0' GROUP BY `call_type` ORDER BY `call_type`")); } // $this->load->database(); // $query=$this->db->query($sql); foreach ($sql as $row) { $call[$row->call_type][$i] = $row->count; } if (!isset($call['Inquiry'][$i])) { $call['Inquiry'][$i] = "0"; } if (!isset($call['Sales'][$i])) { $call['Sales'][$i] = "0"; } if (!isset($call['Tickets'][$i])) { $call['Tickets'][$i] = "0"; } } //bar3 // $data3y=array(220,230,210,175,185); // $data4y=array(40,45,70,80,50); // $data5y=array(20,20,25,22,30); $data3y = $call['Inquiry']; $data4y = $call['Sales']; $data5y = $call['Tickets']; // Create the graph. These two calls are always required $graph = new \Graph(350, 250, 'auto'); $graph->SetScale("textlin"); $graph->SetY2Scale("lin", 0, 90); $graph->SetY2OrderBack(false); $graph->SetMargin(35, 50, 20, 5); $theme_class = new \UniversalTheme(); $graph->SetTheme($theme_class); // $graph->yaxis->SetTickPositions(array(0,50,100,150,200,250,300,350), array(25,75,125,175,275,325)); $graph->y2axis->SetTickPositions(array(30, 40, 50, 60, 70, 80, 90)); // $months = $gDateLocale->GetShortMonth(); // $months = array_merge(array_slice($months,3,9), array_slice($months,0,3)); // $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels($labels); $graph->xaxis->title->Set($type); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->yaxis->title->Set('Calls'); // Setup month as labels on the X-axis // $graph->xaxis->SetTickLabels($months); // Create the bar plots $b3plot = new \BarPlot($data3y); $b4plot = new \BarPlot($data4y); $b5plot = new \BarPlot($data5y); // Create the grouped bar plot $gbbplot = new \AccBarPlot(array($b3plot, $b4plot, $b5plot)); $gbplot = new \GroupBarPlot(array($gbbplot)); // ...and add it to the graPH $graph->Add($gbplot); $gbplot->SetWidth(45); $b3plot->SetColor("#3333CC"); $b3plot->SetFillColor("#3333CC"); $b3plot->SetLegend("Inquiry"); $b4plot->SetColor("#7474FF"); $b4plot->SetFillColor("#7474FF"); $b4plot->SetLegend("Sales"); $b5plot->SetColor("#6EB7FF"); $b5plot->SetFillColor("#6EB7FF"); $b5plot->SetLegend("Tickets"); $graph->legend->SetFrameWeight(1); $graph->legend->SetColumns(5); // $graph->legend->SetColor('#4E4E4E','#00A78A'); $graph->legend->Pos(0.2, 0.9); $band = new \PlotBand(VERTICAL, BAND_RDIAG, 11, "max", 'khaki4'); $band->ShowFrame(true); $band->SetOrder(DEPTH_BACK); $graph->Add($band); // $graph->title->Set("Combineed Line and Bar plots"); // Display the graph // $graph->Stroke(); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); $fileName = "assets/tmp/" . $type . "_bar_tcall.png"; $graph->img->Stream($fileName); }
function createGroupBar($waktu, $data_bar) { require_once '../jpgraph/jpgraph.php'; require_once '../jpgraph/jpgraph_bar.php'; $patuh = $data_bar['patuh']; $kurang_patuh = $data_bar['kurang_patuh']; $tidak_patuh = $data_bar['tidak_patuh']; // Create the graph. These two calls are always required $graph = new Graph(400, 300, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels(array('HOTEL', 'RESTORAN', 'HIBURAN', 'PARKIR')); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Create the bar plots $b1plot = new BarPlot($patuh); $b2plot = new BarPlot($kurang_patuh); $b3plot = new BarPlot($tidak_patuh); // Create the grouped bar plot $gbplot = new GroupBarPlot(array($b1plot, $b2plot, $b3plot)); // ...and add it to the graPH $graph->Add($gbplot); $b1plot->SetColor("white"); $b1plot->SetFillColor("#8AE952"); $b1plot->SetLegend('PATUH'); $b2plot->SetColor("white"); $b2plot->SetFillColor("#056FD8"); $b2plot->SetLegend('KURANG PATUH'); $b3plot->SetColor("white"); $b3plot->SetFillColor("#AE0000"); $b3plot->SetLegend('TIDAK PATUH'); $graph->title->Set("GRAFIK KEPATUHAN WP"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); // Display the graph $graph->Stroke("../graphfiles/bar_kepatuhan_" . $waktu . ".png"); }
$graph->SetScale("textlin"); class MyTheme extends OceanTheme { private $axis_color = '#0a0a0a'; function GetColorList() { return ['#0b82ff', '#b7ceff']; } function SetupGraph($graph) { parent::SetupGraph($graph); $graph->xaxis->SetColor($this->axis_color, $this->font_color); $graph->yaxis->SetColor($this->axis_color, $this->font_color); } } $graph->SetTheme(new MyTheme()); $graph->xaxis->SetTickLabels($naamMaand); $graph->xaxis->title->SetFont(FF_VERDANA, FS_BOLD); $graph->yaxis->title->SetFont(FF_VERDANA, FS_BOLD); $graph->title->Set('Project Shopping'); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 20); $graph->subtitle->Set('Balans: inkomsten - uitgaven'); $graph->subtitle->SetFont(FF_VERDANA, FS_BOLD, 14); $bplot1 = new BarPlot($inkomsten); $bplot2 = new BarPlot($uitgaven); $gbarplot = new GroupBarPlot(array($bplot1, $bplot2)); $gbarplot->SetWidth(0.6); $graph->Add($gbarplot); $bplot1->value->Show(); $bplot1->value->SetFormat('%d'); $bplot1->value->SetFont(FF_VERDANA, FS_NORMAL);
function generar_grafico($produccion_prog_dia, $produccion_hast_fecha, $fechas_informes, $fecha) { ini_alter('date.timezone', 'America/Santiago'); $this->load->library('grafico'); $data1y = $produccion_prog_dia; //var_dump($produccion_hast_fecha); foreach ($produccion_hast_fecha as $produc_dia) { //var_dump($produc_dia); $data2y[] = $produc_dia; } //$data3y=$produccion_prog_dia; $graph = new Graph(1550, 400, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); //$graph->yaxis->SetTickPositions(array(1000,2000,3000,4000,5000,6000,7000,8000,9000,10000), array(500,1500,2500,3500,4500,5500,6500,7500,8500,9500)); $graph->yaxis->scale->SetGrace(10); $graph->SetBox(TRUE); // Setup X-axis labels $graph->xaxis->SetTickLabels($fechas_informes); $graph->xaxis->SetLabelAngle(50); $graph->ygrid->SetFill(false); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Create the bar plots $b1plot = new BarPlot($data1y); $b2plot = new BarPlot($data2y); //$b3plot = new BarPlot($data3y); // Create the grouped bar plot $gbplot = new GroupBarPlot(array($b1plot, $b2plot)); //,$b3plot)); // ...and add it to the graPH $graph->Add($gbplot); $b1plot->SetColor("white"); $b1plot->SetFillColor("#cc1111"); $b2plot->SetColor("white"); $b2plot->SetFillColor("#11cccc"); //$b3plot->SetColor("white"); //$b3plot->SetFillColor("#1111cc"); $graph->title->Set("Producción Mensual fecha " . $fecha); // Display the graph $graph_temp_directory = 'temp'; // in the webroot (add directory to .htaccess exclude) $graph_file_name = 'test.png'; $graph_file_location = $graph_temp_directory . '/' . $graph_file_name; $graph->Stroke($graph_file_location); // create the graph and write to file }
private function getTabela() { $retorno = ""; $retorno .= "<h2 style=\"text-align:center\">{$this->titulo}</h2>"; $retorno .= "<table width='100%' align='center' class=\"table\"> <thead class=\"conteudo\"> <tr> <th>Nome</td> <th>Grupo</td> <th>Ministério</td> <th>Telefone</td> <th>Status</td> </tr> </thead>"; $status_qtd = array(); $status_atual = ''; $cont = 0; $resposta = listaPessoas(); foreach ( $resposta as $reg ) : $nome = substr($reg ['pessoa'], 0, 17); $grupo = $reg ['grupo']; $ministerio = $reg ['ministerio']; $status = $reg['status']; $retorno .= "<tr>"; $retorno .= "<td>{$nome}</td>"; $retorno .= "<td>{$grupo}</td>"; $retorno .= "<td>{$ministerio}</td>"; $retorno .= "<td>{$reg['telefone']}</td>"; $retorno .= "<td>{$status}</td>"; $retorno .= "</tr>"; $cont++; if($status_atual != $status){ $status_atual = $status; $total = qtdStatus($status_atual); $status_qtd[$status_atual] = $total['total']; } if($cont == $total['total']){ $retorno .= "<tr class='destaque'><td colspan='4'>{$total['total']} pessoa(s) com status {$status_atual}</td></tr>"; $cont = 0; } endforeach ; $datay=array_values($status_qtd); // Create the graph. These two calls are always required $graph = new Graph(1000,200,'auto'); $graph->SetScale("textlin"); $theme_class=new UniversalTheme; $graph->SetTheme($theme_class); $tick = array(0); $soma = array_sum($status_qtd); $graph->yaxis->SetTickPositions(array_reverse(array_merge(array_values($status_qtd),$tick), false),array(0,1)); $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels(array_keys($status_qtd)); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false,false); // Create the bar plots $bplot = new BarPlot($datay); // ...and add it to the graPH $graph->Add($bplot); $bplot->SetColor("white"); $bplot->SetFillColor("#1111cc"); $bplot->SetWidth(45); $bplot->value->show(); $bplot->value->SetColor("black"); $graph->title->Set("QUANTIDADE X STATUS DA OBRA DE HORIZONTE"); //Salva a imagem do grafico $graph->Stroke("resources/img/quadrante.png"); //Define uma permissão para o arquivo, isto para o meu caso! chmod("resources/img/quadrante.png",0777); $retorno .= '</table><img src="resources/img/quadrante.png">'; return $retorno; }
function getChart($exec_arr, $auto_arr, $user_arr, $testplan_name) { $data1y = $exec_arr; $data2y = $auto_arr; // Create the graph. These two calls are always required $graph = new Graph(1500, 300, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->yaxis->SetTickPositions(array(20, 40, 60, 80, 100), array(10, 30, 50, 70, 90)); $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels($user_arr); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Create the bar plots $b1plot = new BarPlot($data1y); $b2plot = new BarPlot($data2y); // Create the grouped bar plot $gbplot = new GroupBarPlot(array($b1plot, $b2plot)); $gbplot->SetWidth(0.3); // ...and add it to the graPH $graph->Add($gbplot); $b1plot->SetColor("white"); $b1plot->SetFillColor("red"); $b1plot->SetAbsWidth(10); $b1plot->SetLegend("Executed"); $b2plot->SetColor("white"); $b2plot->SetFillColor("green"); $b2plot->SetAbsWidth(10); $b2plot->SetLegend("Automated"); $graph->title->Set("Execution Status of {$testplan_name}"); $graph->yaxis->title->Set("value in %"); // Display the graph //$graph->Stroke(); $graph->img->SetImgFormat('jpeg'); $fileName = "execution.jpeg"; $graph->Stroke($fileName); return $fileName; }