Пример #1
0
 public function createPlot()
 {
     $size = '0.25';
     $plot = new \PiePlot($this->data);
     $plot->SetLegends($this->legends);
     $plot->SetSize($size);
     $plot->SetCenter(0.25, 0.32);
     $plot->ShowBorder();
     $plot->SetColor('black');
     $this->grafico->add($plot);
 }
 function graficarPDF()
 {
     $solo_registrados = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m01_registrada IS NOT NULL AND pasantia.m02_aceptada IS NULL AND periodo.activo = TRUE");
     $solo_aceptadas = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m02_aceptada IS NOT NULL AND pasantia.m03_numero_asignado IS NULL AND periodo.activo = TRUE");
     $solo_numero_asignado = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m03_numero_asignado IS NOT NULL AND pasantia.m04_sellada IS NULL AND periodo.activo = TRUE");
     $solo_sellada = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m04_sellada IS NOT NULL AND pasantia.m05_entrego_copia IS NULL AND periodo.activo = TRUE");
     $solo_entrego_copia = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m05_entrego_copia IS NOT NULL AND pasantia.m06_entrego_borrador IS NULL AND periodo.activo = TRUE");
     $solo_entrego_borrador = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m06_entrego_borrador IS NOT NULL AND pasantia.m07_retiro_borrador IS NULL AND periodo.activo = TRUE");
     $solo_retiro_borrador = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m07_retiro_borrador IS NOT NULL AND pasantia.m08_entrega_final IS NULL AND periodo.activo = TRUE");
     $finalizaron = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m08_entrega_final IS NOT NULL AND periodo.activo = TRUE");
     $this->MultiCell(200, 5, utf8_decode("\nRepública Bolivariana de Venezuela\nUniversidad del Zulia\nFacultad Experimental de Ciencias\nDivisión de Programas Especiales\nSistema de Pasantías\n\n\n\nEstadísticas de Hitos"), 0, "C", 0);
     //GENERAR LA TABLA
     $this->SetXY(5, 65);
     $this->SetFont('Arial', 'B', 12);
     $this->SetWidths(array(27, 25, 25, 25, 25, 25, 25, 25));
     $this->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'));
     $this->Row(array("Registradas", "Aceptadas", "Numero Asignado", "Selladas", "Entrega Copia", "Entrega Borrador", "Retiro Borrador", "Finalizaron"));
     $this->SetX(5);
     $this->SetFont('Arial', '', 12);
     $this->SetWidths(array(27, 25, 25, 25, 25, 25, 25, 25));
     $this->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'));
     $this->Row(array("{$solo_registrados}", "{$solo_aceptadas}", "{$solo_numero_asignado}", "{$solo_sellada}", "{$solo_entrego_copia}", "{$solo_entrego_borrador}", "{$solo_retiro_borrador}", "{$finalizaron}"));
     $data = array($solo_registrados, $solo_aceptadas, $solo_numero_asignado, $solo_sellada, $solo_entrego_copia, $solo_entrego_borrador, $solo_retiro_borrador, $finalizaron);
     //aqui va la cantidad que llevará cada parte del grafico
     $graph = new PieGraph(640, 480);
     //tamaño de la letra del titulo y la leyenda
     $graph->SetShadow();
     $db = new PgDB();
     //QUERY PARA EL PERIDO ACTIVO
     $queryPer = "SELECT tipo, anio FROM periodo WHERE activo = TRUE";
     $recoPer = pg_query($queryPer);
     $rowPer = pg_fetch_array($recoPer);
     $graph->title->Set(utf8_decode("REPORTE TOTAL\n{$rowPer['tipo']} - {$rowPer['anio']}"));
     $graph->title->SetFont(FF_FONT2, FS_BOLD);
     $p1 = new PiePlot($data);
     $p1->value->Show(true);
     $p1->SetLegends(array("Registradas", "Aceptadas", "Numeros Asignados", "Selladas", "Entrega de Copias", "Entrega de Borrador", "Retiro de Borrador", "Finalizaron"));
     //la leyenda del gráfico
     $p1->SetSize(0.3);
     //el radio del gráfico
     //$p1->SetAngle(45); //setear el angulo
     $graph->Add($p1);
     $graph->Stroke("asd.png");
     $this->Image("asd.png", -15, 85, 240, 180);
     // x, y, ancho, altura.
     $this->Image("logotipo.jpg", 20, 12, -280);
     unlink("asd.png");
 }
Пример #3
0
 function plot()
 {
     $this->_setValues();
     // Create the Pie Graph.
     $graph = new PieGraph(500, 300);
     $graph->SetShadow();
     // Create
     $p1 = new PiePlot($this->_data);
     // Set A title for the plot
     $p1->SetLegends($this->_legends);
     $p1->SetSize(0.3);
     $p1->SetCenter(0.28, 0.5);
     $txt = new Text("Most Visited Titles", 0.15, 0.05);
     $txt->SetFont(FONT1_BOLD);
     $graph->Add($p1);
     $graph->AddText($txt);
     $graph->Stroke();
 }
Пример #4
0
function graph_pie_chart($graph_title, $graph_theme, $legend_array, $data_array, $xcoord, $ycoord)
{
    //unlink("Images/piecharts2/pie_chart_image.png");
    print "{$graph_title}";
    print "{$graph_theme}";
    print "{$legend_array}";
    print "{$data_array}";
    print "{$xcoord}";
    print "{$ycoord}";
    print "{$legend_array['2']}";
    $graph = new PieGraph($xcoord, $ycoord);
    $graph->title->Set($graph_title);
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $pie = new PiePlot($data_array);
    $pie->SetLegends($legend_array);
    $pie->SetTheme($graph_theme);
    //Sets the colour scheme defined in jpgraph_pie.php
    $graph->Add($pie);
    $graph->Stroke("images/piecharts2/pie_chart_image.png");
}
 /**
  * Builds pie graph
  */
 function buildGraph()
 {
     $this->graph = new Chart_Pie($this->width, $this->height);
     // title setup
     $this->graph->title->Set($this->title);
     if (is_null($this->description)) {
         $this->description = "";
     }
     $this->graph->subtitle->Set($this->description);
     if (is_array($this->data) && array_sum($this->data) > 0) {
         $p = new PiePlot($this->data);
         $p->setSliceColors($this->graph->getThemedColors());
         $p->SetCenter(0.4, 0.6);
         $p->SetLegends($this->legend);
         $p->value->HideZero();
         $p->value->SetFont($this->graph->getFont(), FS_NORMAL, 8);
         $p->value->SetColor($this->graph->getMainColor());
         $p->value->SetMargin(0);
         $this->graph->Add($p);
     }
     return $this->graph;
 }
