Exemplo n.º 1
1
function graficoBarra($data, $archivo = "", $meta_data = array('titulo' => 'Sin Título', 'tituloX' => 'Eje X', 'tituloY' => 'Eje Y', 'color' => 'SkyBlue', 'width' => 800, 'height' => 600, 'angle' => 45), $legend = array("Datos"))
{
    # Objeto que crea el gráfico y su tama?o
    $plot = new PHPlot($meta_data['width'], $meta_data['height']);
    $plot->SetImageBorderType('plain');
    # Setea el archivo donde se guarda la imagen generada y no permite la visualización inmediata
    $plot->SetPrintImage(false);
    $plot->SetFileFormat("jpg");
    $plot->SetOutputFile($archivo);
    $plot->SetIsInline(true);
    # Envio de datos
    $plot->SetDataValues($data);
    # Tipo de gráfico y datos
    $plot->SetDataType("text-data");
    $plot->SetPlotType("bars");
    # Setiando el True type font
    //$plot->SetTTFPath(TTFPath);
    //$plot->SetUseTTF(TRUE);
    $plot->SetAxisFontSize(2);
    $plot->SetVertTickIncrement(7);
    //$plot->SetXTickLength(7);
    //$plot->SetDataColors($meta_data['color']);
    $plot->SetDataColors(array($meta_data['color'], 'red', 'white'));
    $plot->SetLegendPixels(1, 1);
    $plot->SetLegend($legend);
    # Etiquetas del eje Y:
    $plot->SetYTitle($meta_data['tituloY']);
    $plot->SetYDataLabelPos('plotin');
    # Título principal del gráfico:
    $plot->SetTitle($meta_data['titulo']);
    # Etiquetas eje X:
    $plot->SetXTitle($meta_data['tituloX']);
    if (isset($meta_data['angle'])) {
        $plot->SetXLabelAngle($meta_data['angle']);
    } else {
        $plot->SetXLabelAngle(45);
    }
    $plot->SetXTickLabelPos('none');
    $plot->SetXTickPos('none');
    # Método que dibuja el gráfico
    $plot->DrawGraph();
    $plot->PrintImage();
}
Exemplo n.º 2
0
function plotGraph($data)
{
    //Define the object
    $plot = new PHPlot(800, 400);
    $plot->SetIsInline(true);
    $plot->SetOutputFile('phpplot2.png');
    $example_data = $data;
    $plot->SetDataValues($example_data);
    $plot->SetDataType('data-data');
    //Set titles
    $plot->SetTitle("temp and humi");
    $plot->SetXTitle('time');
    $plot->SetYTitle('Y Data');
    $legend = array('temp', 'humi', 'state');
    $plot->SetLegend($legend);
    $plot->SetXDataLabelAngle(90);
    //$plot->SetXGridLabelType("time");
    $plot->SetXTickLabelPos('xaxis');
    $plot->SetXTickPos('plotdown');
    $plot->SetXLabelType('time', '%H:%M');
    $plot->TuneXAutoTicks(10, 'date');
    //	$plot->SetXTickIncrement(.5);
    //$plot->SetXTickIncrement(60 * 24);
    $plot->SetPlotType('lines');
    //$plot->SetPlotAreaWorld(strtotime('00:00'), null, strtotime('23:59'), null);
    $plot->SetDrawXGrid(true);
    //Draw it
    $plot->DrawGraph();
}
Exemplo n.º 3
0
 public function renderLot()
 {
     $grafico = new PHPlot(800, 600);
     $grafico->SetFileFormat("jpg");
     $grafico->SetIsInline(True);
     #Indicamos o títul do gráfico e o título dos dados no eixo X e Y do mesmo
     $grafico->SetTitle($this->data->titulo);
     $grafico->SetXTitle($this->data->eixoX);
     $grafico->SetYTitle($this->data->eixoY);
     #passamos o tipo de gráfico escolhido
     if (!$this->data->tipoLot) {
         $this->data->tipoLot = 'bars';
     }
     $grafico->SetPlotType($this->data->tipoLot);
     switch ($this->data->tipoLot) {
         case 'pie':
             $grafico->SetPieLabelType('index', 'custom', 'mycallback');
             $grafico->SetDataType('text-data-single');
             break;
         case 'stackedbars':
             $grafico->SetDataType('text-data-yx');
             break;
         case 'bubbles':
             $grafico->SetDataType('data-data-xyz');
             break;
     }
     $grafico->SetLegend($column_names);
     #Definimos os dados do gráfico
     switch ($this->data->tipoLot) {
         case 'pie':
             $dados = array(array($this->data->x1, $this->data->y11), array($this->data->x2, $this->data->y21), array($this->data->x3, $this->data->y31), array($this->data->x4, $this->data->y41));
             break;
         default:
             $dados = array(array($this->data->x1, $this->data->y11, $this->data->y12, $this->data->y13), array($this->data->x2, $this->data->y21, $this->data->y22, $this->data->y23), array($this->data->x3, $this->data->y31, $this->data->y32, $this->data->y33), array($this->data->x4, $this->data->y41, $this->data->y42, $this->data->y43));
             break;
     }
     $grafico->SetDataValues($dados);
     #Salvamos o gráfico
     $caminho = \Manager::getFilesPath();
     $fileName = uniqid() . '.jpg';
     $grafico->SetOutputFile($caminho . '/' . $fileName);
     $grafico->SetIsInline(True);
     $grafico->DrawGraph();
     #obtemos o endereco do grafico
     $this->data->locate = \Manager::getDownloadURL('files', basename($fileName), true);
 }
 public function doGet(WebAppRequest $req, WebAppResponse $res)
 {
     // Bootstraps Innomatic
     require_once 'innomatic/core/InnomaticContainer.php';
     $innomatic = InnomaticContainer::instance('innomaticcontainer');
     // Sets Innomatic base URL
     $baseUrl = '';
     $webAppPath = $req->getUrlPath();
     if (!is_null($webAppPath) && $webAppPath != '/') {
         $baseUrl = $req->generateControllerPath($webAppPath, true);
     }
     $innomatic->setBaseUrl($baseUrl);
     $innomatic->setInterface(InnomaticContainer::INTERFACE_WEB);
     $home = WebAppContainer::instance('webappcontainer')->getCurrentWebApp()->getHome();
     $innomatic->bootstrap($home, $home . 'core/conf/innomatic.ini');
     $id = basename($req->getParameter('id'));
     //$id = basename($_GET['id']);
     $args = unserialize(file_get_contents(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id));
     require_once 'phplot/PHPlot.php';
     $graph = new PHPlot($args['width'], $args['height']);
     $graph->SetIsInline('1');
     //$graph->SetDataColors( array("blue",'white'),array("black") );
     //$graph->$line_style = array('dashed','dashed','solid','dashed','dashed','solid');
     // Base
     $graph->SetDataValues($args['data']);
     $graph->SetPlotType($args['plottype']);
     // Appearance
     $graph->SetPointShape($args['pointshape']);
     $graph->SetPointSize($args['pointsize']);
     $graph->SetTitle($args['title']);
     // Color
     $graph->SetBackgroundColor($args['backgroundcolor']);
     $graph->SetGridColor($args['gridcolor']);
     if (count($args['legend'])) {
         $graph->SetLegend($args['legend']);
     }
     $graph->SetLineWidth($args['linewidth']);
     $graph->SetTextColor($args['textcolor']);
     $graph->SetDataColors(array(array(145, 165, 207), array(114, 167, 112), array(71, 85, 159), array(175, 83, 50), array(247, 148, 53), array(240, 231, 125), array(154, 204, 203), array(201, 164, 196)), 'black');
     //$graph->data_color = array( array(145,165,207), array(114,167,112), array(71,85,159), array(175,83,50), array(247,148,53), array(240,231,125), array(154,204,203), array(201,164,196) );
     //array('blue','green','yellow','red','orange');
     $graph->DrawGraph();
     unlink(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id);
 }
