Example #1
0
function graficarBarras()
{
    require_once "jpgraph/src/jpgraph.php";
    require_once "jpgraph/src/jpgraph_bar.php";
    $datos = array($_GET['pos'], $_GET['neg']);
    //Instancia del objeto del tipo Graph en donde como parametro
    // se le pasan los valore de ancho y altura
    $grafica = new Graph(400, 300);
    $grafica->SetScale("textlin");
    $grafica->SetBox(false);
    //Nombre de las columnas
    $columnas = array($_GET['lab1'], $_GET['lab2']);
    $grafica->xaxis->SetTickLabels($columnas);
    //Objeto del tipo BarPlot que se le enviara a la grafica y el cual
    //recibe como parametros los datos a graficar
    $barras = new BarPlot($datos);
    $grafica->Add($barras);
    //Color de los bordes
    //Color de borde de las barras
    $barras->SetColor("white");
    //Color de relleno de las barras
    $barras->SetFillColor("#4B0082");
    //Ancho de las barras
    $barras->SetWidth(45);
    // $grafica->title->Set("Gráfica de Barras");
    $grafica->title->SetFont(FF_TIMES, FS_ITALIC, 18);
    $grafica->Stroke();
}
Example #2
0
 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();
 }
 public function build()
 {
     $path = APPPATH;
     require_once $path . 'libraries/jpgraph/src/jpgraph.php';
     require_once $path . 'libraries/jpgraph/src/jpgraph_bar.php';
     //        $datay = array(62, 105, 85, 50);
     $datay = $this->parameters;
     // Create the graph. These two calls are always required
     //        $graph = new Graph(350, 220, 'auto');
     $graph = new Graph(350, 220, 'auto');
     $graph->SetScale("textlin");
     //$theme_class="DefaultTheme";
     //$graph->SetTheme(new $theme_class());
     // set major and minor tick positions manually
     $graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135));
     $graph->SetBox(false);
     //$graph->ygrid->SetColor('gray');
     $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($datay);
     $b1plot = new BarPlot($datay);
     // ...and add it to the graPH
     $graph->Add($b1plot);
     $b1plot->SetColor("white");
     $b1plot->SetFillGradient("#4B0082", "white", GRAD_LEFT_REFLECTION);
     $b1plot->SetWidth(45);
     $graph->title->Set("Bar Gradient(Left reflection)");
     // Display the graph
     $d['grafica'] = $graph->Stroke("jacobo.png");
     $d['path'] = $path;
     return $d;
 }
 public static function HistogramShow($data_x, $data_y, $max_y, $graph_title = "", $x_title = "", $y_title = "")
 {
     //柱状图生成函数
     $graph = new Graph(LENHSIZE, HEISIZE, "auto");
     //创建画布
     // $graph->SetScale('textlin');  // 设置y轴的值   这里是0到60
     $graph->SetScale("textlin");
     $graph->yscale->ticks->Set($max_y / 2, 1);
     $graph->yaxis->HideTicks(true, true);
     $graph->yaxis->scale->SetGrace(20);
     $graph->SetBox(false);
     //创建画布阴影
     $graph->SetShadow();
     $graph->img->SetMargin(LEFT, RIGHT, UP, DOWN);
     // $graph->img->SetMargin(40,30,30,50);//设置显示区左、右、上、下距边线的距离,单位为像素
     $bplot = new BarPlot($data_y);
     //创建一个矩形的对象
     $graph->InitializeFrameAndMargin();
     $graph->Add($bplot);
     //将柱形图添加到图像中
     $bplot->SetColor(BAR_COLOR);
     $bplot->SetFillColor(BAR_COLOR);
     $bplot->SetWidth(25);
     $graph->title->Set($graph_title);
     //创建标题"借出次数统计结果(按借出次数由由低到高排列)"
     $graph->xaxis->SetTickLabels($data_x);
     //设置X坐标轴文字
     $bplot->SetShadow(SHADOW);
     //设置阴影效果
     $bplot->value->Show();
     if ($max_y <= 1) {
         $bplot->value->SetFormat('%0.4f');
     } else {
         $bplot->value->SetFormat('%d');
         //在柱形图中显示格式化的评选结果
     }
     $graph->xaxis->title->Set($x_title);
     $graph->yaxis->title->Set($y_title);
     // $graph->xaxis->SetTextTickInterval($y_title,0.2);
     $graph->xaxis->title->setFont(FF_SIMSUN);
     $graph->yaxis->title->setFont(FF_SIMSUN);
     $graph->title->setFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE);
     //设置字体
     $graph->xaxis->setFont(FF_SIMSUN, FS_BOLD, X_FONT);
     //设置字体
     $graph->xaxis->SetLabelAngle(45);
     $num = rand(0, RAND);
     $name = "Histogrm" . $num . ".png";
     session_start();
     $_SESSION["name"] = $name;
     $graph->Stroke($name);
     return $name;
 }
Example #5
0
 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);
 }
Example #6
0
<?php

// 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();
 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();
 }