Пример #6
0
 public function executePieGraph()
 {
     //Set the response header to a image JPEG datastream
     $this->getResponse()->setContent('image/jpeg');
     $util = new util();
     //echo $duales;
     $data1 = $util->getDualMedia('movies');
     $data2 = $util->getTotalMedia('movies') - $data1;
     $data = array($data2, $data1);
     $graph = new PieGraph(199, 120);
     $graph->SetMarginColor('#393939');
     $graph->SetFrame(true, '#393939');
     $graph->legend->SetPos(0.8, 0.9, 'center', 'bottom');
     $p1 = new PiePlot($data);
     $p1->SetSize(0.4);
     $p1->SetCenter(0.45);
     $p1->SetSliceColors(array('white', 'red'));
     $p1->value->SetColor('black');
     $p1->SetLegends(array("Spa", "Dual"));
     $p1->SetLabelPos(0.6);
     $graph->Add($p1);
     $graph->Stroke();
     return sfView::NONE;
 }
Пример #7
0
$graph = new PieGraph(350, 200);
$graph->SetShadow();
// Setup title
$graph->title->Set("Example of pie plot with absolute labels");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// The pie plot
$p1 = new PiePlot($data);
// Move center of pie to the left to make better room
// for the legend
$p1->SetCenter(0.35, 0.5);
// No border
$p1->ShowBorder(false);
// Label font and color setup
$p1->value->SetFont(FF_FONT1, FS_BOLD);
$p1->value->SetColor("darkred");
// Use absolute values (type==1)
$p1->SetLabelType(PIE_VALUE_ABS);
// Label format
$p1->value->SetFormat("\$%d");
$p1->value->Show();
// Size of pie in fraction of the width of the graph
$p1->SetSize(0.3);
// Legends
$p1->SetLegends(array("May (\$%d)", "June (\$%d)", "July (\$%d)", "Aug (\$%d)"));
$graph->legend->Pos(0.05, 0.15);
$graph->Add($p1);
$graph->Stroke();
?>


Пример #8
0
if (empty($limit)) {
    $limit = 10;
}
$hids = new Host_ids("", "", "", "", "", "", "", "", "", "");
$list = $hids->Events($limit);
$data = $legend = array();
foreach ($list as $l) {
    $legend[] = $l[0];
    $data[] = $l[1];
}
$conf = $GLOBALS["CONF"];
$jpgraph = $conf->get_conf("jpgraph_path");
include "{$jpgraph}/jpgraph.php";
include "{$jpgraph}/jpgraph_pie.php";
// Setup graph
$graph = new PieGraph(400, 240, "auto");
$graph->SetShadow();
// Setup graph title
$graph->title->Set("HIDS Events");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create pie plot
$p1 = new PiePlot($data);
//$p1->SetFont(FF_VERDANA,FS_BOLD);
//$p1->SetFontColor("darkred");
$p1->SetSize(0.2);
$p1->SetCenter(0.35);
$p1->SetLegends($legend);
//$p1->SetStartAngle(M_PI/8);
//$p1->ExplodeSlice(0);
$graph->Add($p1);
$graph->Stroke();
Пример #9
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;
}
Пример #10
0
 private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False)
 {
     require_once 'jpgraph_pie.php';
     if ($dimensions == '3d') {
         require_once 'jpgraph_pie3d.php';
     }
     $this->_renderPiePlotArea($doughnut);
     $iLimit = $multiplePlots ? $groupCount : 1;
     for ($groupID = 0; $groupID < $iLimit; ++$groupID) {
         $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
         $exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
         if ($groupID == 0) {
             $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);
             }
         }
         $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
         $seriesPlots = array();
         //	For pie charts, we only display the first series: doughnut charts generally display all series
         $jLimit = $multiplePlots ? $seriesCount : 1;
         //	Loop through each data series in turn
         for ($j = 0; $j < $jLimit; ++$j) {
             $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
             //	Fill in any missing values in the $dataValues array
             $testCurrentIndex = 0;
             foreach ($dataValues as $k => $dataValue) {
                 while ($k != $testCurrentIndex) {
                     $dataValues[$testCurrentIndex] = null;
                     ++$testCurrentIndex;
                 }
                 ++$testCurrentIndex;
             }
             if ($dimensions == '3d') {
                 $seriesPlot = new PiePlot3D($dataValues);
             } else {
                 if ($doughnut) {
                     $seriesPlot = new PiePlotC($dataValues);
                 } else {
                     $seriesPlot = new PiePlot($dataValues);
                 }
             }
             if ($multiplePlots) {
                 $seriesPlot->SetSize(($jLimit - $j) / ($jLimit * 4));
             }
             if ($doughnut) {
                 $seriesPlot->SetMidColor('white');
             }
             $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
             if (count($datasetLabels) > 0) {
                 $seriesPlot->SetLabels(array_fill(0, count($datasetLabels), ''));
             }
             if ($dimensions != '3d') {
                 $seriesPlot->SetGuideLines(false);
             }
             if ($j == 0) {
                 if ($exploded) {
                     $seriesPlot->ExplodeAll();
                 }
                 $seriesPlot->SetLegends($datasetLabels);
             }
             $this->_graph->Add($seriesPlot);
         }
     }
 }