Exemplo n.º 5
0
function testBars()
{
    # PHPlot Example: Bar chart, 3 data sets, unshaded
    $data = array(array('Jan', 40, 2, 4), array('Feb', 30, 3, 4), array('Mar', 20, 4, 4), array('Apr', 10, 5, 4), array('May', 3, 6, 4), array('Jun', 7, 7, 4), array('Jul', 10, 8, 4), array('Aug', 15, 9, 4), array('Sep', 20, 5, 4), array('Oct', 18, 4, 4), array('Nov', 16, 7, 4), array('Dec', 14, 3, 4));
    $plot = new PHPlot(800, 600);
    $plot->SetIsInline(true);
    $plot->SetImageBorderType('plain');
    $plot->SetPlotType('bars');
    $plot->SetDataType('text-data');
    $plot->SetDataValues($data);
    # Main plot title:
    $plot->SetTitle('Unshaded Bar Chart with 3 Data Sets');
    # No 3-D shading of the bars:
    $plot->SetShading(0);
    # Make a legend for the 3 data sets plotted:
    $plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration'));
    # Turn off X tick labels and ticks because they don't apply here:
    $plot->SetXTickLabelPos('none');
    $plot->SetXTickPos('none');
    $plot->DrawGraph();
}
Exemplo n.º 6
0
<?php

/* $Id: inline_image.php,v 1.2 2004-05-04 15:23:45 alex Exp $ */
if (!isset($_GET['which_title'])) {
    echo <<<EOF
<pre>
           *************************************************
           * This file is meant to be called only from the *
           *                   <a href="test_setup.php">test page</a>                   *
           * It will fail if called by itself.             *
           *************************************************
</pre>
EOF;
    exit;
}
// From PHP 4.?, register_globals is off, take it into account (MBD)
include '../phplot.php';
$graph = new PHPlot();
include './data.php';
$graph->SetTitle("{$_GET['which_title']}");
$graph->SetDataValues($example_data);
$graph->SetIsInline('1');
$graph->SetFileFormat("{$_GET['which_format']}");
$graph->DrawGraph();
Exemplo n.º 7
0
<?php