Example #8
0
 public static function HistogramShow($data_x, $data_y, $x_title = "", $y_title = "", $graph_title = "", $max_y)
 {
     //柱状图生成函数
     $graph = new Graph(LENHSIZE, HEISIZE, "auto");
     //创建画布
     // $graph->SetScale('textlin');  // 设置y轴的值   这里是0到60
     if ($max_y > 1) {
         // echo var_dump('sdfsfs');
     }
     $graph->SetScale("textlin");
     $graph->yscale->ticks->Set($max_y / 2, 1);
     $graph->yaxis->HideTicks(true, true);
     $graph->yaxis->scale->SetGrace(20);
     $graph->SetBox(false);
     //创建画布阴影
     $graph->SetShadow();
     $graph->img->SetMargin(LEFT, RIGHT, UP, DOWN);
     // $graph->img->SetMargin(40,30,30,50);//设置显示区左、右、上、下距边线的距离,单位为像素
     $bplot = new BarPlot($data_y);
     //创建一个矩形的对象
     // $bplot->SetFillColor("red"); //设置柱形图的颜色
     // $graph->xaxis->title->SetColor('black');
     // $graph->doshadow=true;
     $graph->InitializeFrameAndMargin();
     // $graph->SetBackgroundGradient();
     // $bplot->SetFillGradient(array(50,50,200));
     $graph->Add($bplot);
     //将柱形图添加到图像中
     // $graph->SetColor(BAR_COLOR);
     $bplot->SetColor(BAR_COLOR);
     $bplot->SetFillColor(BAR_COLOR);
     $bplot->SetWidth(25);
     // $bplot->SetFillGradient("#4B0082","white",GRAD_LEFT_REFLECTION);
     // $bplot->Set3D();
     // $graph->SetMarginColor("lightblue");//设置画布背景色为淡蓝色
     $graph->title->Set($graph_title);
     //创建标题"借出次数统计结果(按借出次数由由低到高排列)"
     $graph->xaxis->SetTickLabels($data_x);
     //设置X坐标轴文字
     $bplot->SetShadow(SHADOW);
     //设置阴影效果
     // $graph->xaxis->SetColor('black');
     // $graph->title->SetMargin(10);
     // $graph->yaxis->SetTickLabels(range(0, 6));
     $bplot->value->Show();
     if ($max_y < 1) {
         $bplot->value->SetFormat('%0.4f');
     } else {
         $bplot->value->SetFormat('%d');
         //在柱形图中显示格式化的评选结果
     }
     $graph->xaxis->title->Set($x_title);
     $graph->yaxis->title->Set($y_title);
     // $graph->xaxis->SetTextTickInterval($y_title,0.2);
     $graph->xaxis->title->setFont(FF_SIMSUN);
     $graph->yaxis->title->setFont(FF_SIMSUN);
     $graph->title->setFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE);
     //设置字体
     $graph->xaxis->setFont(FF_SIMSUN, FS_BOLD, X_FONT);
     //设置字体
     $graph->xaxis->SetLabelAngle(45);
     // $graph->Stroke();//输出矩形图表
     $num = rand(0, RAND);
     // echo var_dump($num);
     $name = "Histogrm" . $num . ".png";
     session_start();
     $_SESSION["name"] = $name;
     // echo var_dump($_SESSION["name"]);
     $graph->Stroke($name);
     return $name;
 }
Example #9
0
$graph->title->Set('Example of combined graph');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14);
$graph->xaxis->SetTickPositions($tickPositions, $minTickPositions);
$graph->xaxis->SetLabelFormatString('My', true);
$graph->xgrid->Show();
$p1 = new LinePlot($datay, $datax);
$graph->Add($p1);
//----------------------
// Setup the bar graph
//----------------------
$graph2 = new Graph($w, 110);
$graph2->SetScale('linlin', 0, 0, $xmin, $xmax);
$graph2->SetMargin($lm, $rm, 5, 10);
$graph2->SetMarginColor('white');
$graph2->SetFrame(false);
$graph2->SetBox(true);
$graph2->xgrid->Show();
$graph2->xaxis->SetTickPositions($tickPositions, $minTickPositions);
$graph2->xaxis->SetLabelFormatString('My', true);
$graph2->xaxis->SetPos('max');
$graph2->xaxis->HideLabels();
$graph2->xaxis->SetTickSide(SIDE_DOWN);
$b1 = new BarPlot($datay2, $datax);
$b1->SetFillColor('teal');
$b1->SetColor('teal:1.2');
$graph2->Add($b1);
//-----------------------
// Create a multigraph
//----------------------
$mgraph = new MGraph();
$mgraph->SetMargin(2, 2, 2, 2);
Example #10
0
 public function curve_chart($total, $previousyear, $previousmonth, $xdata, $title)
 {
     require_once 'Examples/jpgraph/jpgraph.php';
     require_once 'Examples/jpgraph/jpgraph_line.php';
     require_once 'Examples/jpgraph/jpgraph_bar.php';
     $datax = array('1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月');
     // Create the graph.
     $graph = new Graph(1000, 400);
     $graph->SetScale("textlin");
     $graph->SetMarginColor('white');
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD);
     // 设置中文字体
     $graph->subtitle->SetFont(FF_SIMSUN);
     $graph->subsubtitle->SetFont(FF_SIMSUN);
     // Adjust the margin slightly so that we use the
     // entire area (since we don't use a frame)
     $graph->SetMargin(20, 1, 20, 90);
     // Box around plotarea
     $graph->SetBox();
     // No frame around the image
     $graph->SetFrame(false);
     // Setup the tab title
     $graph->tabtitle->Set($title);
     $graph->tabtitle->SetFont(FF_SIMSUN, FS_BOLD, 10);
     // Setup the X and Y grid
     $graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5');
     $graph->ygrid->SetLineStyle('dashed');
     $graph->ygrid->SetColor('gray');
     $graph->xgrid->Show();
     $graph->xgrid->SetLineStyle('dashed');
     $graph->xgrid->SetColor('gray');
     $graph->xaxis->SetLabelAngle(35);
     $graph->legend->SetFont(FF_SIMSUN, FS_NORMAL);
     $graph->legend->SetPos(0.01, 0.01);
     // Setup month as labels on the X-axis
     $graph->xaxis->SetTickLabels($xdata);
     $graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 8);
     // Create the linear error plot
     $l1plot = new LinePlot($previousyear);
     $l1plot->SetColor('red');
     $l1plot->SetWeight(2);
     $l1plot->SetLegend('环比');
     // Create the linear error plot
     $l2plot = new LinePlot($previousmonth);
     $l2plot->SetColor('yellow');
     $l2plot->SetWeight(2);
     $l2plot->SetLegend('同比');
     // Create the bar plot
     $bplot = new LinePlot($total);
     $bplot->SetColor('orange');
     $bplot->SetWeight(2);
     $bplot->SetLegend('总量');
     // Add the plots to t'he graph
     $graph->Add($bplot);
     $graph->Add($l1plot);
     $graph->Add($l2plot);
     //		$graph->title->Set('Adding a line plot to a bar graph v1');
     //		$graph->xaxis->title->Set('X-title');
     $graph->yaxis->title->Set('月份');
     $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->SetTickLabels($datax);
     //$graph->xaxis->SetTextTickInterval(2);
     // Display the graph
     $graph->Stroke();
 }