Пример #11
0
 public static function main($argv)
 {
     list($type, $id, $cmp_id) = $argv;
     // General.
     $o = null;
     $opts = array('xdim' => SG_DIM_X, 'ydim' => SG_DIM_Y, 'retObj' => true);
     // Options to pass to mbars().
     $count_horiz = SG_CNT_HORIZ;
     // Number og graphs to place in each horizontal multi graph "row".
     $graphs = array();
     if ($type == SG_T_TEAM) {
         $o = new Team($_GET['id']);
         $where = "f_team_id   = {$o->team_id}";
     } elseif ($type == SG_T_COACH) {
         $o = new Coach($_GET['id']);
         $where = "f_coach_id  = {$o->coach_id}";
     } elseif ($type == SG_T_PLAYER) {
         $o = new Player($_GET['id']);
         $where = "f_player_id = {$o->player_id}";
     }
     if ($type != SG_T_LEAGUE && !is_object($o)) {
         return false;
     }
     // Make graphs components for multi graph plot.
     if ($type == SG_T_LEAGUE) {
         /*
             Played matches.
         */
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             # m$i = minus/negative $i months from present month.
             array_push($queries, "SUM(IF({$range}, 1, 0)) AS 'Games_m{$i}'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
         }
         $query = "SELECT " . implode(', ', $queries) . " FROM matches";
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('Games' => 'royalblue');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Games played", "Months", "Games", $opts));
         /*
             Active teams
         */
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             array_push($queries, "(SELECT COUNT(DISTINCT(tid)) FROM\n                    (\n                    SELECT team1_id AS 'tid', date_played FROM matches WHERE {$range}\n                    UNION\n                    SELECT team2_id AS 'tid', date_played FROM matches WHERE {$range}\n                    ) AS tmptbl) AS 'Active teams_m{$i}'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'\n");
         }
         $query = "SELECT " . implode(', ', $queries);
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('Active teams' => 'olivedrab');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Active teams", "Months", "Teams", $opts));
         /*
             Active coaches
         */
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             array_push($queries, "(SELECT COUNT(DISTINCT(cid)) FROM\n                    (\n                    SELECT owned_by_coach_id AS 'cid', date_played FROM matches, teams WHERE team1_id = team_id AND {$range}\n                    UNION\n                    SELECT owned_by_coach_id AS 'cid', date_played FROM matches, teams WHERE team2_id = team_id AND {$range}\n                    ) AS tmptbl) AS 'Active coaches_m{$i}'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'\n");
         }
         $query = "SELECT " . implode(', ', $queries);
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('Active coaches' => 'darkorange1');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Active coaches", "Months", "Coaches", $opts));
         /*
             Played matches.
         */
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH_DAYS) as $i) {
             # Hack (for display purposes) set month -> year, day -> month
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} DAY)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} DAY)))\n                    AND\n                    (DAY(date_played) = DAY(SUBDATE(DATE(NOW()), INTERVAL {$i} DAY)))\n                )";
             # m$i = minus/negative $i months from present month.
             array_push($queries, "SUM(IF({$range}, 1, 0)) AS 'Games_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} DAY)) AS 'yr_m{$i}'");
             array_push($queries, "DAY(SUBDATE(DATE(NOW()), INTERVAL {$i} DAY)) AS 'mn_m{$i}'");
         }
         $query = "SELECT " . implode(', ', $queries) . " FROM matches";
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('Games' => 'royalblue');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row, SG_MULTIBAR_HIST_LENGTH_DAYS);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Games played", "Days", "Games", $opts));
         /*
             td & cp.
         */
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             # m$i = minus/negative $i months from present month.
             array_push($queries, "SUM(IF({$range}, cp, 0))     AS 'CP_m{$i}'");
             array_push($queries, "SUM(IF({$range}, td, 0))     AS 'TD_m{$i}'");
             #                array_push($queries, "SUM(IF($range, intcpt, 0)) AS 'int_m$i'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
         }
         $query = "SELECT " . implode(', ', $queries) . " FROM matches, match_data WHERE f_match_id = match_id";
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('CP' => 'seagreen', 'TD' => 'indianred');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "CP & TD history", "Months", "Amount", $opts));
         /*
             CAS.
         */
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             # m$i = minus/negative $i months from present month.
             array_push($queries, "SUM(IF({$range}, bh+si+ki, 0)) AS 'CAS_m{$i}'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
         }
         $query = "SELECT " . implode(', ', $queries) . " FROM matches, match_data WHERE f_match_id = match_id";
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('CAS' => 'firebrick1');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "CAS history", "Months", "Amount", $opts));
         /*
             SMP.
         */
         #            $queries = array();
         #            foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
         #                $range = "(
         #                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                    AND
         #                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                )";
         #                # m$i = minus/negative $i months from present month.
         #                array_push($queries, "SUM(IF($range, smp1+smp2, 0))     AS 'smp_m$i'");
         #                array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'yr_m$i'");
         #                array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'mn_m$i'");
         #            }
         #            $query  = "SELECT ".implode(', ', $queries)." FROM matches";
         #            $result = mysql_query($query);
         #            $row    = mysql_fetch_assoc($result);
         #
         #            $lengends = array('smp' => 'blue');
         #            list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         #            array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Total given sportsmanship points (smp)", "Months", "Points", $opts));
         /*
             Avg. gate per match.
         */
         #            $queries = array();
         #            foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
         #                $range = "(
         #                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                    AND
         #                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                )";
         #                # m$i = minus/negative $i months from present month.
         #                array_push($queries, "AVG(IF($range, gate/1000, NULL)) AS 'avg_gate_m$i'");
         #                array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'yr_m$i'");
         #                array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'mn_m$i'");
         #            }
         #
         #            $query  = "SELECT ".implode(', ', $queries)." FROM matches";
         #            $result = mysql_query($query);
         #            $row    = mysql_fetch_assoc($result);
         #
         #            $lengends = array('avg_gate' => 'blue');
         #            list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         #            array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Average gate per match (kilo)", "Months", "Gate", array_merge($opts, array('scale' => 'textlin'))));
         /*
             average absolute score diff.
         */
         #            $queries = array();
         #            foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
         #                $range = "(
         #                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                    AND
         #                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                )";
         #                # m$i = minus/negative $i months from present month.
         #                array_push($queries, "AVG(IF($range, ABS(CONVERT(team1_score,SIGNED) - CONVERT(team2_score,SIGNED)), NULL)) AS 'avg_abs_diff_m$i'");
         #                array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'yr_m$i'");
         #                array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'mn_m$i'");
         #            }
         #            $query  = "SELECT ".implode(', ', $queries)." FROM matches";
         #            $result = mysql_query($query);
         #            $row    = mysql_fetch_assoc($result);
         #
         #            $lengends = array('avg_abs_diff' => 'blue');
         #            list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         #            array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Average absolute score difference history", "Months", "Avg. abs. score diff.", array_merge($opts, array('scale' => 'textlin'))));
         /*
             Average deta treasury
         */
         #            $queries = array();
         #            foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
         #                $range = "(
         #                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                    AND
         #                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                )";
         #                # m$i = minus/negative $i months from present month.
         #                array_push($queries, "AVG(IF($range, ((income1+income2)/2)/1000, NULL))     AS 'avg_dtreasury_m$i'");
         #                array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'yr_m$i'");
         #                array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'mn_m$i'");
         #            }
         #            $query  = "SELECT ".implode(', ', $queries)." FROM matches";
         #            $result = mysql_query($query);
         #            $row    = mysql_fetch_assoc($result);
         #
         #            $lengends = array('avg_dtreasury' => 'blue');
         #            list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         #            array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Avg. change in team's treasury per match (kilo)", "Months", "Average change", array_merge($opts, array('scale' => 'textlin'))));
         /*
             Average fans at match.
         */
         #            $queries = array();
         #            foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
         #                $range = "(
         #                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                    AND
         #                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                )";
         #                # m$i = minus/negative $i months from present month.
         #                array_push($queries, "AVG(IF($range, fans, NULL))     AS 'fans_m$i'");
         #                array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'yr_m$i'");
         #                array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'mn_m$i'");
         #            }
         #            $query  = "SELECT ".implode(', ', $queries)." FROM matches";
         #            $result = mysql_query($query);
         #            $row    = mysql_fetch_assoc($result);
         #
         #            $lengends = array('fans' => 'blue');
         #            list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         #            array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Average fans per match", "Months", "Average fans", array_merge($opts, array('scale' => 'textlin'))));
         /*
             Average stars and mercs hirings per match
         */
         #            $queries = array();
         #            foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
         #                $range = "(
         #                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                    AND
         #                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                )";
         #                # m$i = minus/negative $i months from present month.
         #                array_push($queries, "AVG(IF($range, stars, NULL)) AS 'avg_stars_m$i'");
         #                array_push($queries, "AVG(IF($range, mercs, NULL)) AS 'avg_mercs_m$i'");
         #                array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'yr_m$i'");
         #                array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'mn_m$i'");
         #            }
         #            $tableMercs = "(
         #                SELECT f_match_id, SUM(IF(f_player_id = ".ID_MERCS.", 1, 0)) AS mercs FROM match_data GROUP BY f_match_id
         #            ) AS mercsTbl";
         #            $tableStars = "(
         #                SELECT f_match_id, SUM(IF(f_player_id <= ".ID_STARS_BEGIN.", 1, 0)) AS stars FROM match_data GROUP BY f_match_id
         #            ) AS starsTbl";
         #            $query  = "SELECT ".implode(', ', $queries)." FROM matches, $tableMercs, $tableStars WHERE mercsTbl.f_match_id = matches.match_id AND starsTbl.f_match_id = matches.match_id";
         #            $result = mysql_query($query);
         #            $row    = mysql_fetch_assoc($result);
         #
         #            $lengends = array('avg_stars' => 'red', 'avg_mercs' => 'green');
         #            list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         #            array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Avg. stars and mercs per match", "Months", "Average hirings", array_merge($opts, array('scale' => 'textlin'))));
         /*
             Injuries
         */
         #            $queries = array();
         #            foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
         #                $range = "(
         #                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                    AND
         #                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)))
         #                )";
         #                # m$i = minus/negative $i months from present month.
         #                array_push($queries, "SUM(IF($range, IF(inj = ".MNG.",  1, 0)+IF(agn1 = ".MNG.",  1, 0)+IF(agn2 = ".MNG.",  1, 0), 0)) AS 'mng_m$i'");
         #                array_push($queries, "SUM(IF($range, IF(inj = ".NI.",   1, 0)+IF(agn1 = ".NI.",   1, 0)+IF(agn2 = ".NI.",   1, 0), 0)) AS 'ni_m$i'");
         #                array_push($queries, "SUM(IF($range, IF(inj = ".MA.",   1, 0)+IF(agn1 = ".MA.",   1, 0)+IF(agn2 = ".MA.",   1, 0), 0)) AS 'ma_m$i'");
         #                array_push($queries, "SUM(IF($range, IF(inj = ".AV.",   1, 0)+IF(agn1 = ".AV.",   1, 0)+IF(agn2 = ".AV.",   1, 0), 0)) AS 'av_m$i'");
         #                array_push($queries, "SUM(IF($range, IF(inj = ".AG.",   1, 0)+IF(agn1 = ".AG.",   1, 0)+IF(agn2 = ".AG.",   1, 0), 0)) AS 'ag_m$i'");
         #                array_push($queries, "SUM(IF($range, IF(inj = ".ST.",   1, 0)+IF(agn1 = ".ST.",   1, 0)+IF(agn2 = ".ST.",   1, 0), 0)) AS 'st_m$i'");
         #                array_push($queries, "SUM(IF($range, IF(inj = ".DEAD.", 1, 0)+IF(agn1 = ".DEAD.", 1, 0)+IF(agn2 = ".DEAD.", 1, 0), 0)) AS 'dead_m$i'");
         #                array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'yr_m$i'");
         #                array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL $i MONTH)) AS 'mn_m$i'");
         #            }
         #            $query  = "SELECT ".implode(', ', $queries)." FROM matches, match_data WHERE f_match_id = match_id";
         #            $result = mysql_query($query);
         #            $row    = mysql_fetch_assoc($result);
         #
         #            $lengends = array('mng' => 'green', 'ni' => 'red', 'ma' => 'blue', 'av' => 'aqua', 'ag' => 'brown', 'st' => 'purple', 'dead' => 'slategray');
         #            list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         #            array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Types of sustained player injuries/statuses", "Months", "Amount", $opts));
         /*
             Race distribution
         */
         #            global $raceididx;
         #            $query  = "SELECT DISTINCT(f_race_id) AS 'race', COUNT(f_race_id) 'cnt' FROM teams GROUP BY f_race_id";
         #            $result = mysql_query($query);
         #            $data = array();
         #            while ($row = mysql_fetch_assoc($result)) {
         #                $data[$raceididx[$row['race']]." ($row[cnt])"] = $row['cnt'];
         #            }
         #            $graph = new PieGraph($opts['xdim'],$opts['ydim'],"auto");
         #            $graph->SetShadow();
         #            $graph->title->Set('Current race distribution');
         #            $graph->title->SetFont(FF_FONT1,FS_BOLD);
         #            $p1 = new PiePlot(array_values($data));
         #            $p1->SetLegends(array_keys($data));
         #            $p1->SetCenter(0.4);
         #            $graph->Add($p1);
         #            array_push($graphs, $graph);
         /*
             CAS distribution
         */
         #            $query  = "SELECT SUM(bh) AS 'bh', SUM(si) AS 'si', SUM(ki) AS 'ki' FROM match_data";
         #            $result = mysql_query($query);
         #            $o = (object) mysql_fetch_assoc($result);
         #            $data = array("BH ($o->bh)" => $o->bh, "SI ($o->si)" => $o->si, "Ki ($o->ki)" => $o->ki);
         #            $graph = new PieGraph($opts['xdim'],$opts['ydim'],"auto");
         #            $graph->SetShadow();
         #            $graph->title->Set('Current CAS distribution');
         #            $graph->title->SetFont(FF_FONT1,FS_BOLD);
         #            $p1 = new PiePlot(array_values($data));
         #            $p1->SetLegends(array_keys($data));
         #            $p1->SetCenter(0.4);
         #            $graph->Add($p1);
         #            array_push($graphs, $graph);
     } else {
         /********************
          *  Current CAS
          ********************/
         if (!$cmp_id && $o->mv_cas != 0) {
             $data = array("BH ({$o->mv_bh})" => $o->mv_bh, "SI ({$o->mv_si})" => $o->mv_si, "Ki ({$o->mv_ki})" => $o->mv_ki);
             $graph = new PieGraph($opts['xdim'], $opts['ydim'], "auto");
             $graph->SetShadow();
             $graph->title->Set('Current CAS distribution');
             $graph->title->SetFont(FF_FONT1, FS_BOLD);
             $p1 = new PiePlot(array_values($data));
             $p1->SetLegends(array_keys($data));
             $p1->SetCenter(0.4);
             $graph->Add($p1);
             array_push($graphs, $graph);
         }
         /********************
          *  BH, SI and Ki
          ********************/
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             # m$i = minus/negative $i months from present month.
             array_push($queries, "SUM(IF({$range}, bh, 0)) AS 'BH_m{$i}'");
             array_push($queries, "SUM(IF({$range}, si, 0)) AS 'SI_m{$i}'");
             array_push($queries, "SUM(IF({$range}, ki, 0)) AS 'Ki_m{$i}'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
         }
         $query = "SELECT " . implode(', ', $queries) . " FROM matches, match_data WHERE f_match_id = match_id AND {$where}";
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('BH' => 'forestgreen', 'SI' => 'firebrick', 'Ki' => 'blue');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "BH, SI and Ki distribution history", "Months", "Amount", $opts));
         /********************
          *  CP & TD
          ********************/
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             # m$i = minus/negative $i months from present month.
             array_push($queries, "SUM(IF({$range}, cp, 0))     AS 'CP_m{$i}'");
             array_push($queries, "SUM(IF({$range}, td, 0))     AS 'TD_m{$i}'");
             #                array_push($queries, "SUM(IF($range, intcpt, 0)) AS 'int_m$i'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
         }
         $query = "SELECT " . implode(', ', $queries) . " FROM matches, match_data WHERE f_match_id = match_id AND {$where}";
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('CP' => 'forestgreen', 'TD' => 'firebrick');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "CP & TD distribution history", "Months", "Amount", $opts));
         /********************
          *  Injuries
          ********************/
         $queries = array();
         foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
             $range = "(\n                    (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    AND\n                    (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                )";
             # m$i = minus/negative $i months from present month.
             array_push($queries, "SUM(IF({$range}, IF(inj = " . MNG . ",  1, 0)+IF(agn1 = " . MNG . ",  1, 0)+IF(agn2 = " . MNG . ",  1, 0), 0)) AS 'MNG_m{$i}'");
             array_push($queries, "SUM(IF({$range}, IF(inj = " . NI . ",   1, 0)+IF(agn1 = " . NI . ",   1, 0)+IF(agn2 = " . NI . ",   1, 0), 0)) AS 'Ni_m{$i}'");
             array_push($queries, "SUM(IF({$range}, IF(inj = " . MA . ",   1, 0)+IF(agn1 = " . MA . ",   1, 0)+IF(agn2 = " . MA . ",   1, 0), 0)) AS 'MA_m{$i}'");
             array_push($queries, "SUM(IF({$range}, IF(inj = " . AV . ",   1, 0)+IF(agn1 = " . AV . ",   1, 0)+IF(agn2 = " . AV . ",   1, 0), 0)) AS 'AV_m{$i}'");
             array_push($queries, "SUM(IF({$range}, IF(inj = " . AG . ",   1, 0)+IF(agn1 = " . AG . ",   1, 0)+IF(agn2 = " . AG . ",   1, 0), 0)) AS 'AG_m{$i}'");
             array_push($queries, "SUM(IF({$range}, IF(inj = " . ST . ",   1, 0)+IF(agn1 = " . ST . ",   1, 0)+IF(agn2 = " . ST . ",   1, 0), 0)) AS 'ST_m{$i}'");
             array_push($queries, "SUM(IF({$range}, IF(inj = " . DEAD . ", 1, 0)+IF(agn1 = " . DEAD . ", 1, 0)+IF(agn2 = " . DEAD . ", 1, 0), 0)) AS 'Dead_m{$i}'");
             array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
             array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
         }
         $query = "SELECT " . implode(', ', $queries) . " FROM matches, match_data WHERE f_match_id = match_id AND {$where}";
         $result = mysql_query($query);
         $row = mysql_fetch_assoc($result);
         $lengends = array('MNG' => 'green', 'Ni' => 'red', 'MA' => 'blue', 'AV' => 'aqua', 'AG' => 'brown', 'ST' => 'purple', 'Dead' => 'slategray');
         list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
         array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Types of sustained player injuries/statuses", "Months", "Amount", $opts));
         // Only if type = team.
         if ($type == SG_T_TEAM) {
             /********************
              *  Won, lost and draw
              ********************/
             $queries = array();
             foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
                 $range = "(\n                        (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                        AND\n                        (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    )";
                 # m$i = minus/negative $i months from present month.
                 array_push($queries, "SUM(IF((team1_score > team2_score AND team1_id = {$o->team_id} OR team1_score < team2_score AND team2_id = {$o->team_id}) AND {$range}, 1, 0)) AS 'W_m{$i}'");
                 array_push($queries, "SUM(IF((team1_score < team2_score AND team1_id = {$o->team_id} OR team1_score > team2_score AND team2_id = {$o->team_id}) AND {$range}, 1, 0)) AS 'L_m{$i}'");
                 array_push($queries, "SUM(IF(team1_score = team2_score AND {$range}, 1, 0)) AS 'D_m{$i}'");
                 array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
                 array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
             }
             $query = "SELECT " . implode(', ', $queries) . " FROM matches WHERE team1_id = {$o->team_id} OR team2_id = {$o->team_id}";
             $result = mysql_query($query);
             $row = mysql_fetch_assoc($result);
             $lengends = array('W' => 'forestgreen', 'L' => 'firebrick', 'D' => 'blue');
             list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
             array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Won, lost and draw distribution history", "Months", "Matches", $opts));
             /*
                 Average deta treasury
             */
             $queries = array();
             foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
                 $range = "(\n                        (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                        AND\n                        (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    )";
                 # m$i = minus/negative $i months from present month.
                 array_push($queries, "AVG(IF({$range}, IF(team1_id = {$o->team_id}, income1, income2)/1000, NULL)) AS 'Avg. change_m{$i}'");
                 array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
                 array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
             }
             $query = "SELECT " . implode(', ', $queries) . " FROM matches WHERE team1_id = {$o->team_id} OR team2_id = {$o->team_id}";
             $result = mysql_query($query);
             $row = mysql_fetch_assoc($result);
             $lengends = array('Avg. change' => 'darkolivegreen4');
             list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
             array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Avg. change in team's treasury per match (kilo)", "Months", "Average change", array_merge($opts, array('scale' => 'textlin'))));
             /*
                 SMP.
             */
             $queries = array();
             foreach (range(0, SG_MULTIBAR_HIST_LENGTH) as $i) {
                 $range = "(\n                        (YEAR(date_played) = YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                        AND\n                        (MONTH(date_played) = MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)))\n                    )";
                 # m$i = minus/negative $i months from present month.
                 array_push($queries, "SUM(IF({$range}, IF(team1_id = {$o->team_id}, smp1, smp2), 0))     AS 'SMP_m{$i}'");
                 array_push($queries, "YEAR(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'yr_m{$i}'");
                 array_push($queries, "MONTH(SUBDATE(DATE(NOW()), INTERVAL {$i} MONTH)) AS 'mn_m{$i}'");
             }
             $query = "SELECT " . implode(', ', $queries) . " FROM matches WHERE team1_id = {$o->team_id} OR team2_id = {$o->team_id}";
             $result = mysql_query($query);
             $row = mysql_fetch_assoc($result);
             $lengends = array('SMP' => 'blue');
             list($datasets, $labels) = SGraph::mbarsInputFormatter($lengends, $row);
             array_push($graphs, SGraph::mbars($datasets, $labels, $lengends, "Total given sportsmanship points (smp)", "Months", "Points", $opts));
         }
     }
     // Multi plot, baby!
     $mgraph = new MGraph();
     $count = count($graphs);
     for ($i = $j = 1; $i + ($j - 1) * $count_horiz <= $count; $j += $i == $count_horiz ? 1 : 0, $i = $i == $count_horiz ? 1 : $i + 1) {
         // i is horiz, j is vert.
         $mgraph->Add(array_shift($graphs), ($i - 1) * $opts['xdim'], ($j - 1) * $opts['ydim']);
     }
     return $mgraph->Stroke();
 }