///////////////////////////////////////////////
//This file is meant only to be called from the
//testing function quick_start.php. It will fail
//if called by itself.
//////////////////////////////////////////////
include "../phplot.php";
$graph = new PHPlot();
include "./data.php";
$graph->SetTitle("{$which_title}");
$graph->SetDataValues($example_data);
$graph->SetIsInline("1");
$graph->SetFileFormat("{$file_format}");
$graph->DrawGraph();
Exemplo n.º 8
0
 function plotfile_me($pdf, $mv_id, $w = 800, $h = 600)
 {
     $mvs = new mietvertraege();
     $mvs->get_mietvertrag_infos_aktuell($mv_id);
     $mk = new mietkonto();
     $datum_mietdefinition = $mk->datum_1_mietdefinition($mv_id);
     // echo "<h1>$datum_mietdefinition</h1>";
     $a_dat = explode('-', $datum_mietdefinition);
     $jahr_a = date("Y") - 2;
     $jahr_e = date("Y") + 3;
     $jahre = $jahr_e - $jahr_a;
     $z = 0;
     for ($jahr = $jahr_a; $jahr <= $jahr_e; $jahr++) {
         $monat = date("m");
         $mk->kaltmiete_monatlich($mv_id, $monat, $jahr);
         if ($jahr > $jahr_a) {
             $miete_vorjahr = $arr_stat[$z - 1][1];
             $prozent = ($mk->ausgangs_kaltmiete - $miete_vorjahr) / ($miete_vorjahr / 100);
         } else {
             $prozent = 0;
         }
         $prozent = nummer_punkt2komma($prozent);
         $arr_stat[$z][0] = "{$jahr}\n{$mk->ausgangs_kaltmiete}\nEUR\n{$prozent} %";
         $arr_stat[$z][1] = $mk->ausgangs_kaltmiete;
         $z++;
     }
     // print_r($arr_stat);
     require_once 'phplot.php';
     $plot = new PHPlot($w, $h);
     $plot->SetImageBorderType('plain');
     $plot->SetPlotType('bars');
     $plot->SetDataType('text-data');
     $plot->SetDataValues($arr_stat);
     // Main plot title:
     $plot->SetTitle('MIETENTWICKLUNG' . " {$mvs->einheit_kurzname} \n {$mvs->personen_name_string}");
     // No 3-D shading of the bars:
     $plot->SetShading(0);
     // Make a legend for the 3 data sets plotted:
     // $plot->SetLegend(array('Mieteinnahmen', 'Leerstand'));
     $plot->SetLegend(array('MIETE'));
     // Turn off X tick labels and ticks because they don't apply here:
     $plot->SetXTickLabelPos('none');
     $plot->SetXTickPos('none');
     // Draw it
     $plot->SetIsInline(true);
     $img = $plot->DrawGraph();
     $px = 'px';
     // echo "<hr>$plot->img ";
     // $plot->PrintImageFrame();
     // $hhh = $plot->PrintImage();
     $ima = $plot->EncodeImage();
     // echo "<a style=\"width:$w$px;heigth:$h$px;\" href=\"?option=stat_mv_big&mv_id=$mv_id\"><img style=\"width:$w$px;heigth:$h$px;\" src=\"$plot->img\"></img></a>";
     // die();
     // echo "<img src=\"$ima\">";
     // die();
     if ($mvs->mietvertrag_aktuell == 1) {
         $pdf->ezNewPage();
         $druckdatum = date("d.m.Y");
         $pdf->addText(464, 730, 7, "<b>Druckdatum: {$druckdatum}</b>");
         $pdf->addPngFromFile($ima, $pdf->x + 10, $pdf->y - $h, $w, $h);
     }
 }
