function conf__grafico(toba_ei_grafico $grafico)
 {
     if (isset($this->datos)) {
         $datos = array();
         $leyendas = array();
         foreach ($this->datos as $value) {
             $datos[] = $value['resultado'];
             $leyendas[] = $value['codc_uacad'];
         }
     }
     require_once toba_dir() . '/php/3ros/jpgraph/jpgraph.php';
     require_once toba_dir() . '/php/3ros/jpgraph/jpgraph_bar.php';
     // Setup a basic graph context with some generous margins to be able
     // to fit the legend
     $canvas = new Graph(900, 300);
     $canvas->SetMargin(100, 140, 60, 40);
     $canvas->title->Set('Cr�dito Disponible');
     //$canvas->title->SetFont(FF_ARIAL,FS_BOLD,14);
     // For contour plots it is custom to use a box style ofr the axis
     $canvas->legend->SetPos(0.05, 0.5, 'right', 'center');
     $canvas->SetScale('intint');
     //$canvas->SetAxisStyle(AXSTYLE_BOXOUT);
     //$canvas->xgrid->Show();
     $canvas->ygrid->Show();
     $canvas->xaxis->SetTickLabels($leyendas);
     // A simple contour plot with default arguments (e.g. 10 isobar lines)
     $cp = new BarPlot($datos);
     $cp->SetColor("#B0C4DE");
     $cp->SetFillColor("#B0C4DE");
     $cp->SetLegend("Resultado");
     $canvas->Add($cp);
     // Con esta llamada informamos al gr�fico cu�l es el gr�fico que se tiene
     // que dibujar
     $grafico->conf()->canvas__set($canvas);
 }
Beispiel #2
0
function draw_graph($xarr, $arr)
{
    require_once "jpgraph/jpgraph.php";
    require_once "jpgraph/jpgraph_line.php";
    require_once "jpgraph/jpgraph_bar.php";
    require_once "jpgraph/jpgraph_log.php";
    // Create the graph. These two calls are always required
    $graph = new Graph(350, 250, "auto");
    //$graph->SetScale("lin");
    //$graph->SetScale("textlin");
    $graph->SetScale("loglin");
    // Create the linear plot
    $lineplot = new BarPlot($arr, $xarr);
    $lineplot->SetColor("blue");
    // Add the plot to the graph
    $graph->Add($lineplot);
    // Display the graph
    $graph->Stroke();
}
Beispiel #3
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);
 }
Beispiel #4
0
// 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);
$mgraph->SetFrame(true, 'darkgray', 2);
$mgraph->Add($graph);
$mgraph->Add($graph2, 0, 240);
$mgraph->Stroke();
?>


Beispiel #5
0
<?php

include "inc/jpgraph.php";
include "inc/jpgraph_bar.php";
include "inc/jpgraph_pie.php";
$ydata = array(11, 20, 8, 12, 5, 1, 9, 13, 5, 7);
$graph = new Graph(350, 250, "auto");
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 20, 20, 40);
$graph->title->Set("Empleados");
$graph->xaxis->title->Set("Mes");
$graph->yaxis->title->Set("Dinero");
$barplot = new BarPlot($ydata);
$barplot->SetColor("orange");
$graph->Add($barplot);
$graph->Stroke();
// Se define el array de valores y el array de la leyenda
$datos = array(40, 60, 21, 33);
$leyenda = array("Morenas", "Rubias", "Pelirrojas", "Otras");
//Se define el grafico
$grafico = new PieGraph(450, 300);
//Definimos el titulo
$grafico->title->Set("Mi primer grafico de tarta");
$grafico->title->SetFont(FF_FONT1, FS_BOLD);
//Añadimos el titulo y la leyenda
$p1 = new PiePlot($datos);
$p1->SetLegends($leyenda);
$p1->SetCenter(0.4);
//Se muestra el grafico
$grafico->Add($p1);
$grafico->Stroke();
Beispiel #6
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);
 }
$graph->xaxis->SetPosAbsDelta(15);
$graph->yaxis->SetPosAbsDelta(-15);
$graph->xaxis->SetLabelAngle(50);
// Legend
$graph->legend->SetMarkAbsSize(5);
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->legend->Pos(0.02, 0.02, "right", "top");
// Create the bar pot
$colors = array("#aa5500", "#55aa00", "#0055aa", "#aa0055", "#5500aa", "#00aa55", "#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff", "#00ffff");
$listPlots = array();
foreach ($opbysalle as $key => $value) {
    $bplot = new BarPlot($value["sejour"]);
    $from = $colors[$key];
    $to = "#EEEEEE";
    $bplot->SetFillGradient($from, $to, GRAD_LEFT_REFLECTION);
    $bplot->SetColor("white");
    $bplot->setLegend($value["nom"]);
    $bplot->value->SetFormat("%01.0f");
    $bplot->value->SetColor($colors[$key]);
    $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
    //$bplot->value->show();
    $listPlots[] = $bplot;
}
$gbplot = new AccBarPlot($listPlots);
$gbplot->SetWidth(0.6);
$gbplot->value->SetFormat("%01.0f");
$gbplot->value->show();
// Set color for the frame of each bar
$graph->Add($gbplot);
// Finally send the graph to the browser
$graph->Stroke();
Beispiel #8
0
    $line1 = new LinePlot($data_total_size);
    if ($is_MCP_enabled === true) {
        $abar1 = new AccBarPlot(array($bar2, $bar3, $bar4));
    } else {
        $abar1 = new AccBarPlot(array($bar2, $bar3));
    }
    $gbplot = new GroupBarPlot(array($bar1, $abar1));
    $graph->Add($gbplot);
    $graph->AddY2($line1);
    $bar1->SetColor('blue');
    $bar1->SetFillColor('blue');
    $bar1->SetLegend('Mail');
    $bar2->SetColor('orange');
    $bar2->SetFillColor('orange');
    $bar2->SetLegend('Viruses');
    $bar3->SetColor('red');
    $bar3->SetFillColor('red');
    $bar3->SetLegend('Spam');
    if ($is_MCP_enabled === true) {
        $bar4->SetFillColor('lightblue');
        $bar4->SetLegend('MCP');
    }
    $line1->SetColor('lightgreen');
    $line1->SetFillColor('lightgreen');
    $line1->SetLegend('Volume (' . $size_info['shortdesc'] . ')');
    $line1->SetCenter();
    $graph->Stroke($filename);
}
// HTML Code to display the graph
echo "<TABLE BORDER=\"0\" CELLPADDING=\"10\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
echo " <TR><TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . "mailscannerlogo.gif\" ALT=\"MailScanner Logo\"></TD></TR>";
Beispiel #9
0
 private function _renderPlotBar($groupID, $dimensions = '2d')
 {
     $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
     //	Rotate for bar rather than column chart
     if ($groupID == 0 && $rotation == 'bar') {
         $this->_graph->Set90AndMargin();
     }
     $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
     $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
     if ($labelCount > 0) {
         $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
         $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation);
         //	Rotate for bar rather than column chart
         if ($rotation == 'bar') {
             $datasetLabels = array_reverse($datasetLabels);
             $this->_graph->yaxis->SetPos('max');
             $this->_graph->yaxis->SetLabelAlign('center', 'top');
             $this->_graph->yaxis->SetLabelSide(SIDE_RIGHT);
         }
         $this->_graph->xaxis->SetTickLabels($datasetLabels);
     }
     $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
     $seriesPlots = array();
     if ($grouping == 'percentStacked') {
         $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
     }
     //	Loop through each data series in turn
     for ($j = 0; $j < $seriesCount; ++$j) {
         $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
         if ($grouping == 'percentStacked') {
             $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
         }
         //	Fill in any missing values in the $dataValues array
         $testCurrentIndex = 0;
         foreach ($dataValues as $k => $dataValue) {
             while ($k != $testCurrentIndex) {
                 $dataValues[$testCurrentIndex] = null;
                 ++$testCurrentIndex;
             }
             ++$testCurrentIndex;
         }
         //	Reverse the $dataValues order for bar rather than column chart
         if ($rotation == 'bar') {
             $dataValues = array_reverse($dataValues);
         }
         $seriesPlot = new BarPlot($dataValues);
         $seriesPlot->SetColor('black');
         $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
         if ($dimensions == '3d') {
             $seriesPlot->SetShadow();
         }
         if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) {
             $dataLabel = '';
         } else {
             $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue();
         }
         $seriesPlot->SetLegend($dataLabel);
         $seriesPlots[] = $seriesPlot;
     }
     //	Reverse the plot order for bar rather than column chart
     if ($rotation == 'bar' && !($grouping == 'percentStacked')) {
         $seriesPlots = array_reverse($seriesPlots);
     }
     if ($grouping == 'clustered') {
         $groupPlot = new GroupBarPlot($seriesPlots);
     } elseif ($grouping == 'standard') {
         $groupPlot = new GroupBarPlot($seriesPlots);
     } else {
         $groupPlot = new AccBarPlot($seriesPlots);
         if ($dimensions == '3d') {
             $groupPlot->SetShadow();
         }
     }
     $this->_graph->Add($groupPlot);
 }
 function getBarPlot($data, $color)
 {
     $b = new BarPlot($data);
     //parameters hard coded for the moment
     $b->SetAbsWidth(10);
     $b->value->Show(true);
     $b->value->SetColor($this->graph->getMainColor());
     $b->value->SetFormat("%d");
     $b->value->HideZero();
     $b->value->SetMargin(4);
     $b->value->SetFont($this->graph->getFont(), FS_NORMAL, 7);
     $b->SetWidth(0.4);
     $b->SetColor($color . ':0.7');
     $b->SetFillColor($color);
     // end hard coded parameter
     return $b;
 }