Пример #12
0
<?php

include "jpgraph.php";
include "jpgraph_pie.php";
// Some data
$data = array(38, 62);
// Create the Pie Graph. Note you may cach this by adding the
// ache file name as PieGraph(300,300,"SomCacheFileName")
$graph = new PieGraph(300, 200);
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set("Example 1 Pie plot");
$graph->title->SetFont(FONT1_BOLD);
// Create graph
$p1 = new PiePlot($data);
$p1->SetLegends(array("Jan", "Feb"));
$graph->Add($p1);
// .. and finally stroke it
$graph->Stroke();
Пример #13
0
    // Title setup
    $graph->title->Set($logtype);
    $graph->title->SetFont(FF_ARIAL, FS_NORMAL);
    //$graph ->legend->Pos( 0.25,0.8,"right" ,"bottom");
    // Setup the pie plot
    $p1 = new PiePlot($y);
    $p1->SetTheme("earth");
    $p1->value->SetFormat("%d");
    $p1->SetLabelType(PIE_VALUE_ABS);
    $p1->SetSliceColors(array('chartreuse3', 'chocolate2', 'wheat1'));
    // Adjust size and position of plot
    $p1->SetSize(0.35);
    $p1->SetCenter(0.25, 0.52);
    $f = tr("found");
    $dnf = tr("not_found");
    $com = tr("comment");
    // Setup slice labels and move them into the plot
    $xx = array($f, $dnf, $com);
    $p1->value->SetFont(FF_COURIER, FS_NORMAL);
    $p1->value->SetColor("black");
    $p1->SetLabelPos(0.65);
    $p1->SetLegends($xx);
    $graph->legend->SetFont(FF_ARIAL, FS_NORMAL);
    // Explode all slices
    //$p1->ExplodeAll(10);
    // Finally add the plot
    $graph->Add($p1);
    $graph->SetShadow();
    // ... and stroke it
    $graph->Stroke();
}
Пример #14
0
<?php