Exemplo n.º 9
0
function BuatBarGraph($filetujuan, $prevtahun, $tahun, $arrStatusAplikan, $urutan, $gel)
{
    $arrPrevTotal = array();
    $arrCurTotal = array();
    FillArrayPeriod($arrPrevTotal, $arrStatusAplikan, $prevtahun, $gel);
    FillArrayPeriod($arrCurTotal, $arrStatusAplikan, $tahun, $gel);
    $maxPrevHeight = 0;
    $maxCurHeight = 0;
    foreach ($arrStatusAplikan as $stat) {
        $data[] = array($stat, $arrPrevTotal[$stat], $arrCurTotal[$stat]);
        $maxPrevHeight = $maxPrevHeight < $arrPrevTotal[$stat] ? $arrPrevTotal[$stat] : $maxPrevHeight;
        $maxCurHeight = $maxCurHeight < $arrCurTotal[$stat] ? $arrCurTotal[$stat] : $maxCurHeight;
    }
    $plot = new PHPlot(800, 600);
    //$plot->SetImageBorderType('raised');
    $plot->SetFont('y_label', 5);
    $plot->SetFont('x_label', 5);
    $plot->SetFont('title', 5);
    $plot->SetFont('legend', 5);
    $plot->setShading(10);
    $plot->SetPlotType('bars');
    $plot->SetDataType('text-data');
    $plot->SetDataValues($data);
    $plot->SetTitle('GRAFIK & DATA PMB GEL SISIPAN');
    $plot->SetLegend(array($prevtahun, $tahun));
    $plot->SetXTickLabelPos('none');
    $plot->SetXTickPos('none');
    $maxHeight = $maxPrevHeight < $maxCurHeight ? $maxCurHeight : $maxPrevHeight;
    $increment = $maxHeight <= 50 ? 5 : ($maxHeight <= 100 ? 10 : ($maxHeight <= 500 ? 50 : 100));
    $plot->SetYTickIncrement($increment);
    $plot->SetYDataLabelPos('plotin');
    $plot->SetIsInline(true);
    $plot->SetOutputFile($filetujuan);
    $plot->DrawGraph();
}
Exemplo n.º 10
0
function BuatPieGraph($filetujuan, $prevtahun, $tahun, $urutan, $gel)
{
    $fg = GetaField("pmb b left outer join pmbperiod p on b.PMBPeriodID=p.PMBPeriodID and b.KodeID=p.KodeID and LEFT(p.PMBPeriodID, 4)='{$tahun}'", "(b.TahunLulus='{$prevtahun}' or b.TahunLulus='{$tahun}') and b.KodeID", KodeID, "count(b.PMBID)");
    $nfg = GetaField("pmb b left outer join pmbperiod p on b.PMBPeriodID=p.PMBPeriodID and b.KodeID=p.KodeID and LEFT(p.PMBPeriodID, 4)='{$tahun}'", "b.TahunLulus < '{$prevtahun}' and b.KodeID", KodeID, "count(b.PMBID)");
    $data = array(array('Fresh Graduate', $fg), array('Non Fresh Graduate', $nfg));
    $plot = new PHPlot(800, 600);
    //$plot->SetImageBorderType('raised');
    $plot->SetPlotType('pie');
    $plot->SetDataType('text-data-single');
    $plot->SetDataValues($data);
    $plot->SetDataColors(array('red', 'blue', 'green', 'yellow', 'cyan', 'magenta', 'brown', 'lavender', 'pink', 'gray', 'orange'));
    $plot->setShading(60);
    $plot->SetLabelScalePosition(0.2);
    $plot->SetFont('generic', 5);
    $plot->SetFont('title', 5);
    $plot->SetFont('legend', 5);
    $plot->SetTitle("Persentase Calon Mahasiswa Fresh / non Fresh Graduate");
    foreach ($data as $row) {
        $plot->SetLegend(implode(': ', $row));
    }
    $plot->SetIsInline(true);
    $plot->SetOutputFile($filetujuan);
    $plot->DrawGraph();
}
Exemplo n.º 11
0
 function get_png($objekt_id, $monat, $jahr, $w = 300, $h = 200)
 {
     $monat = sprintf('%02d', $monat);
     include_once BERLUS_PATH . "/classes/phplot.php";
     $plot = new PHPlot($w, $h, "/tmp/plot_sanierung.png");
     $plot->SetImageBorderType('plain');
     $plot->SetPlotType('stackedbars');
     $plot->SetDataType('text-data');
     // $column_names = array('LEER VM', 'LEER NEU', 'IST WM','DIFF');
     $plot->SetShading(10);
     $plot->SetLegendReverse(True);
     // $plot->SetLegend($column_names);
     $oo = new objekt();
     $oo->get_objekt_infos($objekt_id);
     $anz_einheiten_alle = $oo->anzahl_einheiten_objekt($objekt_id);
     $datum_heute = "{$jahr}-{$monat}-01";
     $mi = new miete();
     $datum_vormonat = $mi->tage_minus($datum_heute, 30);
     $arr = $this->leerstand_finden_monat($objekt_id, $datum_vormonat);
     $anz_leer_vormonat = count($arr);
     // unset($arr);
     $arr_leer = $this->leerstand_finden_monat($objekt_id, $datum_heute);
     $anz_leer_akt = count($arr_leer);
     $anz_vermietet = $anz_einheiten_alle - $anz_leer_akt;
     $leere = $this->array_intersect_recursive($arr_leer, $arr, 'EINHEIT_KURZNAME');
     $vermietete = $this->array_intersect_recursive($arr, $arr_leer, 'EINHEIT_KURZNAME');
     $leer_akt_string = '';
     $anz__L = count($leere);
     if ($anz__L > 0) {
         for ($ee = 0; $ee < $anz__L; $ee++) {
             $leer_akt_string .= $leere[$ee] . "\n";
         }
     }
     $vermietet_akt_string = '';
     $anz__V = count($vermietete);
     // print_r($vermietete);
     if ($anz__V > 0) {
         for ($ee = 0; $ee < $anz__V; $ee++) {
             $vermietet_akt_string .= $vermietete[$ee] . "\n";
         }
     }
     // unset($arr);
     /*
      * $mvs = new mietvertraege;
      * $anz_ausgezogene = $mvs->anzahl_ausgezogene_mieter($objekt_id, $jahr, $monat);
      * $anz_eingezogene = $mvs->anzahl_eingezogene_mieter($objekt_id, $jahr, $monat);
      */
     $bilanz_akt = $anz__V - $anz__L;
     // 0-1 = -1;
     $z = 0;
     /*
      * $data[$z][] = "ALLE\nAKTUELL";
      * $data[$z][] = $anz_einheiten_alle;
      *
      * $data[$z][] = 0;
      * $data[$z][] = 0;
      *
      */
     // $z++;
     /*
      * $data[$z][] = "LEER\nVERM.";
      * $data[$z][] = 0;
      * $data[$z][] = $anz_vermietet;
      * $data[$z][] = $anz_leer_akt;
      */
     $data[$z][] = "VOR-\nMONAT";
     $data[$z][] = 0;
     $data[$z][] = $anz_leer_vormonat;
     $z++;
     $data[$z][] = "LEER-\nAKTUELL";
     $data[$z][] = 0;
     $data[$z][] = 0;
     $data[$z][] = $anz_leer_akt;
     $z++;
     $data[$z][] = "LEER\n\n{$leer_akt_string}";
     $data[$z][] = '0';
     $data[$z][] = '0';
     $data[$z][] = $anz__L;
     $z++;
     $data[$z][] = "VERM.\n\n{$vermietet_akt_string}";
     $data[$z][] = '0';
     $data[$z][] = $anz__V;
     $z++;
     $data[$z][] = "BILANZ\nEIN/AUS";
     if ($bilanz_akt < 0) {
         $data[$z][] = 0;
         $data[$z][] = 0;
         $data[$z][] = 0;
         $data[$z][] = 0;
         $data[$z][] = $bilanz_akt;
     } else {
         $data[$z][] = 0;
         $data[$z][] = $bilanz_akt;
     }
     // $z++;
     $plot->SetYDataLabelPos('plotstack');
     $plot->SetDataValues($data);
     // Main plot title:
     $plot->SetTitle("{$oo->objekt_kurzname} {$monat}/{$jahr}");
     // No 3-D shading of the bars:
     $plot->SetShading(0);
     // Make a legend for the 3 data sets plotted:
     // $plot->SetLegend(array('Mieteinnahmen', 'Leerstand'));
     // $plot->SetLegend(array('MIETE'));
     // Turn off X tick labels and ticks because they don't apply here:
     $plot->SetXTickLabelPos('none');
     $plot->SetXTickPos('none');
     // Draw it
     $plot->SetIsInline(true);
     $plot->DrawGraph();
     // echo "<hr>$plot->img ";
     // $plot->PrintImageFrame();
     // $ima = $plot->PrintImage();
     $ima = $plot->EncodeImage();
     // ob_clean();
     return $ima;
     // echo "<img src=\"$ima\"></img>";
 }