Beispiel #11
0
$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
// end exactly at the max value.
$graph->yaxis->scale->SetGrace(50);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('darkblue');
$bplot->SetColor('darkblue');
$bplot->SetWidth(0.5);
$bplot->SetShadow('darkgray');
// Setup the values that are displayed on top of each bar
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
$bplot->value->SetFormat('$%d');
$bplot->value->SetColor('darkred');
$bplot->value->SetAngle(45);
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
$color = "navy";
$color2 = "navy";
//$color2 = "lightsteelblue";
// Setup graph
$graph = new Graph($width, 250, "auto");
$graph->SetScale("textlin");
$graph->SetMarginColor($background);
$graph->img->SetMargin(40, 30, 20, 40);
//$graph->SetShadow();
//Setup Frame
$graph->SetFrame(true, "#ffffff");
// Setup graph title
$graph->title->Set($title);
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
//$bplot->SetFillGradient($color, $color2, GRAD_MIDVER);
//$bplot->SetColor($color);
// color@transparencia
$bplot->SetFillColor(array(COLOR1 . "@0.5"));
//
$bplot->SetShadow(array(COLOR1 . "@0.7"), 5, 5);
$bplot->SetColor(array(COLOR1 . "@1"));
//
$graph->Add($bplot);
$graph->xaxis->SetTickLabels($labelx);
//$graph->xaxis->SetLabelAngle(40); // only with TTF fonts
$graph->title->Set($title);
$graph->xaxis->title->Set($titley);
$graph->yaxis->title->Set($titlex);
$graph->Stroke();
Beispiel #13
0
$graph->xaxis->SetTickLabels($BPK);
$graph->xaxis->SetFont(FF_FONT1);
$graph->xaxis->SetColor('darkblue', 'black');
//$graph->yaxis->SetLabelFormatCallback('formatNumber_money');
// Setup "hidden" y-axis by given it the same color
// as the background
$graph->yaxis->SetColor('black', 'black');
$graph->ygrid->SetColor('white');
// Setup graph title ands fonts
$graph->title->Set(gettext("GRAFIK"));
$graph->title->SetFont(FF_FONT1, FS_BOLD, 16);
//$graph->subtitle->Set('(With "hidden" y-axis)');
// Create a bar pot
$bplot = new BarPlot($totals);
$bplot->SetFillColor('darkblue');
$bplot->SetColor('black');
$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_FONT1, FS_NORMAL, 8);
//$bplot->value->SetFormatCallback('formatNumber');
// $bplot->value->SetFormat($aLocaleInfo["currency_symbol"] . ' %d');
// $bplot->value->SetFormat('%01.0f');
// Dark blue for positive values and darkred for negative values
$bplot->value->SetColor("darkblue", "darkred");
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
?>
Beispiel #14
0
function print_graph($g, $pgwidth)
{
    $splines = false;
    $bandw = false;
    $percent = false;
    $show_percent = false;
    $stacked = false;
    $h = false;
    $show_values = false;
    $hide_grid = false;
    $hide_y_axis = false;
    if (isset($g['attr']['TYPE']) && $g['attr']['TYPE']) {
        $type = strtolower($g['attr']['TYPE']);
    }
    if (!in_array($type, array('bar', 'horiz_bar', 'line', 'radar', 'pie', 'pie3d', 'xy', 'scatter'))) {
        $type = 'bar';
    }
    // Default=bar
    if (isset($g['attr']['STACKED']) && $g['attr']['STACKED']) {
        $stacked = true;
    }
    // stacked for bar or horiz_bar
    if (isset($g['attr']['SPLINES']) && $g['attr']['SPLINES'] && $type == 'xy') {
        $splines = true;
    }
    // splines for XY line graphs
    if (isset($g['attr']['BANDW']) && $g['attr']['BANDW']) {
        $bandw = true;
    }
    // black and white
    if (isset($g['attr']['LEGEND-OVERLAP']) && $g['attr']['LEGEND-OVERLAP']) {
        $overlap = true;
    }
    // avoid overlap of Legends over graph (line, bar, horiz_bar only)
    if (isset($g['attr']['PERCENT']) && $g['attr']['PERCENT'] && $type != 'xy' && $type != 'scatter') {
        $percent = true;
    }
    // Show data series as percent of total in series
    if (isset($g['attr']['SHOW-VALUES']) && $g['attr']['SHOW-VALUES']) {
        $show_values = true;
    }
    // Show the individual data values
    if (isset($g['attr']['HIDE-GRID']) && $g['attr']['HIDE-GRID']) {
        $hide_grid = true;
    }
    // Hide the y-axis gridlines
    if (isset($g['attr']['HIDE-Y-AXIS']) && $g['attr']['HIDE-Y-AXIS']) {
        $hide_y_axis = true;
    }
    // Hide the y-axis
    // Antialias: If true - better quality curves, but graph line will only be 1px even in PDF 300dpi
    // default=true for most except line and radar
    if (isset($g['attr']['ANTIALIAS']) && ($g['attr']['ANTIALIAS'] == '' || $g['attr']['ANTIALIAS'] == 0)) {
        $antialias = false;
    } else {
        if (isset($g['attr']['ANTIALIAS']) && $g['attr']['ANTIALIAS'] > 0) {
            $antialias = true;
        } else {
            if ($type == 'line' || $type == 'radar') {
                $antialias = false;
            } else {
                $antialias = true;
            }
        }
    }
    if ($g['attr']['DPI']) {
        $dpi = intval($g['attr']['DPI']);
    }
    if (!$dpi || $dpi < 50 || $dpi > 2400) {
        $dpi = 150;
    }
    // Default dpi 150
    $k = 0.2645 / 25.4 * $dpi;
    // mPDF 4.5.009
    global $JpgUseSVGFormat;
    if (isset($JpgUseSVGFormat) && $JpgUseSVGFormat) {
        $img_type = 'svg';
        $k = 1;
        // Overrides as Vector scale does not need DPI
    } else {
        $img_type = 'png';
    }
    if (isset($g['attr']['TITLE']) && $g['attr']['TITLE']) {
        $title = $g['attr']['TITLE'];
    }
    if (isset($g['attr']['LABEL-X']) && $g['attr']['LABEL-X']) {
        $xlabel = $g['attr']['LABEL-X'];
    }
    // NOT IMPLEMENTED??????
    if (isset($g['attr']['LABEL-Y']) && $g['attr']['LABEL-Y']) {
        $ylabel = $g['attr']['LABEL-Y'];
    }
    if (isset($g['attr']['AXIS-X']) && $g['attr']['AXIS-X']) {
        $xaxis = strtolower($g['attr']['AXIS-X']);
    }
    if (!in_array($xaxis, array('text', 'lin', 'linear', 'log'))) {
        $xaxis = 'text';
    }
    // Default=text
    if ($xaxis == 'linear') {
        $xaxis = 'lin';
    }
    if (isset($g['attr']['AXIS-Y']) && $g['attr']['AXIS-Y']) {
        $yaxis = strtolower($g['attr']['AXIS-Y']);
    }
    if (!in_array($yaxis, array('lin', 'linear', 'log', 'percent'))) {
        $yaxis = 'lin';
    }
    // Default=lin
    if ($yaxis == 'percent') {
        $show_percent = true;
        $yaxis = 'lin';
    }
    // Show percent sign on scales
    if ($yaxis == 'linear') {
        $yaxis = 'lin';
    }
    if ($splines) {
        $xaxis = 'lin';
    }
    $axes = $xaxis . $yaxis;
    // e.g.textlin, textlog, loglog, loglin, linlog (XY)
    // mPDF 4.0
    if (isset($g['attr']['cWIDTH']) && $g['attr']['cWIDTH']) {
        $w = $g['attr']['cWIDTH'] / 0.2645;
    }
    // pixels
    if (isset($g['attr']['cHEIGHT']) && $g['attr']['cHEIGHT']) {
        $h = $g['attr']['cHEIGHT'] / 0.2645;
    }
    if (isset($g['attr']['SERIES']) && strtolower($g['attr']['SERIES']) == 'rows') {
        $dataseries = 'rows';
    } else {
        $dataseries = 'cols';
    }
    // Defaults - define data
    $rowbegin = 2;
    $colbegin = 2;
    if ($type == 'scatter' || $type == 'xy') {
        if ($dataseries == 'rows') {
            $rowbegin = 1;
        } else {
            $colbegin = 1;
        }
    }
    $rowend = 0;
    $colend = 0;
    if (isset($g['attr']['DATA-ROW-BEGIN']) && ($g['attr']['DATA-ROW-BEGIN'] === '0' || $g['attr']['DATA-ROW-BEGIN'] > 0)) {
        $rowbegin = $g['attr']['DATA-ROW-BEGIN'];
    }
    if (isset($g['attr']['DATA-COL-BEGIN']) && ($g['attr']['DATA-COL-BEGIN'] === '0' || $g['attr']['DATA-COL-BEGIN'] > 0)) {
        $colbegin = $g['attr']['DATA-COL-BEGIN'];
    }
    if (isset($g['attr']['DATA-ROW-END']) && ($g['attr']['DATA-ROW-END'] === '0' || $g['attr']['DATA-ROW-END'] != 0)) {
        $rowend = $g['attr']['DATA-ROW-END'];
    }
    if (isset($g['attr']['DATA-COL-END']) && ($g['attr']['DATA-COL-END'] === '0' || $g['attr']['DATA-COL-END'] != 0)) {
        $colend = $g['attr']['DATA-COL-END'];
    }
    $nr = count($g['data']);
    $nc = 0;
    foreach ($g['data'] as $r) {
        $cc = 0;
        foreach ($r as $c) {
            $cc++;
        }
        $nc = max($nc, $cc);
    }
    if ($colend == 0) {
        $colend = $nc;
    } else {
        if ($colend < 0) {
            $colend = $nc + $colend;
        }
    }
    if ($rowend == 0) {
        $rowend = $nr;
    } else {
        if ($rowend < 0) {
            $rowend = $nr + $rowend;
        }
    }
    if ($colend < $colbegin) {
        $colend = $colbegin;
    }
    if ($rowend < $rowbegin) {
        $rowend = $rowbegin;
    }
    //	if ($type == 'xy' || $type=='scatter') { $colstart=0; }
    // Get Data + Totals
    $data = array();
    $totals = array();
    for ($r = $rowbegin - 1; $r < $rowend; $r++) {
        for ($c = $colbegin - 1; $c < $colend; $c++) {
            if (isset($g['data'][$r][$c])) {
                $g['data'][$r][$c] = floatval($g['data'][$r][$c]);
            } else {
                $g['data'][$r][$c] = 0;
            }
            if ($dataseries == 'rows') {
                $data[$r + 1 - $rowbegin][$c + 1 - $colbegin] = $g['data'][$r][$c];
                $totals[$r + 1 - $rowbegin] += $g['data'][$r][$c];
            } else {
                $data[$c + 1 - $colbegin][$r + 1 - $rowbegin] = $g['data'][$r][$c];
                if (isset($totals[$c + 1 - $colbegin])) {
                    $totals[$c + 1 - $colbegin] += $g['data'][$r][$c];
                } else {
                    $totals[$c + 1 - $colbegin] = $g['data'][$r][$c];
                }
            }
        }
    }
    // PERCENT
    if ($percent && $type != 'pie' && $type != 'pie3d') {
        for ($r = 0; $r < count($data); $r++) {
            for ($c = 0; $c < count($data[$r]); $c++) {
                $data[$r][$c] = $data[$r][$c] / $totals[$r] * 100;
            }
        }
    }
    // Get Legends and labels
    $legends = array();
    $labels = array();
    $longestlegend = 0;
    $longestlabel = 0;
    if ($dataseries == 'cols') {
        if ($colbegin > 1) {
            for ($r = $rowbegin - 1; $r < $rowend; $r++) {
                $legends[$r + 1 - $rowbegin] = $g['data'][$r][0];
                $longestlegend = max($longestlegend, strlen($g['data'][$r][0]));
            }
        }
        if ($rowbegin > 1) {
            for ($c = $colbegin - 1; $c < $colend; $c++) {
                $labels[$c + 1 - $colbegin] = $g['data'][0][$c];
                $longestlabel = max($longestlabel, strlen($g['data'][0][$c]));
            }
        }
    } else {
        if ($dataseries == 'rows') {
            if ($colbegin > 1) {
                for ($r = $rowbegin - 1; $r < $rowend; $r++) {
                    $labels[$r + 1 - $rowbegin] = $g['data'][$r][0];
                    $longestlabel = max($longestlabel, strlen($g['data'][$r][0]));
                }
            }
            if ($rowbegin > 1) {
                for ($c = $colbegin - 1; $c < $colend; $c++) {
                    $legends[$c + 1 - $colbegin] = $g['data'][0][$c];
                    $longestlegend = max($longestlegend, strlen($g['data'][0][$c]));
                }
            }
        }
    }
    // Default sizes
    $defsize = array();
    $defsize['pie'] = array('w' => 600, 'h' => 300);
    $defsize['pie3d'] = array('w' => 600, 'h' => 300);
    $defsize['radar'] = array('w' => 600, 'h' => 300);
    $defsize['line'] = array('w' => 600, 'h' => 400);
    $defsize['xy'] = array('w' => 600, 'h' => 400);
    $defsize['scatter'] = array('w' => 600, 'h' => 400);
    $defsize['bar'] = array('w' => 600, 'h' => 400);
    $defsize['horiz_bar'] = array('w' => 600, 'h' => 500);
    // Use default ratios
    if ($w && !$h) {
        $h = $w * $defsize[$type]['h'] / $defsize[$type]['w'];
    }
    if ($h && !$w) {
        $w = $h * $defsize[$type]['w'] / $defsize[$type]['h'];
    }
    if (!$h && !$w) {
        $w = $defsize[$type]['w'];
        $h = $defsize[$type]['h'];
    }
    if (count($data) > 0 && $type) {
        $figure_file = "graph_cache/" . rand(11111, 999999999) . "." . $img_type;
        if ($bandw) {
            $colours = array('snow1', 'black', 'snow4', 'snow3', 'snow2', 'cadetblue4', 'cadetblue3', 'cadetblue1', 'bisque4', 'bisque2', 'beige');
        } else {
            $colours = array('cyan', 'darkorchid4', 'cadetblue3', 'khaki1', 'darkolivegreen2', 'cadetblue4', 'coral', 'cyan4', 'rosybrown3', 'wheat1');
        }
        $fills = array('navy', 'orange', 'red', 'yellow', 'purple', 'navy', 'orange', 'red', 'yellow', 'purple');
        $patterns = array(PATTERN_DIAG1, PATTERN_CROSS1, PATTERN_STRIPE1, PATTERN_DIAG3, PATTERN_CROSS2, PATTERN_DIAG2, PATTERN_DIAG4, PATTERN_CROSS3, PATTERN_CROSS4, PATTERN_STRIPE1);
        $markers = array(MARK_DIAMOND, MARK_SQUARE, MARK_CIRCLE, MARK_UTRIANGLE, MARK_DTRIANGLE, MARK_FILLEDCIRCLE, MARK_CROSS, MARK_STAR, MARK_X);
        // LEGENDS
        if ($type == 'pie' || $type == 'pie3d') {
            $graph = new PieGraph($w * $k, $h * $k);
        } else {
            if ($type == 'radar') {
                $graph = new RadarGraph($w * $k, $h * $k);
            } else {
                $graph = new Graph($w * $k, $h * $k);
            }
        }
        // mPDF 4.5.009
        //	$graph->img->SetImgFormat($img_type) ;
        //	if (strtoupper($img_type)=='JPEG') { $graph->img->SetQuality(90); }
        if ($antialias) {
            $graph->img->SetAntiAliasing();
        }
        $graph->SetShadow(true, 2 * $k);
        $graph->SetMarginColor("white");
        // TITLE
        $graph->title->Set($title);
        $graph->title->SetMargin(10 * $k);
        $graph->title->SetFont(FF_USERFONT, FS_BOLD, 11 * $k);
        $graph->title->SetColor("black");
        $graph->legend->SetLineSpacing(3 * $k);
        $graph->legend->SetMarkAbsSize(6 * $k);
        $graph->legend->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
        // Set GRAPH IMAGE MARGINS
        if ($type == 'pie' || $type == 'pie3d') {
            $psize = 0.3;
            $pposxabs = $w / 2;
            $pposy = 0.55;
            if ($longestlegend) {
                // if legend showing
                $pposxabs -= ($longestlegend * 5 + 20) / 2;
            }
            $pposx = $pposxabs / $w;
            $graph->legend->Pos(0.02, 0.5, 'right', 'center');
        } else {
            if ($type == 'radar') {
                $psize = 0.5;
                $pposxabs = $w / 2;
                $pposy = 0.55;
                if ($longestlabel) {
                    // if legend showing
                    $pposxabs -= ($longestlabel * 5 + 20) / 2;
                }
                $pposx = $pposxabs / $w;
                $graph->legend->Pos(0.02, 0.5, 'right', 'center');
            } else {
                if ($type == 'xy' || $type == 'scatter') {
                    $pml = 50;
                    $pmr = 20;
                    $pmt = 60;
                    $pmb = 50;
                    $xaxislblmargin = $pmb - 30;
                    $yaxislblmargin = $pml - 15;
                    $graph->legend->Pos(0.02, 0.1, 'right', 'top');
                } else {
                    if ($type == 'line' || $type == 'bar') {
                        $pml = 50;
                        $pmr = 20;
                        $pmt = 60;
                        $pmb = 50;
                        $xlangle = 0;
                        $ll = $longestlegend * 5;
                        // 45 degrees 8pt fontsize
                        if ($ll > 5 || $ll > 3 && count($data) > 10) {
                            $pmb = max($pmb, $ll + 30);
                            $xlangle = 50;
                        }
                        $xaxislblmargin = $pmb - 30;
                        $yaxislblmargin = $pml - 15;
                        if ($longestlabel && !$overlap) {
                            // if legend showing
                            $pmr = $longestlabel * 5 + 40;
                        }
                        $graph->legend->Pos(0.02, 0.1, 'right', 'top');
                    } else {
                        if ($type == 'horiz_bar') {
                            $pml = 50;
                            $pmr = 20;
                            $pmt = 50;
                            $pmb = 45;
                            $ll = $longestlegend * 6.5;
                            // 8pt fontsize
                            $pml = max($pml, $ll + 20);
                            $xaxislblmargin = $pml - 20;
                            $yaxislblmargin = $pmb - 15;
                            if ($longestlabel && !$overlap) {
                                // if legend showing
                                $pmr = $longestlabel * 5 + 40;
                            }
                            $graph->legend->Pos(0.02, 0.1, 'right', 'top');
                        }
                    }
                }
            }
        }
        // DRAW THE GRAPHS
        if ($type == 'pie') {
            $p1 = new PiePlot($data[0]);
            $p1->SetSliceColors($colours);
            if ($show_values) {
                $p1->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                if ($percent) {
                    $p1->SetLabelType(PIE_VALUE_PERADJ);
                } else {
                    $p1->SetLabelType(PIE_VALUE_ABS);
                }
                if ($percent || $show_percent) {
                    $p1->value->SetFormat("%d%%");
                } else {
                    $p1->value->SetFormat("%s");
                }
                // Enable and set policy for guide-lines. Make labels line up vertically
                $p1->SetGuideLines(true);
                $p1->SetGuideLinesAdjust(1.5);
            } else {
                $p1->value->Show(false);
            }
            $p1->SetLegends($legends);
            $p1->SetSize($psize);
            $p1->SetCenter($pposx, $pposy);
            if ($labels[0]) {
                $graph->subtitle->Set($labels[0]);
                $graph->subtitle->SetMargin(10 * $k);
                $graph->subtitle->SetFont(FF_USERFONT, FS_BOLD, 11 * $k);
                $graph->subtitle->SetColor("black");
            }
            $graph->Add($p1);
        } else {
            if ($type == 'pie3d') {
                $p1 = new PiePlot3d($data[0]);
                $p1->SetSliceColors($colours);
                if ($show_values) {
                    $p1->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                    if ($percent) {
                        $p1->SetLabelType(PIE_VALUE_PERADJ);
                    } else {
                        $p1->SetLabelType(PIE_VALUE_ABS);
                    }
                    if ($percent || $show_percent) {
                        $p1->value->SetFormat("%d%%");
                    } else {
                        $p1->value->SetFormat("%s");
                    }
                } else {
                    $p1->value->Show(false);
                }
                $p1->SetLegends($legends);
                $p1->SetEdge();
                $p1->SetSize($psize);
                $p1->SetCenter($pposx, $pposy);
                if ($labels[0]) {
                    $graph->subtitle->Set($labels[0]);
                    $graph->subtitle->SetMargin(10 * $k);
                    $graph->subtitle->SetFont(FF_USERFONT, FS_BOLD, 11 * $k);
                    $graph->subtitle->SetColor("black");
                }
                $graph->Add($p1);
            } else {
                if ($type == 'radar') {
                    $graph->SetSize($psize);
                    $graph->SetPos($pposx, $pposy);
                    $graph->SetTitles($legends);
                    // labels each axis
                    $graph->axis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                    $graph->axis->title->SetMargin(5 * $k);
                    $graph->axis->SetWeight(1 * $k);
                    $graph->axis->HideLabels();
                    $graph->axis->SetFont(FF_USERFONT, FS_NORMAL, 6 * $k);
                    $graph->HideTickMarks();
                    $group = array();
                    foreach ($data as $series => $dat) {
                        $rdata = array();
                        foreach ($data[$series] as $row) {
                            $rdata[] = $row;
                        }
                        if (count($rdata) < 3) {
                            die("ERROR::Graph::Cannot create a Radar Plot with less than 3 data points.");
                        }
                        // Create the radar plot
                        $bplot = new RadarPlot($rdata);
                        $bplot->mark->SetType($markers[$series]);
                        $bplot->mark->SetFillColor($colours[$series]);
                        $bplot->mark->SetWidth(3 * $k);
                        $bplot->SetColor($colours[$series]);
                        if ($series == 0) {
                            $bplot->SetFillColor('lightred');
                        } else {
                            $bplot->SetFill(false);
                        }
                        $bplot->SetLineWeight(1 * $k);
                        $bplot->SetLegend($labels[$series]);
                        if ($bandw) {
                            $bplot->SetShadow("gray5");
                        }
                        $graph->Add($bplot);
                    }
                } else {
                    if ($type == 'line') {
                        // Setup the graph.
                        $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                        // LRTB
                        $graph->SetScale($axes);
                        $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                        if ($ylabel) {
                            $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            $graph->yaxis->SetTitle($ylabel, 'middle');
                            $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                        }
                        $graph->yaxis->SetLabelMargin(4 * $k);
                        if ($percent || $show_percent) {
                            $graph->yaxis->SetLabelFormat('%d%%');
                        }
                        // Percent
                        // Show 0 label on Y-axis (default is not to show)
                        $graph->yscale->ticks->SupressZeroLabel(true);
                        if ($hide_y_axis) {
                            $graph->yaxis->Hide();
                        }
                        if ($hide_grid) {
                            $graph->ygrid->Show(false);
                        }
                        // Setup X-axis labels
                        $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                        $graph->xaxis->SetTickLabels($legends);
                        $graph->xaxis->SetLabelAngle($xlangle);
                        $graph->xaxis->SetLabelMargin(4 * $k);
                        // X-axis title
                        if ($xlabel) {
                            $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            $graph->xaxis->SetTitle($xlabel, 'middle');
                            $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                        }
                        foreach ($data as $series => $rdata) {
                            $bplot = new LinePlot($rdata);
                            $bplot->mark->SetType($markers[$series]);
                            $bplot->mark->SetFillColor($colours[$series]);
                            $bplot->mark->SetWidth(4 * $k);
                            if ($show_values) {
                                $bplot->value->Show();
                                // Not if scatter
                                $bplot->value->SetMargin(6 * $k);
                                $bplot->value->SetColor("darkred");
                                $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                if ($percent || $show_percent) {
                                    $bplot->value->SetFormat('%d%%');
                                } else {
                                    $bplot->value->SetFormat("%s");
                                }
                            }
                            // Set color for each line
                            $bplot->SetColor($colours[$series]);
                            $bplot->SetWeight(2 * $k);
                            $bplot->SetLegend($labels[$series]);
                            if ($bandw) {
                                $bplot->SetShadow("gray5");
                            }
                            // Indent the X-scale so the first and last point doesn't fall on the edges
                            $bplot->SetCenter();
                            $graph->Add($bplot);
                        }
                    } else {
                        if ($type == 'xy' || $type == 'scatter') {
                            // Setup the graph.
                            $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                            // LRTB
                            $graph->SetScale($axes);
                            // Setup font for axis
                            $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            // Y-axis title
                            if ($labels[1]) {
                                $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                                $graph->yaxis->SetTitle($labels[1], 'middle');
                            }
                            $graph->yaxis->SetLabelMargin(4 * $k);
                            if ($percent || $show_percent) {
                                $graph->yaxis->SetLabelFormat('%d%%');
                            }
                            // Percent
                            // Show 0 label on Y-axis (default is not to show)
                            $graph->yscale->ticks->SupressZeroLabel(true);
                            // Just let the maximum be autoscaled
                            $graph->yaxis->scale->SetAutoMin(0);
                            if ($hide_y_axis) {
                                $graph->yaxis->Hide();
                            }
                            if ($hide_grid) {
                                $graph->ygrid->Show(false);
                            }
                            // Setup X-axis labels
                            $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                            // mPDF 2.5 Corrects labelling of x-axis
                            //			$graph->xaxis->SetTickLabels($legends);
                            $graph->xaxis->SetLabelAngle(50);
                            $graph->xaxis->SetLabelMargin(4 * $k);
                            // X-axis title
                            if ($labels[0]) {
                                $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                                $graph->xaxis->SetTitle($labels[0], 'middle');
                            }
                            // Create the bar plot
                            // SPLINES
                            if ($splines && $type == 'xy') {
                                $spline = new Spline($data[0], $data[1]);
                                list($newx, $newy) = $spline->Get(100);
                            } else {
                                $newx = $data[0];
                                $newy = $data[1];
                            }
                            if ($type == 'xy') {
                                // LINE PLOT
                                $bplot = new LinePlot($newy, $newx);
                                // Set color for each line
                                $bplot->SetColor($fills[0]);
                                $bplot->SetWeight(4 * $k);
                                if ($bandw) {
                                    $bplot->SetShadow("gray5");
                                }
                                $graph->Add($bplot);
                            }
                            // SCATTER PLOT
                            $cplot = new ScatterPlot($data[1], $data[0]);
                            $cplot->mark->SetType($markers[0]);
                            $cplot->mark->SetFillColor($fills[0]);
                            $cplot->mark->SetWidth(8 * $k);
                            if ($show_values) {
                                // mPDF 2.5
                                if ($type == 'xy') {
                                    $cplot->value->Show();
                                }
                                // Not if scatter
                                $cplot->value->SetMargin(8 * $k);
                                $cplot->value->SetColor("darkred");
                                $cplot->value->SetFont(FF_USERFONT, FS_NORMAL, 6 * $k);
                                if ($percent || $show_percent) {
                                    $cplot->value->SetFormat('%d%%');
                                } else {
                                    $cplot->value->SetFormat("%s");
                                }
                            }
                            // Set color for each line
                            $cplot->SetColor($fills[0]);
                            $cplot->SetWeight(4 * $k);
                            if ($bandw) {
                                $cplot->SetShadow("gray5");
                            }
                            $graph->Add($cplot);
                        } else {
                            if ($type == 'bar') {
                                // Setup the graph.
                                $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                                // LRTB
                                $graph->SetScale($axes);
                                // Setup y-axis
                                $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                if ($hide_y_axis) {
                                    $graph->yaxis->Hide();
                                }
                                if ($hide_grid) {
                                    $graph->ygrid->Show(false);
                                }
                                $graph->yaxis->SetLabelMargin(4 * $k);
                                if ($ylabel) {
                                    $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->yaxis->SetTitle($ylabel, 'middle');
                                    $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                                }
                                // Show 0 label on Y-axis (default is not to show)
                                $graph->yscale->ticks->SupressZeroLabel(false);
                                // Setup X-axis labels
                                $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                $graph->xaxis->SetTickLabels($legends);
                                $graph->xaxis->SetLabelAngle($xlangle);
                                $graph->xaxis->SetLabelMargin(4 * $k);
                                // X-axis title
                                if ($xlabel) {
                                    $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->xaxis->SetTitle($xlabel, 'middle');
                                    $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                                }
                                $group = array();
                                foreach ($data as $series => $dat) {
                                    $rdata = array();
                                    foreach ($data[$series] as $row) {
                                        $rdata[] = $row;
                                    }
                                    // Create the bar plot
                                    $bplot = new BarPlot($rdata);
                                    $bplot->SetWidth(0.6);
                                    // for SINGLE??
                                    // Setup color for gradient fill style
                                    if ($bandw) {
                                        $bplot->SetPattern($patterns[$series]);
                                    } else {
                                        $bplot->SetFillGradient($fills[$series], "#EEEEEE", GRAD_LEFT_REFLECTION);
                                    }
                                    // Set color for the frame of each bar
                                    $bplot->SetColor("darkgray");
                                    $bplot->SetLegend($labels[$series]);
                                    if ($bandw) {
                                        $bplot->SetShadow("gray5");
                                    }
                                    if ($show_values) {
                                        $bplot->value->Show();
                                        $bplot->value->SetMargin(6 * $k);
                                        $bplot->value->SetColor("darkred");
                                        $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                        if ($percent || $show_percent) {
                                            $bplot->value->SetFormat('%d%%');
                                        } else {
                                            $bplot->value->SetFormat("%s");
                                        }
                                    }
                                    $group[] = $bplot;
                                }
                                if (count($data) == 1) {
                                    $graph->Add($group[0]);
                                } else {
                                    // Create the grouped bar plot
                                    if ($stacked) {
                                        $gbplot = new AccBarPlot($group);
                                    } else {
                                        $gbplot = new GroupBarPlot($group);
                                    }
                                    $graph->Add($gbplot);
                                }
                            } else {
                                if ($type == 'horiz_bar') {
                                    $graph->SetScale($axes);
                                    $graph->Set90AndMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k);
                                    // LRTB
                                    // Setup y-axis
                                    $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->yaxis->SetLabelMargin(4 * $k);
                                    $graph->yaxis->SetPos('max');
                                    // Intersect at top of x-axis i.e. y axis is at bottom
                                    // First make the labels look right
                                    $graph->yaxis->SetLabelAlign('center', 'top');
                                    if ($percent || $show_percent) {
                                        $graph->yaxis->SetLabelFormat('%d%%');
                                    }
                                    $graph->yaxis->SetLabelSide(SIDE_RIGHT);
                                    $graph->yaxis->scale->SetGrace(10);
                                    // sets 10% headroom
                                    if ($hide_y_axis) {
                                        $graph->yaxis->Hide();
                                    }
                                    if ($hide_grid) {
                                        $graph->ygrid->Show(false);
                                    }
                                    // The fix the tick marks
                                    $graph->yaxis->SetTickSide(SIDE_LEFT);
                                    if ($ylabel) {
                                        $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                        $graph->yaxis->SetTitle($ylabel, 'middle');
                                        $graph->yaxis->SetTitleMargin($yaxislblmargin * $k);
                                        // Finally setup the title
                                        $graph->yaxis->SetTitleSide(SIDE_RIGHT);
                                        // To align the title to the right use :
                                        $graph->yaxis->title->Align('right');
                                        $graph->yaxis->title->SetAngle(0);
                                    }
                                    // Show 0 label on Y-axis (default is not to show)
                                    $graph->yscale->ticks->SupressZeroLabel(false);
                                    // Setup X-axis labels
                                    $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                    $graph->xaxis->title->SetAngle(90);
                                    $graph->xaxis->SetTickLabels($legends);
                                    $graph->xaxis->SetLabelMargin(4 * $k);
                                    // X-axis title
                                    if ($xlabel) {
                                        $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                        $graph->xaxis->SetTitleMargin($xaxislblmargin * $k);
                                        $graph->xaxis->SetTitle($xlabel, 'middle');
                                    }
                                    $group = array();
                                    foreach ($data as $series => $dat) {
                                        $rdata = array();
                                        foreach ($data[$series] as $row) {
                                            $rdata[] = $row;
                                        }
                                        // Create the bar pot
                                        $bplot = new BarPlot($rdata);
                                        $bplot->SetWidth(0.6);
                                        // for SINGLE??
                                        // Setup color for gradient fill style
                                        if ($bandw) {
                                            $bplot->SetPattern($patterns[$series]);
                                        } else {
                                            $bplot->SetFillGradient($fills[$series], "#EEEEEE", GRAD_LEFT_REFLECTION);
                                        }
                                        // Set color for the frame of each bar
                                        $bplot->SetColor("darkgray");
                                        $bplot->SetLegend($labels[$series]);
                                        if ($bandw) {
                                            $bplot->SetShadow("gray5");
                                        }
                                        if ($show_values) {
                                            $bplot->value->Show();
                                            $bplot->value->SetMargin(6 * $k);
                                            $bplot->value->SetColor("darkred");
                                            $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k);
                                            if ($percent || $show_percent) {
                                                $bplot->value->SetFormat('%d%%');
                                            } else {
                                                $bplot->value->SetFormat("%s");
                                            }
                                        }
                                        $group[] = $bplot;
                                    }
                                    if (count($data) == 1) {
                                        $graph->Add($group[0]);
                                    } else {
                                        // Create the grouped bar plot
                                        if ($stacked) {
                                            $gbplot = new AccBarPlot($group);
                                        } else {
                                            $gbplot = new GroupBarPlot($group);
                                        }
                                        $graph->Add($gbplot);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($graph) {
            $graph->Stroke(_MPDF_PATH . $figure_file);
            $srcpath = str_replace("\\", "/", dirname(__FILE__)) . "/";
            $srcpath .= $figure_file;
            return array('file' => $srcpath, 'w' => $w, 'h' => $h);
        }
    }
    return false;
}
Beispiel #15
0
$bplot->SetColor('#94D239');
$bplot->value->Show();
$bplot->value->SetFormat('%d');
$bplot->SetLegend("ANSWERED");
$bplot1->SetFillColor('#376BF6');
$bplot1->SetColor('#376BF6');
$bplot1->value->Show();
$bplot1->value->SetFormat('%d');
$bplot1->SetLegend("BUSY");
/*$bplot2->SetFillColor('#C40505');
$bplot2->SetColor('#C40505');
$bplot2->value->Show();
$bplot2->value->SetFormat('%d');
$bplot2->SetLegend("UNSUCCESSFULL");*/
$bplot3->SetFillColor('#A7A7A7');
$bplot3->SetColor('#A7A7A7');
$bplot3->value->Show();
$bplot3->value->SetFormat('%d');
$bplot3->SetLegend("NOANSWER");
// Setup the titles
$graph->title->Set("Total monthly calls breakdown by status");
$graph->xaxis->title->Set("Month");
$graph->yaxis->title->Set("Calls");
$graph->yaxis->SetLabelAlign('center', 'top');
$graph->legend->SetColumns(4);
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetPos(0.5, 0.14, 'center', 'bottom');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
// Display the graph
Beispiel #16
0
<?php

// content="text/plain; charset=utf-8"
require_once '../jpgraph.php';
require_once '../jpgraph_bar.php';
$datay1 = array(13, 8, 19, 7, 17, 6);
$datay2 = array(4, 5, 2, 7, 5, 25);
// Create the graph.
$graph = new Graph(350, 250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Setup title
$graph->title->Set('Acc bar with gradient');
// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2', 'AntiqueWhite4:0.8', GRAD_VERT);
$bplot->SetColor('darkred');
// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT);
$bplot2->SetColor('darkgreen');
// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot, $bplot2));
$graph->Add($accbplot);
$graph->Stroke();
Beispiel #17
0
// Conecto a la base de datos
include 'conexion_bd.php';
$consulta = "SELECT combustible FROM viaje";
$resultado = mysql_query($consulta);
mysql_close($conexion);
while ($row = mysql_fetch_array($resultado)) {
    //Definiendo datos de la tercera línea
    $promedio[] = $row['combustible'];
    $datay1[] = array_sum($promedio) / count($promedio);
}
//crear la instancia del objeto graph
$ancho = 640;
$alto = 320;
$graph = new Graph($ancho, $alto);
//especificar la escala
$graph->SetScale("textlin");
// Create the bar plots
$b1plot = new BarPlot($datay1);
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$b1plot->value->Show();
$b1plot->SetColor("white");
$b1plot->SetFillColor("#1111cc");
$b1plot->SetColor("#6495ED");
$b1plot->SetLegend('Promedio');
$graph->img->SetMargin(60, 80, 50, 50);
$graph->title->Set("Consumo de Combustible por Viaje");
// Display the graph
$graph->Stroke();
Beispiel #18
0
$barplot_tot->value->Show();
$barplot_tot->value->SetFormatCallback('format_bytes_billing_short');
$barplot_in = new BarPlot($in_data);
$barplot_in->SetLegend("Traffic In");
$barplot_in->SetColor('#' . $config['graph_colours']['greens'][1]);
$barplot_in->SetFillColor('#' . $config['graph_colours']['greens'][0]);
$barplot_in->SetWeight(1);
$barplot_out = new BarPlot($out_data);
$barplot_out->SetLegend("Traffic Out");
$barplot_out->SetColor('#' . $config['graph_colours']['blues'][0]);
$barplot_out->SetFillColor('#' . $config['graph_colours']['blues'][1]);
$barplot_out->SetWeight(1);
if ($imgtype == "historical") {
    $barplot_over = new BarPlot($overuse_data);
    $barplot_over->SetLegend("Traffic Overusage");
    $barplot_over->SetColor('darkred');
    $barplot_over->SetFillColor('lightred@0.4');
    $barplot_over->SetWeight(1);
    $lineplot_allow = new LinePlot($allow_data);
    $lineplot_allow->SetLegend("Traffic Allowed");
    $lineplot_allow->SetColor('black');
    $lineplot_allow->SetWeight(1);
    $gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out, $barplot_over));
} else {
    $lineplot_allow = new LinePlot($ave_data);
    //$lineplot_allow->SetLegend("Average per ".$imgtype);
    $lineplot_allow->SetLegend("Average");
    $lineplot_allow->SetColor('black');
    $lineplot_allow->SetWeight(1);
    $gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out));
}
Beispiel #19
0
//Setup Mian Title
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->title->Set("{$txt_7day}");
$graph->title->SetColor("{$textcolour}");
//Setup x axis
$graph->xaxis->SetColor("{$xtextcolour}");
$graph->xaxis->HideLabels(true);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->xaxis->title->Set("{$txt_rain} ({$rain_unit})");
$graph->xaxis->title->SetColor("{$xtextcolour}");
// Setup y axis
$graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->yaxis->SetColor("{$ytextcolour}");
$graph->yaxis->SetLabelFormat("{$rain_format}");
$graph->yaxis->HideTicks(true, true);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.7);
$bplot->SetAlign("center");
$bplot->value->SetFont(FF_ARIAL, FS_BOLD);
$bplot->value->HideZero();
$bplot->value->SetColor("black");
$bplot->SetValuePos('top');
$bplot->value->Show();
$bplot->value->SetFormat("{$rain_format}");
$bplot->SetFillGradient("{$rain_col}", "#EEEEEE", GRAD_LEFT_REFLECTION);
$bplot->SetColor("{$rain_col}");
//Add plot
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
// Initialize bucket with 0's
for ($i = 0; $i < $INTERVAL_COUNT; $i++) {
    $bucket[$i] = 0;
    $tick_labels[$i] = $i * $range_interval . "+";
    //.((($i+1)*$range_interval)-1);
}
foreach ($humidity as $value) {
    $bucket_pos = floor($value / $range_interval);
    if ($bucket_pos >= $INTERVAL_COUNT) {
        $bucket_pos = $INTERVAL_COUNT - 1;
    }
    $bucket[$bucket_pos]++;
    //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]);
}
$humidity_plot = new BarPlot($bucket);
$humidity_plot->SetColor('dodgerblue');
$humidity_plot->SetWeight(2);
$humidity_plot->SetFillColor('dodgerblue');
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('background_v_40_60.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('textlin');
$graph->Add($humidity_plot);
$graph->ygrid->SetColor("azure3");
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->xaxis->SetTickLabels($tick_labels);
Beispiel #21
0
 /**
  * Executes test action
  *
  */
 public function executeTest()
 {
     /*
         In order to use fonts, you must define the location to your fonts:
         define('TTF_DIR', '/usr/X11R6/share/fonts/ttf/');
     */
     //------------------------------------------------------------------
     // Create some random data for the plot. We use the current time for the
     // first X-position
     //------------------------------------------------------------------
     $datay = array();
     $datax = array();
     $ts = time();
     $n = 70;
     // Number of data points
     for ($i = 0; $i < $n; ++$i) {
         $datax[$i] = $ts + $i * 150000;
         $datay[$i] = rand(5, 60);
         $datay2[$i] = rand(1, 8);
     }
     // Now get labels at the start of each month
     $date = new DateScaleUtils();
     list($tickPositions, $minTickPositions) = $date->getTicks($datax, DSUTILS_MONTH1);
     // Now create the real graph
     // Combine a line and a bar graph
     // We add some grace to the end of the X-axis scale so that the first and last
     // data point isn't exactly at the very end or beginning of the scale
     $grace = 400000;
     $xmin = $datax[0] - $grace;
     $xmax = $datax[$n - 1] + $grace;
     // Overall width of graphs
     $w = 450;
     // Left and right margin for each graph
     $lm = 25;
     $rm = 15;
     //----------------------
     // Setup the line graph
     //----------------------
     $graph = new sfJpGraph('line', $w, 250);
     $graph = $graph->getJpGraph();
     $graph->SetScale('linlin', 0, 0, $xmin, $xmax);
     $graph->SetMargin($lm, $rm, 10, 30);
     $graph->SetMarginColor('white');
     $graph->SetFrame(false);
     $graph->SetBox(true);
     $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 sfJpGraph('bar', $w, 110);
     $graph2 = $graph2->getJpGraph();
     $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 sfJpGraph('mgraph', $w, 110);
     $mgraph = $mgraph->getJpGraph();
     $mgraph->SetImgFormat('jpeg', 60);
     $mgraph->SetMargin(2, 2, 2, 2);
     $mgraph->SetFrame(true);
     $mgraph->AddMix($graph, 0, 0, 85);
     $mgraph->AddMix($graph2, 0, 250, 85);
     $mgraph->Stroke();
     return sfView::NONE;
 }
Beispiel #22
0
$graph->xaxis->SetFont(FF_FONT1, FS_NORMAL, 8);
$graph->yaxis->SetFont(FF_FONT1, FS_NORMAL, 11);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
if ($gorientation == "v") {
    $graph->img->SetAngle(90);
    $graph->Set90AndMargin(120, 40, 40, 40);
} else {
    $graph->xaxis->SetLabelAngle(90);
}
//Setup Frame
$graph->SetFrame(true, "#fafafa");
//$graph->SetFrame(false);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillColor($color . "@0.3");
//$bplot->SetShadow($color."@0.7",5,5);
// Set color for the frame of each bar
$bplot->SetColor($color . "@1");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
unset($graph);
$geoloc->close();
?>

$graph->SetMarginColor($background);
$graph->img->SetMargin(40, 30, 20, 160);
//Setup Frame
$graph->SetFrame(true, "#ffffff");
// Setup graph title
//$graph->title->Set($title);
//$graph->title->SetFont(FF_FONT1, FS_BOLD);
$bar_array = array();
$i = 0;
foreach ($final_values as $title => $values) {
    $i %= count($color_list);
    $datay = explode(",", $values);
    $bplot = new BarPlot($datay);
    $bplot->SetWidth(0.7);
    $bplot->SetFillColor($color_list[$i] . "@0.5");
    $bplot->SetColor($color_list[$i] . "@1");
    $bplot->SetLegend($title);
    $bar_array[] = $bplot;
    $i++;
}
// Create the grouped bar plot
$gbplot = new AccBarPlot($bar_array);
$gbplot->SetShadow($color . "@0.9", 6, 5);
$gbplot->SetWidth(0.6);
$graph->Add($gbplot);
$graph->xaxis->SetTickLabels($labelx);
$graph->xaxis->title->Set($titley);
$graph->yaxis->title->Set($titlex);
// Adjust the legend position
$graph->legend->SetColumns(3);
$graph->legend->SetPos(0.5, 0.95, 'center', 'bottom');
    $data['value'][] = $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_bar.php";
// Setup the graph.
$graph = new Graph(600, 250, "auto");
$graph->SetScale("textlin");
$graph->Set90AndMargin(150, 10, 20, 0);
$graph->SetMarginColor("#fafafa");
$graph->xaxis->SetTickLabels($data['title']);
$graph->SetColor("#fafafa");
$graph->SetFrame(true, '#fafafa', 0);
// Create the bar plots
$b1plot = new BarPlot($data['value']);
// color@transparencia
$b1plot->SetFillColor(array(COLOR1 . "@0.5", COLOR2 . "@0.5", COLOR3 . "@0.5", COLOR4 . "@0.5", COLOR5 . "@0.5", COLOR6 . "@0.5", COLOR7 . "@0.5", COLOR8 . "@0.5", COLOR9 . "@0.5", COLOR10 . "@0.5", COLOR11 . "@0.5", COLOR12 . "@0.5"));
//
$b1plot->SetShadow(array(COLOR1 . "@0.7", COLOR2 . "@0.7", COLOR3 . "@0.7", COLOR4 . "@0.7", COLOR5 . "@0.7", COLOR6 . "@0.7", COLOR7 . "@0.7", COLOR8 . "@0.7", COLOR9 . "@0.7", COLOR10 . "@0.7", COLOR11 . "@0.7", COLOR12 . "@0.7"), 5, 5);
$b1plot->SetColor(array(COLOR1 . "@1", COLOR2 . "@1", COLOR3 . "@1", COLOR4 . "@1", COLOR5 . "@1", COLOR6 . "@1", COLOR7 . "@1", COLOR8 . "@1", COLOR9 . "@1", COLOR10 . "@1", COLOR11 . "@1", COLOR12 . "@1"));
//
$graph->Add($b1plot);
// Finally send the graph to the browser
$graph->Stroke();
unset($graph);
?>

Beispiel #25
0
// Setup the graph.
$graph = new Graph(400, 200);
$graph->img->SetMargin(60, 20, 30, 50);
$graph->SetScale("textlin");
$graph->SetMarginColor("silver");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Example negative bars");
$graph->title->SetFont(FF_VERDANA, FS_NORMAL, 16);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
$graph->yaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// 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
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy", "steelblue", GRAD_MIDVER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
 /**
  *
  * @param int $userId
  * @param unknown_type $groupBy
  * @param unknown_type $startDate
  * @param unknown_type $endDate
  * @param Boolean $absolute Is y-axis relative to data set or absolute (starting from 0)
  */
 function displayUserGraph($userId, $groupBy, $startDate, $endDate, $absolute = true)
 {
     $graph = new Chart(750, 450, "auto");
     $graph->SetScale("textlin");
     $graph->title->Set("User growth over the time");
     $graph->yaxis->title->Set("Size");
     $graph->yaxis->SetTitleMargin(60);
     $graph->yaxis->setLabelFormatCallback(array($this, 'sizeReadable'));
     if ($absolute) {
         $graph->yaxis->scale->SetAutoMin(0);
     }
     $data = $this->_dum->getWeeklyEvolutionUserData($userId, $groupBy, $startDate, $endDate);
     if (is_array($data) && count($data) > 1) {
         $dates = array();
         $ydata = array();
         foreach ($data as $xdate => $values) {
             $dates[] = $xdate;
             $ydata[] = (double) $values;
         }
         $lineplot = new BarPlot($ydata);
         $lineplot->SetColor('blue');
         $lineplot->value->SetFont($graph->getFont(), FS_NORMAL, 8);
         $lineplot->value->setFormatCallback(array($this, 'sizeReadable'));
         $graph->Add($lineplot);
         $graph->xaxis->title->Set($groupBy . "s");
         $graph->xaxis->SetTitleMargin(35);
         $graph->xaxis->SetTickLabels($dates);
         $graph->Stroke();
     } else {
         $this->displayError($GLOBALS['Language']->getText('plugin_statistics', 'no_data_error'));
     }
 }
Beispiel #27
0
 /**
  * Draw the XY type plot
  *
  * @param array $data plot data array reference
  * @param array $xmlArr xml array reference
  * @return object refernce XY plot object reference
  */
 public function renderXYPlot(&$data, &$xmlArr)
 {
     $id = $xmlArr['ATTRIBUTES']['ID'];
     $field = $xmlArr['ATTRIBUTES']['FIELD'];
     $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE'];
     $pointType = $xmlArr['ATTRIBUTES']['POINTTYPE'];
     $weight = $xmlArr['ATTRIBUTES']['WEIGHT'];
     $color = $xmlArr['ATTRIBUTES']['COLOR'];
     $fillColor = $xmlArr['ATTRIBUTES']['FILLCOLOR'];
     $showVal = $xmlArr['ATTRIBUTES']['SHOWVALUE'];
     $legend = $xmlArr['ATTRIBUTES']['LEGENDFIELD'];
     $visible = $xmlArr['ATTRIBUTES']['VISIBLE'];
     if ($chartType == 'Line' or $chartType == 'Bar') {
         if ($chartType == 'Line') {
             include_once JPGRAPH_DIR . '/jpgraph_line.php';
             $plot = new LinePlot($data);
             $this->_drawMark($plot->mark, $xmlArr['POINTMARK']['ATTRIBUTES']['TYPE'], $xmlArr['POINTMARK']['ATTRIBUTES']['COLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['FILLCOLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['SIZE']);
             $plot->SetBarCenter();
             $plot->SetCenter();
         } else {
             if ($chartType == 'Bar') {
                 include_once JPGRAPH_DIR . '/jpgraph_bar.php';
                 $plot = new BarPlot($data);
                 $plot->SetAlign('center');
             }
         }
         if ($color) {
             $plot->SetColor($color);
         }
         if ($fillColor) {
             $plot->SetFillColor($fillColor);
         }
         if ($weight) {
             $plot->SetWeight($weight);
         }
         if ($showVal == 1) {
             $plot->value->Show();
         }
         if ($legend) {
             $plot->SetLegend($legend);
         }
         $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']);
     }
     if ($chartType == 'GroupBar' or $chartType == 'AccBar') {
         $children = $xmlArr['ATTRIBUTES']['CHILDREN'];
         $childList = explode(",", $children);
         foreach ($childList as $child) {
             $childPlotList[] = $this->m_PlotList[$child];
         }
         if ($chartType == 'GroupBar') {
             $plot = new GroupBarPlot($childPlotList);
         } else {
             if ($chartType == 'AccBar') {
                 $plot = new AccBarPlot($childPlotList);
             }
         }
     }
     $this->m_PlotList[$id] = $plot;
     if ($visible == 1) {
         return $plot;
     }
     return null;
 }
$bplot2 = new BarPlot($from_outside);
$gbplot = new GroupBarPlot(array($bplot, $bplot1, $bplot2));
// Adjust fill color
$graph->Add($gbplot);
$bplot->SetFillColor('#C40505');
$bplot->SetColor('#C40505');
$bplot->value->Show();
$bplot->value->SetFormat('%d');
$bplot->SetLegend("External");
$bplot1->SetFillColor('#94D239');
$bplot1->SetColor('#94D239');
$bplot1->value->Show();
$bplot1->value->SetFormat('%d');
$bplot1->SetLegend("Internal");
$bplot2->SetFillColor('#3925F8');
$bplot2->SetColor('#3925F8');
$bplot2->value->Show();
$bplot2->value->SetFormat('%d');
$bplot2->SetLegend("From Outside");
// Setup the titles
$graph->title->Set("Last 4 weeks - Total weekly calls breakdown by context");
$graph->xaxis->title->Set("Week year");
$graph->yaxis->title->Set("Calls");
$graph->yaxis->SetLabelAlign('center', 'top');
$graph->legend->SetColumns(3);
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetPos(0.5, 0.14, 'center', 'bottom');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
// Display the graph
 /**
  * Build a JpGraph barPlot object with retrived data.
  *
  * @return BarPlot
  */
 private function displayRepositoryPushesByWeek()
 {
     $nbRepo = count($this->repoList);
     $colors = array_slice($GLOBALS['HTML']->getChartColors(), 0, $nbRepo);
     $nbColors = count($colors);
     $i = 0;
     $bplot = array();
     foreach ($this->repoList as $repository) {
         $this->legend = null;
         $pushes = $this->getRepositoryPushesByWeek($repository);
         if ($this->displayChart) {
             $b2plot = new BarPlot($pushes);
             $color = $colors[$i++ % $nbColors];
             $b2plot->SetColor($color . ':0.7');
             $b2plot->setFillColor($color);
             if (!empty($this->legend)) {
                 $b2plot->SetLegend($this->legend);
             }
             $bplot[] = $b2plot;
         }
     }
     return $bplot;
 }
Beispiel #30
0
$graph->title->Set("$title");
$graph->title->SetFont(FF_FONT1, FS_BOLD, 18);
$graph->title->SetColor("$titlecolor");
*/
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1, FS_NORMAL, 8);
$graph->yaxis->SetFont(FF_FONT1, FS_NORMAL, 11);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
if ($gorientation == "v") {
    $graph->img->SetAngle(90);
    $graph->Set90AndMargin(120, 40, 40, 40);
} else {
    $graph->xaxis->SetLabelAngle(90);
}
//Setup Frame
$graph->SetFrame(true, "#fafafa");
//$graph->SetFrame(false);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillColor($colors[0] . "@0.3");
// Set color for the frame of each bar
$bplot->SetColor($colors[0]);
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
unset($graph);