date_default_timezone_set('America/Bogota');
require_once "lib/jpgraph/src/jpgraph.php";
require_once "lib/jpgraph/src/jpgraph_pie.php";
// Se define el array de valores y el array de la leyenda
if (isset($_GET['datos']) && isset($_GET['textos'])) {
    $d = stripslashes($_GET['datos']);
    $datos = unserialize($d);
    $t = stripslashes($_GET['textos']);
    $textos = unserialize($t);
    //$titulo = $_GET['titulo'];
    //Se define el grafico
    $grafico = new PieGraph(380, 200);
    //Definimos el titulo
    $grafico->title->Set("Grafica");
    $grafico->title->SetFont(FF_FONT1, FS_BOLD);
    //Añadimos el titulo y la leyenda
    $p1 = new PiePlot($datos);
    $p1->SetLegends($textos);
    $p1->SetCenter(0.2);
    //Se muestra el grafico
    $grafico->Add($p1);
    $grafico->Stroke();
}
 /**
  *
  * @param Integer $used
  * @param Integer $total
  */
 function displayProjectProportionUsage($used, $total)
 {
     $graph = new Chart_Pie(350, 250, "auto");
     $data = array($used, $total - $used);
     $usage = new PiePlot($data);
     $usage->SetSliceColors(array('#44697D', '#ACBBA4'));
     $usage->SetLegends(array("Used proportion", "Allowed quota"));
     $graph->legend->SetPos(0.01, 0, 'right', 'top');
     $graph->add($usage);
     //graph display
     $graph->stroke();
 }