Exemplo n.º 12
0
function plot_guifi()
{
    include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php';
    $result = db_query("select COUNT(*) as num, MONTH(FROM_UNIXTIME(timestamp_created)) as mes, YEAR(FROM_UNIXTIME(timestamp_created)) as ano from {guifi_location} where status_flag='Working' GROUP BY YEAR(FROM_UNIXTIME(timestamp_created)),MONTH(FROM_UNIXTIME(timestamp_created)) ");
    $inicial = 5;
    $nreg = $inicial;
    $tot = 0;
    $ano = 2004;
    $mes = 5;
    $items = 2004;
    $label = "";
    while ($record = db_fetch_object($result)) {
        if ($record->ano >= 2004) {
            if ($mes == 12) {
                $mes = 1;
                $ano++;
            } else {
                $mes++;
            }
            while ($ano < $record->ano || $mes < $record->mes) {
                $nreg++;
                if ($mes == 6) {
                    $label = $ano;
                } else {
                    $label = '';
                }
                $data[] = array("{$label}", $nreg, $tot, '');
                if ($mes == 12) {
                    $mes = 1;
                    $ano++;
                } else {
                    $mes++;
                }
            }
            $tot += $record->num;
            $nreg++;
            if ($mes == 6) {
                $label = $ano;
            } else {
                $label = '';
            }
            $data[] = array("{$label}", $nreg, $tot, '');
        } else {
            $tot += $record->num;
        }
    }
    while ($mes < 12) {
        $nreg++;
        $mes++;
        if ($mes == 6) {
            $label = $ano;
        } else {
            $label = '';
        }
        $data[] = array("{$label}", $nreg, "");
    }
    $items = ($ano - $items + 1) * 12;
    if ($tot % 1000 < 30) {
        $data[$nreg - $inicial - 1][3] = $tot;
        $vt = floor($tot / 1000) * 1000;
        $vtitle = $vt . " " . t('Nodes') . "!!!";
        $tcolor = 'red';
    } else {
        $vtitle = t('Working nodes');
        $tcolor = 'DimGrey';
    }
    $shapes = array('none', 'circle');
    $plot = new PHPlot(200, 150);
    $plot->SetPlotAreaWorld(0, 0, $items, NULL);
    $plot->SetFileFormat('png');
    $plot->SetDataType("data-data");
    $plot->SetDataValues($data);
    $plot->SetPlotType("linepoints");
    $plot->SetYTickIncrement(2000);
    $plot->SetXTickIncrement(12);
    $plot->SetSkipBottomTick(TRUE);
    $plot->SetSkipLeftTick(TRUE);
    $plot->SetXAxisPosition(0);
    $plot->SetPointShapes($shapes);
    $plot->SetPointSizes(10);
    $plot->SetTickLength(3);
    $plot->SetDrawXGrid(TRUE);
    $plot->SetTickColor('grey');
    $plot->SetTitle($vtitle);
    $plot->SetDrawXDataLabelLines(FALSE);
    $plot->SetXLabelAngle(0);
    $plot->SetXLabelType('custom', 'Plot1_LabelFormat');
    $plot->SetGridColor('red');
    $plot->SetPlotBorderType('left');
    $plot->SetDataColors(array('orange'));
    $plot->SetTextColor('DimGrey');
    $plot->SetTitleColor($tcolor);
    $plot->SetLightGridColor('grey');
    $plot->SetBackgroundColor('white');
    $plot->SetTransparentColor('white');
    $plot->SetXTickLabelPos('none');
    $plot->SetXDataLabelPos('plotdown');
    $plot->SetIsInline(TRUE);
    $plot->DrawGraph();
}
Exemplo n.º 13
0
for ($i = 1; $i <= 10; $i++) {
    //math
    $quejas = 0;
    $num = $i;
    $texto = $i;
    $data1[$key] = array($texto, $num);
    $key++;
    $c++;
}
$plot = new PHPlot();
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetShading(0);
$plot->SetDataValues($data1);
$plot->SetFileFormat('png');
$plot->SetIsInline(true);
$plot->PHPlot(1200, 550, "images/tmp/img7.png");
$plot->DrawGraph();
$img7 = "images/tmp/img7.png";
//en consesionario
/** PDF **/
$pdf = new FPDF('L', 'mm', 'Letter');
$title = 'Incidencias Generales';
$pdf->SetTitle($title);
$pdf->SetAuthor('Loop Media');
$pdf->AddPage();
//bg
$pdf->Image('images/pdf_bg.jpg', 0, 0, $pdf->w, $pdf->h);
//tittulo
$pdf->SetFont('Times', '', 42);
$pdf->SetTextColor(250, 250, 250);
Exemplo n.º 14
0
<?php