Example #11
0
/**
 * Un tableau contenant les moyennes des eleves pour chaque sequences
 * 
 * @param type $moyennes = array()
 */
function genererCourbe($moyennes, $eleve)
{
    try {
        # Donnees de la courbe
        $ydata = $moyennes;
        $ydata2 = $moyennes;
        /* for ($i = 1; $i <= 6; $i++) {
           $r = rand(0, 20);
           $ydata[] = $r;
           $ydata2[] = $r;
           } */
        /** Definition des label de l'axe x */
        $datax = array("seq 1", "seq 2", "seq 3", "seq 4", "seq 5", "seq 6");
        # Creation du graph
        $graph = new Graph(350, 250, 'auto');
        $graph->SetMarginColor('white');
        # Definir le max et le min des valeur X
        $graph->SetScale('textlin', 0, 20);
        #$graph->xaxis->title->Set("Séquences");
        $graph->yaxis->title->Set("Moyennes");
        $graph->xaxis->SetTickLabels($datax);
        $graph->xaxis->SetTitle("Séquences", "middle");
        $graph->SetBackgroundGradient('white', 'lightblue', GRAD_HOR, BGRAD_PLOT);
        # Adjuster les margins (left, right, top, bottom)
        $graph->SetMargin(40, 5, 21, 45);
        # Box autour du plotarea
        $graph->SetBox();
        # Un cadre ou frame autour de l'image
        $graph->SetFrame(false);
        # Definir le titre tabulaire
        $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 8);
        $graph->tabtitle->Set($_SESSION['anneeacademique']);
        # Definir le titre du graphe
        $graph->title->SetFont(FF_VERDANA, FS_NORMAL, 8);
        $graph->title->SetAlign("right");
        if (count($ydata) > 1) {
            $prev = $ydata[count($ydata) - 2];
            if ($prev < $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance en hausse");
            } elseif ($prev == $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance constante");
            } else {
                $graph->title->Set("Performance en baisse");
            }
        }
        # Definir les grid X et Y
        $graph->ygrid->SetFill(true, '#BBBBBB@0.9', '#FFFFFF@0.9');
        //$graph->ygrid->SetLineStyle('dashed');
        //$graph->ygrid->SetColor('gray');
        //$graph->xgrid->SetLineStyle('dashed');
        $graph->xgrid->SetColor('gray');
        $graph->xgrid->Show();
        //$graph->ygrid->Show();
        #$graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_MARGIN);
        $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
        $graph->xaxis->SetLabelAngle(0);
        # Creation d'une bar pot
        $bplot = new BarPlot($ydata);
        $bplot->SetWidth(0.9);
        $fcol = '#440000';
        $tcol = '#FF9090';
        $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION);
        # Set line weigth to 0 so that there are no border around each bar
        $bplot->SetWeight(0);
        # Create filled line plot
        $lplot = new LinePlot($ydata2);
        $lplot->SetFillColor('skyblue@0.5');
        $lplot->SetStyle(1);
        $lplot->SetColor('navy@0.7');
        $lplot->SetBarCenter();
        $lplot->mark->SetType(MARK_SQUARE);
        $lplot->mark->SetColor('blue@0.5');
        $lplot->mark->SetFillColor('lightblue');
        $lplot->mark->SetSize(5);
        # Afficher les moyenne au dessus des barres
        $accbarplot = new AccBarPlot(array($bplot));
        $accbarplot->value->SetFormat("%.2f");
        $accbarplot->value->Show();
        $graph->Add($accbarplot);
        $graph->SetBackgroundImageMix(50);
        # Definir un fond d'ecran pour l'image
        $background = SITE_ROOT . "public/photos/eleves/" . $eleve['PHOTO'];
        if (!empty($eleve['PHOTO']) && file_exists(ROOT . DS . "public" . DS . "photos" . DS . "eleves" . DS . $eleve['PHOTO'])) {
            $graph->SetBackgroundImage($background, BGIMG_FILLPLOT);
            # $icon = new IconPlot($background, 25, 25, 0.8, 50);
        } else {
            //$graph->SetBackgroundImage(SITE_ROOT . "public/img/". LOGO, BGIMG_FILLPLOT);
            # $icon = new IconPlot(SITE_ROOT . "public/img/ipw.png", 25, 25, 0.8, 50);
        }
        # $icon->SetAnchor('right', 'bottom');
        $graph->Add($lplot);
        // Display the graph
        $filename = ROOT . DS . "public" . DS . "tmp" . DS . $eleve['IDELEVE'] . ".png";
        if (file_exists($filename)) {
            unlink($filename);
        }
        $graph->Stroke($filename);
        //echo "<img src='" . SITE_ROOT . "public/tmp/emp.png' />";
    } catch (Exception $e) {
        var_dump($e);
    }
}
    if ($i % DATAPERMONTH === 0) {
        $months[$i] = $m[(int) ($i / DATAPERMONTH)];
    } else {
        $months[$i] = 'xx';
    }
}
// New graph with a drop shadow
$graph = new Graph(400, 200);
//$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale('textlin');
// Specify X-labels
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetTextTickInterval(DATAPERMONTH, 0);
$graph->xaxis->SetTextLabelInterval(2);
// Set title and subtitle
$graph->title->Set('Textscale with tickinterval=2');
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->SetBox(true, 'red');
// Create the bar plot
$lp1 = new LinePlot($datay);
$lp1->SetLegend('Temperature');
// The order the plots are added determines who's ontop
$graph->Add($lp1);
// Finally output the  image
$graph->Stroke();
?>