Пример #16
0
 private function createCookieGraph($xdata, $ytitle)
 {
     // Create the graph.
     $graph = new PieGraph($this->width, $this->height, "auto");
     $graph->title->SetFont(FF_FONT1, FS_NORMAL, 10);
     $graph->SetFrame(false);
     if ($this->shadow) {
         $graph->SetShadow();
     }
     $p1 = new PiePlot($xdata);
     // second group negative
     $p1->SetLegends($this->ydata1);
     $p1->SetCenter(0.3);
     $p1->SetTheme("earth");
     //color for negative prologiq "#cc00cc"
     $p1->value->SetFont(FF_FONT1, FS_NORMAL, 10);
     $graph->title->Set($ytitle);
     // ... and add it to the graph
     $graph->Add($p1);
     return $graph;
 }
Пример #17
0
 function parse($input, $parser)
 {
     global $jpgraphLabelType;
     foreach (split("\n", $input) as $line) {
         // skip empty line or comments
         if (preg_match("/^(\\s*)#.*\$|^(\\s*)\$/", $line)) {
             continue;
         }
         // Storing data
         $raw_data = split($this->fieldsep, $line);
         if (count($raw_data) == 2) {
             $this->labels[] = $raw_data[0];
             $this->datay[] = $raw_data[1];
         } else {
             $this->datay[] = $raw_data[0];
         }
     }
     if ($this->is3d) {
         $pie = new PiePlot3D($this->datay);
         $pie->SetAngle($this->angle);
     } else {
         $pie = new PiePlot($this->datay);
     }
     if ($this->center) {
         $tmp = split(",", $this->center);
         if (is_array($tmp) && count($tmp) == 2) {
             $pie->SetCenter($tmp[0], $tmp[1]);
         } else {
             if (is_array($tmp) && count($tmp) == 1) {
                 $pie->SetCenter($tmp[0]);
             }
         }
     }
     if ($this->labeltype) {
         $label_type = $jpgraphLabelType[$this->labeltype];
         if (!$label_type) {
             throw new JpgraphMWException("Unknown label type(" . $this->labeltype . "). Possible values are: " . implode(", ", array_keys($jpgraphLabelType)));
         }
         $pie->SetLabelType($label_type);
     }
     if ($this->labelformat) {
         $pie->value->SetFormat($this->labelformat);
     }
     if ($this->usettf) {
         $pie->value->SetFont($this->font);
     }
     $pie->value->Show($this->showlabel);
     $explode_pie_list = split(",", $this->explode);
     if (count($explode_pie_list) == 1) {
         $pie->ExplodeAll($explode_pie_list[0]);
     } else {
         $pie->Explode($explode_pie_list);
     }
     if (count($this->labels) == count($this->datay)) {
         $pie->SetLegends($this->labels);
     }
     $this->graph->Add($pie);
 }