# $Id$
# PHPlot error test - argument error with returning handler, redo the graph.
require 'esupport.php';
set_error_handler('test_catch_return');
require_once 'phplot.php';
$data = array(array('a', 1, 1), array('b', 2, 3), array('c', 3, 5));
$plot = new PHPlot();
# Don't do any output of the error image:
$plot->SetIsInline(True);
$plot->SetOutputFile('/dev/null');
if (!$plot->SetDataType('data-text')) {
    restore_error_handler();
    fwrite(STDERR, "Return after error. Destroy object and try again\n");
    unset($plot);
    $plot = new PHPlot();
    $plot->SetDataType('data-data');
}
$plot->SetDataValues($data);
$plot->SetPlotType('lines');
$plot->SetOutputFile('');
$plot->DrawGraph();
Exemplo n.º 15
0
/**
 * drawing the graph for a evaluation question
 *
 * @param array() $data
 * @param string $evalquestion_id
 */
function do_graph($data, $evalquestion_id)
{
    global $tmp_path_export, $auth, $PATH_EXPORT;
    $type = do_graph_template();
    //Define the object
    if ($type == "pie") {
        // Beim pie muss die Zeichenflaeche etwas groesser gewaehlt werden...
        $graph = new PHPlot(500, 300);
    } else {
        $graph = new PHPlot(300, 250);
    }
    if ($type == "pie") {
        // Beim pie muss das Array umgeformt werden. Bug in PHPlot?
        $tmp = array();
        $tmp2 = array();
        $legend = array();
        array_push($tmp, "Test");
        foreach ($data as $k => $d) {
            array_push($tmp, $d[1]);
            array_push($legend, $d[0]);
        }
        array_push($tmp2, $tmp);
        $data = $tmp2;
        $graph->SetLegend($legend);
    }
    //Data Colors
    $graph->SetDataColors(array("blue", "green", "yellow", "red", "PeachPuff", "orange", "pink", "lavender", "navy", "peru", "salmon", "maroon", "magenta", "orchid", "ivory"), array("black"));
    $max_x = max(array_map('next', $data));
    $graph->SetPlotAreaWorld(NULL, 0);
    // y-achse bei 0 starten
    $graph->SetPrecisionY(0);
    //anzahl kommastellen y-achse
    $graph->SetYTickIncrement($max_x < 10 ? 1 : round($max_x / 10));
    $graph->SetPlotBgColor(array(222, 222, 222));
    $graph->SetDataType("text-data");
    $graph->SetFileFormat(Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT);
    $graph->SetOutputFile($tmp_path_export . "/evalsum" . $evalquestion_id . $auth->auth["uid"] . "." . Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT);
    $graph->SetIsInline(true);
    $graph->SetDataValues($data);
    $graph->SetPlotType($type);
    $graph->SetXLabelAngle(count($data) < 10 ? 0 : 90);
    //$graph->SetShading(0); // kein 3D
    $graph->SetLineWidth(1);
    $graph->SetDrawXDataLabels(true);
    //Draw it
    $graph->DrawGraph();
}
Exemplo n.º 16
0
function guifi_stats_chart07()
{
    include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php';
    $gDirTTFfonts = drupal_get_path('module', 'guifi') . '/contrib/fonts/';
    if (isset($_GET['width'])) {
        $gwidth = $_GET['width'];
    } else {
        $gwidth = 500;
    }
    if (isset($_GET['height'])) {
        $gheight = $_GET['height'];
    } else {
        $gheight = 450;
    }
    $today = getdate();
    $year = $today[year];
    $month = $today[mon];
    $month = $month - 12;
    $n = 0;
    $tot = 0;
    if ($month < 1) {
        $year = $year - 1;
        $month = 12 + $month;
    }
    $datemin = mktime(0, 0, 0, $month, 1, $year);
    if (isset($_GET['zone'])) {
        $zone_id = $_GET['zone'];
        if ($zone_id == "0") {
            $zone_id = "0";
        }
        //"3671";
    } else {
        $zone_id = "0";
    }
    $avalue = array();
    $adata = array();
    for ($i = 0; $i < 10; $i++) {
        $adata[] = array(0, 0);
    }
    $vsql = "select sum(if(timestamp_created >= " . $datemin . ",1,0)) as num, count(*) as total, zone_id\n      from {guifi_location}\n      where status_flag='Working' ";
    if ($zone_id != "0") {
        $achilds = guifi_zone_childs($zone_id);
        $v = "";
        foreach ($achilds as $key => $child) {
            if ($v == "") {
                $v .= "zone_id=" . $child;
            } else {
                $v .= " or zone_id=" . $child;
            }
        }
        $vsql .= "AND (" . $v . ") ";
    }
    $vsql .= "GROUP BY zone_id ";
    $result = db_query($vsql);
    while ($record = db_fetch_object($result)) {
        if ($record->total >= 20) {
            $vn = $record->num / $record->total * 100;
            $vmin = 0;
            for ($i = 1; $i < 10; $i++) {
                if ($adata[$vmin][1] > $adata[$i][1]) {
                    $vmin = $i;
                }
            }
            if ($vn > $adata[$vmin][1]) {
                $adata[$vmin][0] = $record->zone_id;
                $adata[$vmin][1] = $vn;
            }
        }
    }
    for ($i = 0; $i < 10; $i++) {
        if ($adata[$i][1] != 0) {
            $avalue[$adata[$i][0]] = $adata[$i][1];
        }
    }
    arsort($avalue);
    foreach ($avalue as $key => $value) {
        if ($value != 0) {
            $data[] = array(substr(guifi_get_zone_name($key), 0, 20) . "  �", $value);
        }
    }
    $shapes = array('none');
    $plot = new PHPlot($gwidth, $gheight);
    $plot->SetPlotAreaWorld(0, 0, NULL, NULL);
    $plot->SetFileFormat('png');
    $plot->SetDataType("text-data");
    $plot->SetDataValues($data);
    $plot->SetPlotType("bars");
    $plot->SetXTickIncrement(1);
    $plot->SetSkipBottomTick(TRUE);
    $plot->SetSkipLeftTick(TRUE);
    $plot->SetTickLength(0);
    //$plot->SetXTickPos('none');
    $plot->SetYDataLabelPos('plotin');
    $plot->SetYLabelType('data', 0);
    $plot->SetTickColor('grey');
    $plot->SetTTFPath($gDirTTFfonts);
    $plot->SetFontTTF('title', 'Vera.ttf', 12);
    $plot->SetFontTTF('x_label', 'Vera.ttf', 8);
    if (isset($_GET['title'])) {
        $plot->SetTitle("guifi.net      \n" . t($_GET['title']));
    } else {
        if ($zone_id == "0") {
            $plot->SetTitle("guifi.net      \n" . t('Largest annual increase'));
        } else {
            $plot->SetTitle("guifi.net    " . t('zone') . ": " . guifi_get_zone_name($zone_id) . "\n" . t('Largest annual increase'));
        }
    }
    //$plot->SetXTitle(t('Zones'));
    $plot->SetYTitle(t('% increase'));
    $plot->SetXDataLabelPos('plotdown');
    //$plot->SetXLabelAngle(45);
    $plot->SetXDataLabelAngle(75);
    $plot->SetGridColor('red');
    $plot->SetPlotBorderType('left');
    $plot->SetDataColors(array('orange'));
    $plot->SetTextColor('DimGrey');
    $plot->SetTitleColor('DimGrey');
    $plot->SetLightGridColor('grey');
    $plot->SetBackgroundColor('white');
    $plot->SetTransparentColor('white');
    $plot->SetIsInline(TRUE);
    $plot->DrawGraph();
}
Exemplo n.º 17
0
  license@systemsmanager.net so we can mail you a copy immediately.