Example #13
0
 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);
 }
Example #14
0
 private function barVPlot($question, $datax, $datay, $width, $height)
 {
     include_once BASE . "jpgraph.php";
     include_once BASE . "jpgraph_bar.php";
     $tFontSize = 11;
     $xFontSize = 6 + $height / $this->amountOfVariants / 30;
     $maxX = 0;
     foreach ($datax as $x) {
         if (($t = strlen($x)) > $maxX) {
             $maxX = $t;
         }
     }
     for ($i = 0; $i < $this->amountOfVariants; $i++) {
         $x =& $datax[$i];
         if (($t = strlen($x)) >= MAXCHARSPERLINE) {
             $index = strrpos(substr($x, 0, MAXCHARSPERLINE - 1), ' ');
             if ($index === false) {
                 $index = MAXCHARSPERLINE - 3;
             }
             $x[$index] = "\n";
             if ($t > $index + MAXCHARSPERLINE) {
                 $x = substr($x, 0, $index + MAXCHARSPERLINE - 3) . "...";
             }
         }
     }
     unset($x);
     // Set the basic parame graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin", 0, 100);
     //if (amountOfVariants>5) $xFontSize--;
     $lm = 0;
     foreach ($datax as $x) {
         $linia = strtok($x, "\n");
         while ($linia != '') {
             $t = new Text($linia);
             $t->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
             $lineWidth = $t->GetWidth($graph->img);
             if ($lineWidth > $lm) {
                 $lm = $lineWidth;
             }
             //echo $linia.$lineWidth."<BR>";
             $linia = strtok("\n");
         }
     }
     // Rotate graph 90 degrees and set margin
     $graph->SetMargin(35, 20, 40, $lm + 15);
     // Set white margin color
     $graph->SetMarginColor('gray@0.95');
     // Setup title
     //$graph->title->Set($question);
     //$graph->title->SetMargin(10);
     //$graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize);
     $graph->tabtitle->Set($question);
     $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, $tFontSize);
     $tWidth = $graph->tabtitle->GetWidth($graph->img);
     //if ($graph->title->GetWidth($graph->img)>$width) $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize-2);
     if ($tWidth > $width) {
         $index = strrpos(substr($question, 0, ($len = strlen($question)) / 2 + 5), ' ');
         //echo $index;
         if ($index === false) {
             $index = $len / 2 - 3;
         }
         $question[$index] = "\n";
         $graph->tabtitle->Set($question);
         $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, $tFontSize -= 2);
     }
     // Setup X-axis
     $graph->xaxis->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetColor('black');
     $graph->xaxis->SetLabelAngle(80);
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('center', 'top');
     // Add some grace to y-axis so the bars doesn't go
     // all the way to the end of the plot area
     $graph->yaxis->scale->SetGrace(10);
     //$graph->yaxis->SetPos('max');
     //$graph->yaxis->SetLabelAlign('center', 'top');
     //$graph->yaxis->SetLabelSide('SIDE_RIGHT');
     $graph->yaxis->SetLabelFormat('%2d%%');
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     $bplot->SetWidth(0.4);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_VERDANA, FS_NORMAL, $xFontSize);
     //$bplot->SetShadow("black@0.1",2,2);
     //$bplot->value->SetAlign('left','center');
     $bplot->value->SetColor("black");
     $bplot->value->SetFormat('%d%%');
     //$bplot->SetValuePos('max');
     //$graph->SetMarginColor('green');
     // Box around plotarea
     $graph->SetBox();
     $graph->SetFrame(false);
     //	$graph->SetShadow();
     // Setup the X and Y grid
     $graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5');
     $graph->ygrid->SetLineStyle('dashed');
     $graph->ygrid->SetColor('gray');
     $graph->xgrid->Show();
     $graph->xgrid->SetLineStyle('dashed');
     $graph->xgrid->SetColor('gray');
     $fcol = '#440000';
     $tcol = '#FF9090';
     $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION);
     // Set line weigth to 0 so that there are no border
     // around each bar
     $bplot->SetWeight(0);
     $graph->Add($bplot);
     // .. and stroke the graph
     return $graph->Stroke("images/raporty/{$this->id_pytanie}V.png");
     //header("Content-type: image/png");
     //ImagePng($im);
 }