Пример #18
0
<?php

require_once realpath(dirname(__FILE__)) . '/../../config_path.inc.php';
include 'graph/jpgraph.php';
include 'graph/jpgraph_pie.php';
//import_request_variables("gP","");
extract($_GET, EXTR_OVERWRITE, ADA_GP_VARIABLES_PREFIX);
extract($_POST, EXTR_OVERWRITE, ADA_GP_VARIABLES_PREFIX);
$nodes_percent_decode = urldecode($nodes_percent);
// Array dei dati
$data = array($nodes_percent_decode, 100 - $nodes_percent_decode);
// Crea un grafico a torta
$graph = new PieGraph(300, 200);
$graph->SetShadow();
// Set titolo
$graph->title->Set('Nodi visitati');
$graph->title->SetFont(FONT1_BOLD);
// Crea il grafico
$p1 = new PiePlot($data);
$p1->SetLegends(array('visitati'));
$graph->Add($p1);
// output
$graph->Stroke();
Пример #19
0
 public static function pieShow($piedata, $piename, $title)
 {
     //饼状图生成
     $graph = new PieGraph(LENHSIZE, HEISIZE);
     //设置画布尺寸
     $graph->img->SetMargin(LEFT, RIGHT, UP, DOWN);
     $graph->SetShadow();
     $graph->title->set($title);
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE);
     $num = count($piedata);
     //如果个数大于10则用2D显示,否则用3D显示
     if (num < 10) {
         $pieplot = new PiePlot3D($piedata);
     } else {
         $pieplot = new PiePlot($piedata);
     }
     $pieplot->setCenter(0.4);
     $pieplot->SetLegends($piename);
     $graph->legend->SetColumns(1);
     $pieplot->value->Show();
     $graph->legend->SetPos(0.01, 0.01, 'right', 'right');
     //设置图例显示属性
     $graph->legend->setFont(FF_SIMSUN, FS_BOLD, GRAGHSIZE - 6);
     $graph->Add($pieplot);
     //借出次数最多物品突出显示
     $max = max($piedata);
     foreach ($piedata as $key => $value) {
         if ($value == $max) {
             $pieplot->ExplodeSlice($key);
         }
     }
     // $graph->AddText(new text("jhgjhs"),false);
     // $pieplot->ExplodeSlice( 0 );
     $num = rand(0, RAND);
     // echo var_dump($num);
     $name = "Histogrm" . $num . ".png";
     session_start();
     $_SESSION["name"] = $name;
     // echo var_dump($name);
     $graph->Stroke($name);
     return $name;
 }
Пример #20
0
function baw_render_jpgraph_img()
{
    include_once "../config.php";
    if (isset($_GET['type'])) {
        $type = $_GET['type'];
    } else {
        return;
    }
    $d = $_GET['d'];
    $f = $_GET['f'];
    $count = count($d);
    $dir = $BAW_CONF['jpgraph_path'] . '/jpgraph.php';
    include_once $dir;
    switch ($type) {
        case 'bar':
            include_once $BAW_CONF['jpgraph_path'] . '/jpgraph_bar.php';
            break;
        case 'pie':
            include_once $BAW_CONF['jpgraph_path'] . "/jpgraph_pie.php";
            $size = 0.17;
            $graph = new PieGraph(600, 250, "auto");
            for ($i = 0; $i < 1; $i++) {
                $p1 = new PiePlot($d[$i]);
                if ($i == 0) {
                    $p1->SetLegends($d[0]);
                }
                $p1->title->Set($f[1]);
                $p1->SetSize($size);
                $vert = 0.15 + ($size + 0.1) * $i;
                $p1->SetCenter($vert, 0.3);
                $p1->SetStartAngle(0);
                $p1->SetTheme("sand");
                $graph->Add($p1);
            }
            $graph->Stroke();
            break;
        case 'line':
            include_once $BAW_CONF['jpgraph_path'] . "/jpgraph_line.php";
            break;
    }
    return $out;
}
Пример #21
0
 public function executePieGraphSingers(sfWebRequest $request)
 {
     $util = new util();
     $loko = $util->singersData();
     //Set the response header to a image JPEG datastream
     $this->getResponse()->setContent('image/jpeg');
     //echo $duales;
     $data1 = 300;
     $data2 = 200;
     //        $data_results = $util->singersData();
     $data = array($data2, $data1);
     $graph = new PieGraph(200, 174);
     $graph->SetMarginColor('#393939');
     $graph->SetFrame(true, '#393939');
     $graph->legend->SetPos(0.8, 0.9, 'center', 'bottom');
     $p1 = new PiePlot($data);
     $p1->SetSize(0.4);
     $p1->SetCenter(0.45);
     $p1->SetSliceColors(array('white', 'red'));
     $p1->value->SetColor('black');
     $p1->SetLegends(array("Spa", "Dual"));
     $p1->SetLabelPos(0.6);
     $graph->Add($p1);
     $graph->Stroke();
     return sfView::NONE;
 }
Пример #22
0
<?php

include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/controller/jpgraph/jpgraph.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/controller/jpgraph/jpgraph_pie.php';
$data = array();
if (isset($_GET['present']) && isset($_GET['absent'])) {
    $data[] = $_GET['present'];
    $data[] = $_GET['absent'];
}
$graph = new Piegraph(350, 350);
$theme_class = "DefaultTheme";
//$graph->SetTheme(new $theme_class());
// Set A title for the plot
$graph->title->Set("Attendance Report");
$graph->SetBox(true);
// Create
$p1 = new PiePlot($data);
$p1->SetSize(0.28);
$p1->SetCenter(0.25, 0.32);
$p1->SetLegends(array("Present", "Absent"));
$graph->Add($p1);
$p1->ShowBorder(1, '#000000');
$p1->SetColor('black');
$p1->SetSliceColors(array('#2E2EFE', '#FFBF00'));
$graph->Stroke();
Пример #23
0
<?php