*/
include DIR_WS_CLASSES . 'phplot.php';
$year = $_GET['year'] ? $_GET['year'] : date('Y');
$month = $_GET['month'] ? $_GET['month'] : date('n');
$days = date('t', mktime(0, 0, 0, $month)) + 1;
$stats = array();
for ($i = 1; $i < $days; $i++) {
    $stats[] = array($i, '0', '0');
}
$banner_stats_query = smn_db_query("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . "'");
while ($banner_stats = smn_db_fetch_array($banner_stats_query)) {
    $stats[$banner_stats['banner_day'] - 1] = array($banner_stats['banner_day'], $banner_stats['value'] ? $banner_stats['value'] : '0', $banner_stats['dvalue'] ? $banner_stats['dvalue'] : '0');
}
$graph = new PHPlot(600, 350, 'images/graphs/banner_daily-' . $banner_id . '.' . $banner_extension);
$graph->SetFileFormat($banner_extension);
$graph->SetIsInline(1);
$graph->SetPrintImage(0);
$graph->SetSkipBottomTick(1);
$graph->SetDrawYGrid(1);
$graph->SetPrecisionY(0);
$graph->SetPlotType('lines');
$graph->SetPlotBorderType('left');
$graph->SetTitleFontSize('4');
$graph->SetTitle(sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0, 0, 0, $month)), $year));
$graph->SetBackgroundColor('white');
$graph->SetVertTickPosition('plotleft');
$graph->SetDataValues($stats);
$graph->SetDataColors(array('blue', 'red'), array('blue', 'red'));
$graph->DrawGraph();
$graph->PrintImage();
	/**
	* Generate a graph for this tag
	* @param string $tag
	* @param string $filePath
	* @return bool, success
	*/
	public function makePngGraph( $tag, $filePath ) {
		if( !function_exists( 'ImageCreate' ) ) {
			// GD is not installed
			return false;
		}
		global $wgPHPlotDir, $wgMemc;
		require_once( "$wgPHPlotDir/phplot.php" ); // load classes
		// Define the object
		$plot = new PHPlot( 1000, 400 );
		// Set file path
		$dir = dirname($filePath);
		// Make sure directory exists
		if( !file_exists($dir) && !wfMkdirParents( $dir, 0777, __METHOD__ ) ) {
			throw new MWException( 'Could not create file directory!' );
		}
		$plot->SetOutputFile( $filePath );
		$plot->SetIsInline( true );
		$data = array();
		$totalVal = $totalCount = $n = 0;
		// Define the data using the DB rows
		list($res,$u,$maxC,$days) = $this->doQuery( $tag );
		if( !$maxC ) {
			return false;
		}
		// Label spacing
		$int = intval( ceil($days/10) ); // 10 labels at most
		foreach( $res as $row ) {
			$totalVal += (int)$row->rfh_total;
			$totalCount += (int)$row->rfh_count;
			$dayCount = (real)$row->rfh_count;
			if( !$row->rfh_count ) {
				continue; // bad data
			}
			// Nudge values up by 1
			$dayAve = 1 + (real)$row->rfh_total/(real)$row->rfh_count;
			$cumAve = 1 + (real)$totalVal/(real)$totalCount;
			$year = intval( substr( $row->rfh_date, 0, 4 ) );
			$month = intval( substr( $row->rfh_date, 4, 2 ) );
			$day = intval( substr( $row->rfh_date, 6, 2 ) );
			# Fill in days with no votes to keep spacing even
			if( isset($lastDate) ) {
				$dayGap = wfTimestamp(TS_UNIX,$row->rfh_date) - wfTimestamp(TS_UNIX,$lastDate);
				$x = intval( $dayGap/86400 );
				# Day gaps...
				for( $x; $x > 1; --$x ) {
					$data[] = array("",$lastDAve,$lastRAve,0);
					$n++;
				}
			}
			$n++;
			# Label point?
			if( $n >= $int || !count($data) ) {
				$p = ($days > 31) ? "{$month}-".substr( $year, 2, 2 ) : "{$month}/{$day}";
				$n = 0;
			} else {
				$p = "";
			}
			$data[] = array( $p, $dayAve, $cumAve, $dayCount );
			$lastDate = $row->rfh_date;
			$lastDAve = $dayAve;
			$lastRAve = $cumAve;
		}
		// Minimum sample size
		if( count($data) < 2 ) {
			return false;
		}
		// Re-scale voter count to fit to graph
		$this->dScale = ceil($maxC/5);
		// Cache the scale value to memory
		$key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period );
		$wgMemc->set( $key, $this->dScale, 7*24*3600 );
		// Fit to [0,4]
		foreach( $data as $x => $dataRow ) {
			$data[$x][3] = $dataRow[3]/$this->dScale;
		}
		$plot->SetDataValues($data);
		$plot->SetPointShapes( array('dot','dot','dot') );
		$plot->setPointSizes( array(1,1,4) );
		$plot->SetDataColors( array('blue','green','red') );
		$plot->SetLineStyles( array('solid','solid','solid') );
		$plot->SetBackgroundColor('#F8F8F8');
		// Turn off X axis ticks and labels because they get in the way:
		$plot->SetXTickLabelPos('none');
		$plot->SetXTickPos('none');
		$plot->SetYTickIncrement( .5 );
		// Set plot area
		$plot->SetPlotAreaWorld( 0, 0, null, 5 );
		// Show total number of votes
		$plot->SetLegend( array("#{$totalCount}") );
		// Draw it!
		$plot->DrawGraph();
		return true;
	}