Example #15
0
 public function grafico_deciles($id_asignacionprueba)
 {
     require_once APPPATH . '/libraries/JpGraph/jpgraph_bar.php';
     $this->deciles($id_asignacionprueba);
     $datos = array($this->decil_0, $this->decil_1, $this->decil_2, $this->decil_3, $this->decil_4, $this->decil_5, $this->decil_6, $this->decil_7, $this->decil_8, $this->decil_9);
     $grafica = new Graph(700, 400, 'auto');
     //$grafica->SetScale("textlin");
     $grafica->SetScale('textlin', 0, 50);
     // se determina el limite del eje y
     //Posicion de los puntos de posiciones del eje de las Y
     //$mayor = array(0,5,10);
     //$grafica->yaxis->SetTickPositions($mayor);
     $grafica->ygrid->SetFill(true, '#fff', '#DDDDDD@0.5');
     $grafica->SetMarginColor("#fff");
     $grafica->SetFrame(true, '#fff', 1);
     $grafica->SetBox(false);
     //Nombre de las columnas
     $columnas = array('0%-9%', '10%-19%', '20%-29%', '30%-39%', '40%-49%', '50%-59%', '60%-69%', '70%-79%', '80%-89%', '90%-100%');
     $grafica->xaxis->SetTickLabels($columnas);
     $grafica->yaxis->title->Set("Alumnos por Decil");
     $barras = new BarPlot($datos);
     $grafica->Add($barras);
     $barras->SetColor($this->color_barra);
     //$barras->SetFillColor("#1d71b8");
     $barras->SetFillColor($this->color_barra);
     $barras->SetWidth(45);
     //$barras->SetValuePos('center');
     $barras->value->Show();
     $barras->value->SetFormat('%d');
     // valores en formato de numero entero
     $barras->SetLegend("N° Alumnos");
     $barras->value->SetColor("black");
     $grafica->legend->SetPos(0.5, 0.98, 'center', 'bottom');
     $grafica->legend->SetFrameWeight(1);
     $grafica->title->Set("Gráfico de Deciles");
     $grafica->Stroke(_IMG_HANDLER);
     global $img_graf_deciles;
     $this->img_graf_deciles = "assets/images/graf_deciles.jpg";
     $grafica->img->Stream($this->img_graf_deciles);
     /*
     $grafica->img->Headers();
     $grafica->img->Stream();
     */
 }