require_once "../src/jpgraph.php";
require_once "../src/jpgraph_pie.php";
//模拟数据
$data = array(0 => 3.5, 1 => 4.6, 2 => 9.1, 3 => 21.9, 4 => 42.3, 5 => 90.7, 6 => 183.5, 7 => 127.5, 8 => 61.4, 9 => 33.5, 10 => 11.5, 11 => 4.4);
//创建画布
$graph = new PieGraph(800, 500);
//设置图像边界范围
$graph->img->SetMargin(30, 30, 80, 30);
//设置标题
$graph->title->SetFont(FF_CHINESE);
$graph->title->Set("饼图--PiePlot Test");
//得到饼图对象
$piePlot = new PiePlot($data);
//设置图例
$piePlot->SetLegends(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
//设置图例位置
$graph->legend->Pos(0.01, 0.45, "left", "top");
//添加到画布中
$graph->Add($piePlot);
//输出
$graph->Stroke();
Пример #24
0
<?php

include "../jpgraph.php";
include "../jpgraph_pie.php";
include "../jpgraph_pie3d.php";
$data = array(40, 60, 21, 33);
$graph = new PieGraph(300, 200, "auto");
$graph->SetShadow();
$graph->title->Set("A simple Pie plot");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$p1 = new PiePlot($data);
$p1->ExplodeSlice(1);
$p1->SetCenter(0.45);
$p1->SetLegends($gDateLocale->GetShortMonth());
$graph->Add($p1);
$graph->Stroke();
?>


Пример #25
0
        $legenda[] = $array[0];
        $tot_top10 = $tot_top10 + $array[1];
        $data[] = $array[1];
    }
}
$legenda[] = "Other Titles";
$data[] = $total - $tot_top10;
// operação retirada em 02/2006
// Objetivo: aproveitar o arquivo já processada anteriormente, desde que no mesmo dia
// $OP="rm -f $db_tmp_issn.* ";
// $result=exec($OP);
// **************************************************************
// ********  Apresentação grafico                        ********
// **************************************************************
$graph = new PieGraph(690, 350);
//   $graph->SetShadow ();
// Create
$p1 = new PiePlot($data);
// Set A title for the plot
$p1->SetLegends($legenda);
$p1->SetSize(0.4);
$p1->SetCenter(0.28, 0.5);
$txt = new Text("Most Visited Titles", 0.15, 0.0);
$txt->SetFont(FONT1_BOLD);
$graph->Add($p1);
$graph->AddText($txt);
$graph->Stroke();
?>
 

Пример #26
0
    if ($point["name"] != "Start") {
        $labels[] = $point["name"] . " (" . $point["diff"] . ")";
        $data[] = (double) $point["diff"];
    }
}
// A new graph
$graph = new PieGraph(750, 500, "auto");
// Setup title
$graph->title->Set("Benchmark Results");
$graph->title->SetFont($font, FS_BOLD, 12);
// The pie plot
$p1 = new PiePlot($data);
$p1->SetTheme('pastel');
// Move center of pie to the left to make better room
// for the legend
$p1->SetCenter(0.26, 0.55);
// Label font and color setup
$p1->SetFont($font, FS_BOLD);
$p1->SetFontColor("black");
// Use absolute values (type==1)
$p1->SetLabelType(1);
// Label format
$p1->SetLabelFormat("%.5f");
// Size of pie in fraction of the width of the graph
$p1->SetSize(0.3);
// Legends
$p1->SetLegends($labels);
$graph->legend->SetFont($font);
$graph->legend->Pos(0.06, 0.1);
$graph->Add($p1);
$graph->Stroke();
Пример #27
0
    }
}
$longest_size++;
for ($i = 0; $i < $category_count; $i++) {
    #echo $data_count_arr[$i];
    $percentage = number_format($data_count_arr[$i] / $total * 100, 1);
    #echo $percentage;
    $percentage_str = str_pad($percentage, 5, ' ', STR_PAD_LEFT);
    $data_category_arr[$i] = str_pad($data_category_arr[$i], $longest_size);
    $data_category_arr[$i] = $data_category_arr[$i] . $percentage_str;
    if ($percentage < 1) {
        $data_count_arr[$i] = 0;
    }
}
$proj_name = project_get_field($t_project_id, 'name');
# Setup Graph
# ---
$graph = new PieGraph(800, 600);
$graph->SetShadow();
# Set A title for the plot
$graph->title->Set("Category Distribution Graph: {$proj_name}");
$graph->title->SetFont(FF_FONT2, FS_BOLD);
# Create graph
$p1 = new PiePlot($data_count_arr);
$p1->SetLegends($data_category_arr);
$p1->SetSize(260);
$p1->SetCenter(0.35);
$p1->SetSliceColors($g_color_arr);
$p1->SetStartAngle(-90);
$graph->Add($p1);
$graph->Stroke();
Пример #28
0
 private function _getTorta($datos, $textos)
 {
     //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($textos);
     $p1->SetCenter(0.4);
     //Se muestra el grafico
     $grafico->Add($p1);
     $grafico->Stroke();
 }
Пример #29
0
<?php

include_once "../jpgraph.php";
include_once "../jpgraph_pie.php";
// Some data
$data = array(40, 21, 17, 14, 23);
// Create the Pie Graph.
$graph = new PieGraph(300, 200, 'auto');
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set("Client side image map");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create
$p1 = new PiePlot($data);
$p1->SetCenter(0.4, 0.5);
$p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"));
$targ = array("pie_csimex1.php#1", "pie_csimex1.php#2", "pie_csimex1.php#3", "pie_csimex1.php#4", "pie_csimex1.php#5", "pie_csimex1.php#6");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$p1->SetCSIMTargets($targ, $alts);
$graph->Add($p1);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM('pie_csimex1.php');
?>


Пример #30
0
 public function grafico_distribucion_tipo_resp($id_asignacionprueba)
 {
     require_once APPPATH . '/libraries/JpGraph/jpgraph_pie.php';
     $this->rendimiento_global($id_asignacionprueba);
     $data_circ = array($this->totalcorrectas, $this->totalincorrectas, $this->totalomitidas);
     $columnas_circ = array('Correctas', 'Incorrectas', 'Omitidas');
     $graph_circ = new PieGraph(400, 320);
     $graph_circ->title->Set("Distribución por Tipo de Respuesta");
     $graph_circ->SetMarginColor("#fff");
     $graph_circ->SetFrame(true, '#fff', 1);
     $graph_circ->SetBox(false);
     $p1 = new PiePlot($data_circ);
     $p1->ExplodeSlice(0);
     $p1->SetCenter(0.5);
     //$p1->SetLegends('Correctas','Incorrectas','Omitidas');
     $p1->SetLegends($columnas_circ);
     // No border
     $p1->ShowBorder(false);
     $graph_circ->legend->SetPos(0.1, 0.996, 'left', 'bottom');
     $graph_circ->legend->SetFrameWeight(1);
     $p1->SetGuideLines(true, false);
     $p1->SetGuideLinesAdjust(1.5);
     $p1->SetLabelType(PIE_VALUE_PER);
     $p1->value->Show();
     $p1->SetSliceColors(array('#1d71b8', '#ea1d25', 'orange'));
     $graph_circ->Add($p1);
     $graph_circ->Stroke(_IMG_HANDLER);
     global $img_graf_dist_resp;
     $this->img_graf_dist_resp = "assets/images/graf_dist_resp.jpg";
     $graph_circ->img->Stream($this->img_graf_dist_resp);
     /*
     $graph_circ->img->Headers();
     $graph_circ->img->Stream();
     */
 }