Example #16
0
 /**
  * Construct the graph
  * 
  */
 private function Init()
 {
     // Setup limits for color indications
     $lowx = $this->iXMin;
     $highx = $this->iXMax;
     $lowy = $this->iYMin;
     $highy = $this->iYMax;
     $width = $this->iWidth;
     $height = $this->iHeight;
     // Margins
     $lm = 50;
     $rm = 40;
     $tm = 60;
     $bm = 40;
     if ($width <= 300 || $height <= 250) {
         $labelsize = 8;
         $lm = 25;
         $rm = 25;
         $tm = 45;
         $bm = 25;
     } elseif ($width <= 450 || $height <= 300) {
         $labelsize = 8;
         $lm = 30;
         $rm = 30;
         $tm = 50;
         $bm = 30;
     } elseif ($width <= 600 || $height <= 400) {
         $labelsize = 9;
     } else {
         $labelsize = 11;
     }
     if ($this->iSubTitle == '') {
         $tm -= $labelsize + 4;
     }
     $graph = new Graph($width, $height);
     $graph->SetScale('intint', $lowy, $highy, $lowx, $highx);
     $graph->SetMargin($lm, $rm, $tm, $bm);
     $graph->SetMarginColor($this->iMarginColor[$this->iColorMap]);
     $graph->SetClipping();
     $graph->title->Set($this->iTitle);
     $graph->subtitle->Set($this->iSubTitle);
     $graph->title->SetFont(FF_ARIAL, FS_BOLD, $labelsize + 4);
     $graph->subtitle->SetFont(FF_ARIAL, FS_BOLD, $labelsize + 1);
     $graph->SetBox(true, 'black@0.3');
     $graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, $labelsize);
     $graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, $labelsize);
     $graph->xaxis->scale->ticks->Set(CCBPGraph::TickStep, CCBPGraph::TickStep);
     $graph->yaxis->scale->ticks->Set(CCBPGraph::TickStep, CCBPGraph::TickStep);
     $graph->xaxis->HideZeroLabel();
     $graph->yaxis->HideZeroLabel();
     $graph->xaxis->SetLabelFormatString('%d%%');
     $graph->yaxis->SetLabelFormatString('%d%%');
     // For the x-axis we adjust the color so labels on the left of the Y-axis are in black
     $n1 = floor(abs($this->iXMin / 25)) + 1;
     $n2 = floor($this->iXMax / 25);
     if ($this->iColorMap == 0) {
         $xlcolors = array();
         for ($i = 0; $i < $n1; ++$i) {
             $xlcolors[$i] = 'black';
         }
         for ($i = 0; $i < $n2; ++$i) {
             $xlcolors[$n1 + $i] = 'lightgray:1.5';
         }
         $graph->xaxis->SetColor('gray', $xlcolors);
         $graph->yaxis->SetColor('gray', 'lightgray:1.5');
     } else {
         $graph->xaxis->SetColor('darkgray', 'darkgray:0.8');
         $graph->yaxis->SetColor('darkgray', 'darkgray:0.8');
     }
     $graph->SetGridDepth(DEPTH_FRONT);
     $graph->ygrid->SetColor('gray@0.6');
     $graph->ygrid->SetLineStyle('dotted');
     $graph->ygrid->Show();
     $graph->xaxis->SetWeight(1);
     $graph->yaxis->SetWeight(1);
     $ytitle = new Text(CCBPGraph::YTitle, floor($lm * 0.75), ($height - $tm - $bm) / 2 + $tm);
     #$ytitle->SetFont(FF_VERA,FS_BOLD,$labelsize+1);
     $ytitle->SetAlign('right', 'center');
     $ytitle->SetAngle(90);
     $graph->Add($ytitle);
     $xtitle = new Text(CCBPGraph::XTitle, ($width - $lm - $rm) / 2 + $lm, $height - 10);
     #$xtitle->SetFont(FF_VERA,FS_BOLD,$labelsize);
     $xtitle->SetAlign('center', 'bottom');
     $graph->Add($xtitle);
     $df = 'D j:S M, Y';
     if ($width < 400) {
         $df = 'D j:S M';
     }
     $time = new Text(date($df), $width - 10, $height - 10);
     $time->SetAlign('right', 'bottom');
     #$time->SetFont(FF_VERA,FS_NORMAL,$labelsize-1);
     $time->SetColor('darkgray');
     $graph->Add($time);
     // Use an accumulated fille line graph to create the colored bands
     $n = 3;
     for ($i = 0; $i < $n; ++$i) {
         $b = $this->iColorInd[$i][0];
         $k = ($this->iColorInd[$i][1] - $this->iColorInd[$i][0]) / $this->iXMax;
         $colarea[$i] = array(array($lowx, $lowx * $k + $b), array($highx, $highx * $k + $b));
     }
     $colarea[3] = array(array($lowx, $highy), array($highx, $highy));
     $cb = array();
     for ($i = 0; $i < 4; ++$i) {
         $cb[$i] = new LinePlot(array($colarea[$i][0][1], $colarea[$i][1][1]), array($colarea[$i][0][0], $colarea[$i][1][0]));
         $cb[$i]->SetFillColor($this->iColorSpec[$this->iColorMap][$i]);
         $cb[$i]->SetFillFromYMin();
     }
     $graph->Add(array_slice(array_reverse($cb), 0, 4));
     $this->graph = $graph;
 }
Example #17
0
 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);
 }
Example #18
0
/**
 * 
 * @param array $datax
 * @param array $datay1 Moy de classe pour une matiere
 * @param type $datay2 pourcentage de reussite
 */
function tracerCourbeMoyennes($datax, $datay1, $datay2)
{
    // Setup the graph
    $graph = new Graph(850, 400, 'auto');
    $graph->SetMargin(30, 15, 50, 5);
    $graph->SetMarginColor('black');
    $graph->SetScale("linlin");
    $graph->SetBox();
    // Hide the frame around the graph
    $graph->SetFrame(false);
    // Setup title
    #$graph->title->Set("Using Builtin PlotMarks");
    $graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
    // Note: requires jpgraph 1.12p or higher
    // $graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_PLOT);
    #$graph->tabtitle->Set('Region 1' );
    #$graph->tabtitle->SetWidth(TABTITLE_WIDTHFULL);
    // Enable X and Y Grid
    $graph->SetScale('textlin', 0, max($datay2) + 1);
    $graph->xgrid->SetColor('gray@0.5');
    $graph->xaxis->SetTickLabels($datax);
    $graph->ygrid->SetColor('gray@0.5');
    // Format the legend box
    $graph->legend->SetColor('black');
    #$graph->legend->SetFillColor('lightgreen');
    $graph->legend->SetLineWeight(1);
    $graph->legend->SetFont(FF_ARIAL, FS_BOLD, 8);
    $graph->legend->SetShadow('gray@0.4', 3);
    #$graph->legend->SetAbsPos(15,120,'right','top');
    $graph->legend->SetPos(0.3, 0.03, 'right', 'top');
    // Create the line plots
    $p1 = new LinePlot($datay1);
    $p1->SetColor("red");
    $p1->SetFillColor("yellow@0.5");
    $p1->SetWeight(2);
    $p1->mark->SetType(MARK_IMG_DIAMOND, 5, 0.6);
    $p1->SetLegend('Moy.Classe');
    $graph->Add($p1);
    $p2 = new LinePlot($datay2);
    $p2->SetColor("darkgreen");
    $p2->SetWeight(2);
    $p2->SetLegend('%REUSSITE');
    $p2->mark->SetType(MARK_IMG_MBALL, 'red');
    $graph->Add($p2);
    // Add a vertical line at the end scale position '7'
    $l1 = new PlotLine(VERTICAL, intval(count($datax) / 2));
    $graph->Add($l1);
    // Display the graph
    $filename = ROOT . DS . "public" . DS . "tmp" . DS . "courbe.png";
    if (file_exists($filename)) {
        unlink($filename);
    }
    $graph->Stroke($filename);
}
Example #19
0
$graph2->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph2->yaxis->SetLabelMargin(0);
$graph2->yaxis->scale->SetAutoMin(0);
$line2 = new LinePlot($data_windspeed, $xdata);
$line2->SetStepStyle();
$line2->SetColor('red');
$graph2->Add($line2);
//------------------------------------------------------------------
// Setup the wind temp graph
//------------------------------------------------------------------
$graph3 = new Graph(WIND_WIDTH - 30, WIND_HEIGHT);
$graph3->SetScale('datlin');
$graph3->Set90AndMargin(5, 20, 70, 30);
$graph3->SetMarginColor(BKG_COLOR);
$graph3->SetFrame(true, 'white', 0);
$graph3->SetBox();
$graph3->title->Set('Temperature');
$graph3->title->SetColor('black');
$graph3->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph3->title->SetMargin(5);
$graph3->xaxis->HideLabels();
$graph3->xgrid->Show();
$graph3->yaxis->SetLabelAngle(90);
$graph3->yaxis->SetColor('black');
$graph3->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph3->yaxis->SetLabelMargin(0);
$graph3->yaxis->scale->SetAutoMin(-10);
$line3 = new LinePlot($data_windtemp, $xdata);
$line3->SetStepStyle();
$line3->SetColor('black');
$graph3->Add($line3);
Example #20
0
$graph->yaxis->SetLabelAngle(90);
$graph->yaxis->SetColor('blue');
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->SetLabelMargin(0);
$graph->yaxis->scale->SetAutoMin(0);
$line = new LinePlot($data_winddirection, $xdata);
$line->SetStepStyle();
$line->SetColor('blue');
$graph->Add($line);
// Setup the wind speed graph
$graph2 = new Graph(WIND_WIDTH - 30, WIND_HEIGHT);
$graph2->SetScale('datlin');
$graph2->Set90AndMargin(5, 20, 60, 30);
$graph2->SetMarginColor(BKG_COLOR);
$graph2->SetFrame(true, 'white', 0);
$graph2->SetBox();
$graph2->title->Set('Windspeed');
$graph2->title->SetColor('red');
$graph2->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph2->title->SetMargin(5);
$graph2->xaxis->HideLabels();
$graph2->xgrid->Show();
$graph2->yaxis->SetLabelAngle(90);
$graph2->yaxis->SetColor('red');
$graph2->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph2->yaxis->SetLabelMargin(0);
$graph2->yaxis->scale->SetAutoMin(0);
$line2 = new LinePlot($data_windspeed, $xdata);
$line2->SetStepStyle();
$line2->SetColor('red');
$graph2->Add($line2);
Example #21
0
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;
}
 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;
     }
 }
Example #23
0
<?php

// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_bar.php";
$datay = array(10, 29, 3, 6);
// Create the graph.
$graph = new Graph(200, 200);
$graph->SetScale('textlin');
$graph->SetMargin(25, 10, 20, 25);
$graph->SetBox(true);
// Add 10% grace ("space") at top and botton of Y-scale.
$graph->yscale->SetGrace(10);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor("lightblue");
$graph->ygrid->Show(false);
// .. and add the plot to the graph
$graph->Add($bplot);
// Add band
$band = new PlotBand(HORIZONTAL, BAND_3DPLANE, 15, 35, 'khaki4');
$band->SetDensity(10);
$band->ShowFrame(true);
$graph->AddBand($band);
// Set title
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->title->SetColor('darkred');
$graph->title->Set('BAND_3DPLANE, Density=10');
$graph->Stroke();
Example #24
0
function create_graph_barplot($text, $datay, $width, $height)
{
    $margex = 140;
    $graph = new Graph($width, $height);
    $tab_txt = explode('|', $text);
    $txt = new Text($tab_txt[0]);
    $txt->SetPos(0, $height - 40);
    $txt->SetColor('red');
    $txtb = new Text($tab_txt[1] . ' ' . $tab_txt[2] . ' ' . $tab_txt[3]);
    $txtb->SetPos(0, $height / 2);
    $graph->AddText($txt);
    $graph->AddText($txtb);
    $graph->SetScale('textlin', 0, max($datay));
    $graph->SetBox();
    $graph->xaxis->HideLabels();
    $graph->yaxis->HideLabels();
    $graph->yaxis->SetPos('max');
    $graph->yaxis->SetTitle(max($datay), 'high');
    $graph->yaxis->SetTitleMargin(15);
    $graph->yaxis->SetTitleSide(SIDE_RIGHT);
    $graph->xgrid->Show();
    $graph->img->SetMargin($margex, 15, 1, 1);
    $graph->SetFrame(true, 'black', 0);
    $graph->ygrid->SetWeight(0, 0);
    $graph->ygrid->SetFill(false);
    $graph->xaxis->SetTextTickInterval(12, 0);
    $bplot = new BarPlot($datay);
    $graph->Add($bplot);
    return $graph;
}
Example #25
0
$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>";
    // Create the first line
    $p[$key] = new LinePlot($value);
    //$graph->Add($p[$key]);
Example #26
0
$numpoints = 50;
$k = 0.05;
// Create some data points
for ($i = 0; $i < $numpoints; ++$i) {
    $datay[$i] = exp(-$k * $i) * cos(2 * M_PI / 10 * $i);
}
// A format callbakc function
function mycallback($l)
{
    return sprintf("%02.2f", $l);
}
// Setup the basic parameters for the graph
$graph = new Graph(400, 200);
$graph->SetScale("intlin");
$graph->SetShadow();
$graph->SetBox();
$graph->title->Set("Impuls Example 3");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Set format callback for labels
$graph->yaxis->SetLabelFormatCallback("mycallback");
// Set X-axis at the minimum value of Y-axis (default will be at 0)
$graph->xaxis->SetPos("min");
// "min" will position the x-axis at the minimum value of the Y-axis
// Extend the margin for the labels on the Y-axis and reverse the direction
// of the ticks on the Y-axis
$graph->yaxis->SetLabelMargin(12);
$graph->xaxis->SetLabelMargin(6);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->xaxis->SetTickSide(SIDE_DOWN);
// Create a new impuls type scatter plot
$sp1 = new ScatterPlot($datay);
Example #27
0
<?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();
?>


Example #28
0
 /**
  * 横柱图
  * 
  */
 function createhorizoncolumnar($title, $subtitle, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array())
 {
     vendor("Jpgraph.jpgraph");
     vendor("Jpgraph.jpgraph_bar");
     $datay = $data;
     $datax = $legend;
     //编码转化
     foreach ($datax as $k => $v) {
         $datax[$k] = iconv('utf-8', 'gb2312', $v);
     }
     // Size of graph
     $count = count($datay);
     $addheight = 0;
     if ($count > 10) {
         $addheight = ($count - 10) * 20;
     }
     $height = $height + $addheight;
     // Set the basic parameters of the graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin");
     // No frame around the image
     $graph->SetFrame(false);
     $graph->SetFrame(false, '#ffffff', 0);
     //去掉周围的边框
     // Rotate graph 90 degrees and set margin
     $graph->Set90AndMargin(70, 10, 50, 30);
     // Set white margin color
     $graph->SetMarginColor('white');
     // Use a box around the plot area
     $graph->SetBox();
     // Use a gradient to fill the plot area
     $graph->SetBackgroundGradient('white', 'white', GRAD_HOR, BGRAD_PLOT);
     // Setup title
     $graph->title->Set(iconv('utf-8', 'gb2312', "{$title}"));
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 12);
     $graph->subtitle->Set("(" . iconv('utf-8', 'gb2312', $subtitle) . ")");
     $graph->subtitle->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Setup X-axis
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('right', 'center');
     // Add some grace to y-axis so the bars doesn't go
     // all the way to the end of the plot area
     $graph->yaxis->scale->SetGrace(10);
     // We don't want to display Y-axis
     $graph->yaxis->Hide();
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     //$bplot->SetShadow();
     //You can change the width of the bars if you like
     //$bplot->SetWidth(0.5);
     // Set gradient fill for bars
     $bplot->SetFillGradient('blue', '#0080C0', GRAD_HOR);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 7);
     $bplot->value->SetAlign('left', 'center');
     $bplot->value->SetColor("black");
     $bplot->value->SetFormat('%.0f');
     //$bplot->SetValuePos('max');
     // Add the bar to the graph
     $graph->Add($bplot);
     // Add some explanation text
     $txt = new Text('');
     $txt->SetPos(130, 399, 'center', 'bottom');
     $txt->SetFont(FF_COMIC, FS_NORMAL, 8);
     $graph->Add($txt);
     // .. and stroke the graph
     $graph->Stroke();
 }
 public function getGrafmayorcosto()
 {
     JpGraph::module('bar');
     $graph = new Graph(680, 300);
     $graph->SetScale("textlin");
     $graph->yscale->SetGrace(5);
     $graph->SetBox(true);
     $labels = array();
     $valores = array();
     foreach (Activo::where('id', '>', '0')->orderBy('costo', 'desc')->take(10)->get() as $activo) {
         $labels[] = $activo->num_activo;
         $valores[] = $activo->costo;
     }
     //titulo de la grafica
     $graph->title->SetColor('black');
     $graph->title->Set('Gráfica: Activos con Mayor Costo');
     //valores de los labels en ambas axis y como se ubicaran
     $graph->xaxis->SetTickLabels($labels);
     $graph->xaxis->SetLabelAlign('center', 'top', 'center');
     $graph->ygrid->SetFill(false);
     $graph->yaxis->HideLabels(false);
     $graph->yaxis->HideTicks(false, false);
     //Fonts para las axis
     $graph->xaxis->SetColor('black');
     $graph->yaxis->SetColor('black');
     //grafica de activos con mayor costo
     $mayorCosto = new BarPlot($valores);
     $mayorCosto->SetColor('white');
     $mayorCosto->SetWidth(0.6);
     //agrega la grafica generada a la instancia de la grafica
     $graph->Add($mayorCosto);
     //Despliega la grafica
     $graph->Stroke();
 }