コード例 #1
0
ファイル: phplotbars.php プロジェクト: SuichiesS/homewatch
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();
}
コード例 #2
0
 function costo_externo_interno_año($id_oficina, $año)
 {
     $this->autoLayout = false;
     $this->autoRender = false;
     $this->loadModel('CentroCosto');
     $sql_oficina = '';
     if ($id_oficina != 0) {
         $sql_oficina = " AND Cencos_id='" . $id_oficina . "' ";
         $cenco = $this->CentroCosto->find('first', array('fields' => array('CentroCosto.Cencos_nombre'), 'conditions' => array('CentroCosto.Cencos_id' => $id_oficina)));
         $subtitulo_oficina = 'la dependencia ' . mb_convert_case($cenco['CentroCosto']['Cencos_nombre'], MB_CASE_TITLE, "UTF-8");
     } else {
         $subtitulo_oficina = 'todas las dependencias';
     }
     $meses = $this->Solicitud->query("SELECT MONTH(solucionada) AS mes FROM solicitudes WHERE estado='s' " . $sql_oficina . " AND YEAR(solucionada)=" . $año . " GROUP BY MONTH(solucionada)");
     if (!empty($meses)) {
         // Inicializamos el arreglo en ceros (para los meses ke no tienen solicitudes).
         $totales = array();
         for ($i = 1; $i <= 12; $i++) {
             $totales[$i][0][0] = array('costo_i' => 0, 'costo_e' => 0);
         }
         foreach ($meses as $mes) {
             $costos_e_i = $this->Solicitud->query("SELECT SUM(costo_externo) AS costo_e, SUM(costo_interno) AS costo_i FROM solicitudes WHERE estado='s' AND YEAR(solucionada)=" . $año . " AND MONTH(solucionada)=" . $mes[0]['mes']);
             $totales[$mes[0]['mes']] = $costos_e_i;
         }
         if (!empty($totales)) {
             $total_costo_interno = $total_costo_externo = 0;
             $i = 0;
             $arreglo_plot = array();
             foreach ($totales as $mes => $arreglo_mes) {
                 // se construye el array para el PHPlot.
                 if (count($arreglo_mes) > 0) {
                     $arreglo_plot[$i] = array($this->meses[$mes], $arreglo_mes[0][0]['costo_i'], $arreglo_mes[0][0]['costo_e']);
                     $total_costo_interno += $arreglo_mes[0][0]['costo_i'];
                     $total_costo_externo += $arreglo_mes[0][0]['costo_e'];
                 } else {
                     $arreglo_plot[$i] = array($this->meses[$mes], 0, 0);
                 }
                 $i++;
             }
             $plot = new PHPlot(1790, 500);
             $plot->SetDataValues($arreglo_plot);
             $plot->SetDataType('text-data');
             // Fuentes
             $plot->SetUseTTF(true);
             $plot->SetFontTTF('legend', 'FreeSans.ttf', 9);
             $plot->SetFontTTF('title', 'FreeSans.ttf', 14);
             $plot->SetFontTTF('y_label', 'FreeSans.ttf', 9);
             $plot->SetFontTTF('x_label', 'FreeSans.ttf', 10);
             $plot->SetFontTTF('y_title', 'FreeSans.ttf', 14);
             $plot->SetFontTTF('x_title', 'FreeSans.ttf', 12);
             // Titulos
             $plot->SetTitle("\nTotal de costos internos/externos\n" . "de " . $subtitulo_oficina . " en el año " . $año . "\n TOTAL Costo Interno = \$" . $total_costo_interno . "\n" . "TOTAL Costo Externo = \$" . $total_costo_externo);
             $plot->SetYTitle('$ COSTO');
             // Etiquetas
             $plot->SetXTickLabelPos('none');
             $plot->SetXTickPos('none');
             $plot->SetYTickLabelPos('none');
             $plot->SetYTickPos('none');
             $plot->SetYDataLabelPos('plotin');
             $plot->SetDrawXGrid(true);
             // Leyenda
             $leyenda = array('Costo Interno', 'Costo Externo');
             $plot->SetLegend($leyenda);
             $plot->SetLegendPixels(27, 0);
             $plot->SetDataColors(array('beige', 'YellowGreen'));
             $plot->SetPlotType('bars');
             $plot->SetShading(5);
             $plot->DrawGraph();
         }
     }
 }
コード例 #3
0
ファイル: SalesGraph.php プロジェクト: rrsc/KwaMoja
 $graph->SetXTitle(_('Month'));
 if ($_POST['GraphValue'] == 'Net') {
     $graph->SetYTitle(_('Sales Value'));
 } elseif ($_POST['GraphValue'] == 'GP') {
     $graph->SetYTitle(_('Gross Profit'));
 } else {
     $graph->SetYTitle(_('Quantity'));
 }
 $graph->SetXTickPos('none');
 $graph->SetXTickLabelPos('none');
 $graph->SetBackgroundColor('white');
 $graph->SetTitleColor('blue');
 $graph->SetFileFormat('png');
 $graph->SetPlotType($_POST['GraphType']);
 $graph->SetIsInline('1');
 $graph->SetShading(5);
 $graph->SetDrawYGrid(TRUE);
 $graph->SetDataType('text-data');
 $SalesResult = DB_query($SQL, $db);
 if (DB_error_no($db) != 0) {
     prnMsg(_('The sales graph data for the selected criteria could not be retrieved because') . ' - ' . DB_error_msg($db), 'error');
     include 'includes/footer.inc';
     exit;
 }
 if (DB_num_rows($SalesResult) == 0) {
     prnMsg(_('There is not sales data for the criteria entered to graph'), 'info');
     include 'includes/footer.inc';
     exit;
 }
 $GraphArrays = array();
 $i = 0;
コード例 #4
0
ファイル: stackedbars.php プロジェクト: myfarms/PHPlot
}
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('stackedbars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
if ($tp['compat']) {
    # backward compatible mode
    $plot->SetTitle('Candy Sales by Month and Product');
    $plot->SetYTitle('Millions of Units');
    $plot->SetLegend(array('Chocolates', 'Mints', 'Hard Candy', 'Sugar-Free'));
} else {
    $plot->SetTitle($tp['title'] . $tp['suffix']);
    $plot->SetXTitle('Month');
    $plot->SetYTitle('Number of Units');
}
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
if (isset($tp['shading'])) {
    $plot->SetShading($tp['shading']);
}
if (isset($tp['xaxispos'])) {
    $plot->SetXAxisPosition($tp['xaxispos']);
}
if (isset($tp['ydatalabel'])) {
    $plot->SetYDataLabelPos($tp['ydatalabel']);
}
if (isset($tp['custom'])) {
    call_user_func($tp['custom'], $plot);
}
$plot->DrawGraph();
コード例 #5
0
function bcond($name, $var)
{
    return $name . ": " . ($var ? "True" : "False") . "\n";
}
$data = array(array('A', 10, 20, 30, 40, 50, 60, 70, 80, 90, 100), array('B', 10, 20, 30, 40, 50, 60, 70, 80, 90, 100), array('C', 10, 20, 30, 40, 50, 60, 70, 80, 90, 100));
$n_cols = count($data[0]) - 1;
for ($i = 0; $i < $n_cols; $i++) {
    $legend[$i] = "== Row {$i} ==";
}
$title = "Legend Colorbox Borders Control\n" . cond("Color box borders: ", $tp['colorboxborders']) . cond("Color box width factor: ", $tp['colorboxwidth']) . bcond("Set Data Border Colors", $tp['setdbcolors']) . bcond("Set Text Color", $tp['settextcolor']);
$p = new PHPlot(800, 600);
$p->SetTitle($title);
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotType('bars');
$p->SetShading(0);
// Unshaded so borders can be seen
$p->SetLegend($legend);
$p->SetLegendPosition(0, 0, 'plot', 0, 0, 5, 5);
if (isset($tp['colorboxborders'])) {
    $p->SetLegendColorboxBorders($tp['colorboxborders']);
}
if (isset($tp['colorboxwidth'])) {
    $p->legend_colorbox_width = $tp['colorboxwidth'];
}
if ($tp['setdbcolors']) {
    $p->SetDataBorderColors(array('red', 'green', 'blue'));
}
if ($tp['settextcolor']) {
    $p->SetTextColor('blue');
}
コード例 #6
0
<?php

require '../phplot/phplot.php';
include_once '../conecta_banco.php';
include_once '../funcoes_banco.php';
include_once '../funcoes_auxiliares.php';
$sql = "SELECT cardapio.nome_produto, sum(cardapio_comanda.quantidade) as somatorio\n            FROM cardapio_comanda\n            INNER JOIN cardapio\n                ON cardapio_comanda.id_cardapio = cardapio.id_produto\n            GROUP BY id_cardapio";
$res = mysql_query($sql);
// nome_produto, id_cardapio, somatorio
$resultArr = resultadosParaArray($res);
$plot = new PHPlot();
$data = $resultArr;
$plot->SetDataValues($data);
$plot->SetDataType('text-data');
// legenda texto-numero
$plot->SetPlotType('bars');
// barras
$plot->SetTitle("Produtos Consumidos");
$plot->SetXTitle('Produtos');
$plot->SetYTitle('Quantidade');
$plot->SetYDataLabelPos('plotin');
// imprime o valor acima do grafico
$plot->SetShading(1);
// deixa os graficos 2d
$plot->SetXTickPos('none');
// retira os ticks na linha x
$plot->SetYTickIncrement(1);
// define o incremento de 1 em 1
header("Content-type: image/png");
$plot->DrawGraph();
コード例 #7
0
ファイル: bars-datalabel.php プロジェクト: myfarms/PHPlot
        $row = array("={$grp}=");
        for ($bar = 1; $bar <= $tp['nbars']; $bar++) {
            $row[] = floor($x + 0.5);
            $tx = $x * $cdt - $y * $sdt;
            $y = $x * $sdt + $y * $cdt;
            $x = $tx;
        }
        $data[] = $row;
    }
}
$p = new PHPlot(800, 600);
$p->SetTitle($tp['title'] . $tp['suffix']);
$p->SetDataType('text-data');
$p->SetDataValues($data);
# Options:
#  Note: <=5.0rc3 used x_label font. This was corrected.
if (isset($tp['fontsize'])) {
    $p->SetFont('y_label', $tp['fontsize']);
}
if (isset($tp['shading'])) {
    $p->SetShading($tp['shading']);
}
# Note: This didn't work <= 5.0rc3
if (isset($tp['yprec'])) {
    $p->SetPrecisionY($tp['yprec']);
}
$p->SetXTickLabelPos('none');
$p->SetXTickPos('none');
$p->SetYDataLabelPos('plotin');
$p->SetPlotType('bars');
$p->DrawGraph();
コード例 #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);
     }
 }
コード例 #9
0
ファイル: horizbar.php プロジェクト: myfarms/PHPlot
# PHPlot Example - Horizontal Bars
require_once 'phplot.php';
$data = array(array('San Francisco CA', 20.11), array('Reno NV', 7.5), array('Phoenix AZ', 8.300000000000001), array('New York NY', 49.7), array('New Orleans LA', 64.2), array('Miami FL', 52.3), array('Los Angeles CA', 13.2), array('Honolulu HI', 18.3), array('Helena MT', 11.3), array('Duluth MN', 31.0), array('Dodge City KS', 22.4), array('Denver CO', 15.8), array('Burlington VT', 36.1), array('Boston MA', 42.5), array('Barrow AL', 4.2));
$plot = new PHPlot(800, 800);
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->SetTitle("Average Annual Precipitation (inches)\n" . "Selected U.S. Cities");
$plot->SetBackgroundColor('gray');
#  Set a tiled background image:
$plot->SetPlotAreaBgImage('images/drop.png', 'centeredtile');
#  Force the X axis range to start at 0:
$plot->SetPlotAreaWorld(0);
#  No ticks along Y axis, just bar labels:
$plot->SetYTickPos('none');
#  No ticks along X axis:
$plot->SetXTickPos('none');
#  No X axis labels. The data values labels are sufficient.
$plot->SetXTickLabelPos('none');
#  Turn on the data value labels:
$plot->SetXDataLabelPos('plotin');
#  No grid lines are needed:
$plot->SetDrawXGrid(FALSE);
#  Set the bar fill color:
$plot->SetDataColors('salmon');
#  Use less 3D shading on the bars:
$plot->SetShading(2);
$plot->SetDataValues($data);
$plot->SetDataType('text-data-yx');
$plot->SetPlotType('bars');
$plot->DrawGraph();
コード例 #10
0
 function solicitudes_reparacion_por_operario($id_operario, $año)
 {
     $this->loadModel('ReparacionSolicitud');
     $this->loadModel('Funcionario');
     $meses = $this->ReparacionSolicitud->query("SELECT MONTH(archivada) AS mes FROM reparacion_solicitudes WHERE estado='a' AND ejecutada=1 AND YEAR(archivada)=" . $año . " GROUP BY MONTH(archivada)");
     if (!empty($meses)) {
         // Inicializamos el arreglo en ceros (para los meses ke no tienen solicitudes).
         $total = array();
         for ($i = 1; $i <= 12; $i++) {
             $total[$i][0][0] = array('cuenta' => 0);
         }
         foreach ($meses as $mes) {
             $cant_solicitudes = $this->ReparacionSolicitud->query("SELECT COUNT(*) AS cuenta FROM reparacion_solicitudes WHERE id_funcionario=" . $id_operario . " AND estado='a' AND ejecutada=1 AND YEAR(archivada)=" . $año . " AND MONTH(archivada)=" . $mes[0]['mes']);
             $total[$mes[0]['mes']] = $cant_solicitudes;
         }
         if (!empty($total)) {
             $operario = $this->Funcionario->find('first', array('conditions' => array('Funcionario.id' => $id_operario), 'fields' => array('Funcionario.nombre')));
             foreach ($total as $mes => $arreglo_mes) {
                 $arreglo_plot[] = array($this->meses[$mes], $arreglo_mes[0][0]['cuenta']);
             }
             $plot = new PHPlot(890, 450);
             $plot->SetDataValues($arreglo_plot);
             $plot->SetDataType('text-data');
             // Fuentes
             $plot->SetUseTTF(true);
             $plot->SetFontTTF('legend', 'FreeSans.ttf', 9);
             $plot->SetFontTTF('title', 'FreeSans.ttf', 14);
             $plot->SetFontTTF('y_label', 'FreeSans.ttf', 10);
             $plot->SetFontTTF('x_label', 'FreeSans.ttf', 10);
             $plot->SetFontTTF('y_title', 'FreeSans.ttf', 14);
             // Titulos
             $plot->SetTitle("\nSolicitudes de reparación\natendidas por " . mb_convert_case($operario['Funcionario']['nombre'], MB_CASE_TITLE, "UTF-8"));
             $plot->SetXTitle('AÑO ' . $año);
             $plot->SetYTitle('# SOLICITUDES');
             // Etiquetas
             $plot->SetXTickLabelPos('none');
             $plot->SetXTickPos('none');
             $plot->SetYTickLabelPos('none');
             $plot->SetYTickPos('none');
             $plot->SetYDataLabelPos('plotin');
             $plot->SetDrawXGrid(true);
             // Leyenda
             $leyenda = array('Solicitudes de Reparación');
             $plot->SetLegend($leyenda);
             $plot->SetLegendPixels(703, 0);
             $plot->SetPlotType('bars');
             $plot->SetShading(7);
             $plot->DrawGraph();
         }
     }
 }
コード例 #11
0
ファイル: statistics_graph.php プロジェクト: danorama/orsee
 foreach ($plot_defaults as $key => $value) {
     if (!isset($stat[$key])) {
         $stat[$key] = $value;
     }
 }
 //Define the object
 $graph = new PHPlot($stat['xsize'], $stat['ysize']);
 $graph->SetDataType($stat['data_type']);
 $graph->SetFileFormat($stat['file_format']);
 $graph->SetPlotType($stat['graphtype']);
 $graph->SetDefaultTTFont('../tagsets/fonts/FreeSerif.ttf');
 $graph->SetPlotBorderType('none');
 // plotleft, plotright, both, full, none
 $graph->SetBackgroundColor($stat['background_color']);
 if ($stat['graphtype'] == 'bars') {
     $graph->SetShading(0);
     $graph->SetPlotAreaWorld(NULL, 0);
 }
 if (count($stat['legend']) > 0) {
     foreach ($stat['legend'] as $key => $val) {
         if (strlen($val) > 23) {
             $stat['legend'][$key] = substr($val, 0, 20) . '...';
         }
     }
     $graph->SetLegend($stat['legend']);
 }
 if ($stat['legend_x'] && $stat['legend_y']) {
     $graph->SetLegendPixels($stat['legend_x'], $stat['legend_y']);
 }
 if ($stat['graphtype'] == 'pie') {
     $graph->SetPlotAreaPixels(150, 0, $stat['xsize'], $stat['ysize']);
コード例 #12
0
$cumulateddata = array();
$statCounts = $stats->getCount();
$max = 1;
foreach ($statCounts as $statCount) {
    $bardata[] = array(date('M', mktime(0, 0, 0, $statCount['m'], 1, 2010)) . "\n" . $statCount['count'], $statCount['count']);
    if ($statCount['count'] > $max) {
        $max = $statCount['count'];
    }
}
$title = $I18N->Msg('a587_stats_general_timestats', 6);
if (rex_lang_is_utf8()) {
    $title = utf8_decode($title);
}
$plot = new PHPlot(350, 240);
$plot->SetImageBorderType('none');
$plot->SetTransparentColor('white');
$plot->SetMarginsPixels(NULL, NULL, 26, NULL);
# Make sure Y axis starts at 0:
$plot->SetPlotAreaWorld(NULL, 0, NULL, NULL);
$len = strlen('' . $max);
$plot->SetYTickIncrement(max(1, ceil($max / pow(10, $len - 1)) * pow(10, $len - 2)));
# Main plot title:
$plot->SetTitle($title);
$plot->SetFont('title', 3);
// draw bars
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($bardata);
$plot->SetDataColors(array('#14568a', '#2c8ce0', '#dfe9e9'));
$plot->SetShading(6);
$plot->DrawGraph();
コード例 #13
0
ファイル: piebcol.php プロジェクト: myfarms/PHPlot
} else {
    $c = 'default';
}
if (isset($grid_color)) {
    $g = $grid_color;
} else {
    $g = 'default';
}
if (isset($shading)) {
    $shade = "Shading: {$shading}";
} else {
    $shade = "Unshaded";
}
$title = "Test Pie Border Control, {$shade}\n" . "Border: {$b}, Border color: {$c}, Grid color: {$g}";
$plot = new PHPlot(800, 600);
$plot->SetTitle($title);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('pie');
$plot->SetDataType('text-data-single');
$plot->SetDataValues($data);
$plot->SetShading(isset($shading) ? $shading : 0);
if (isset($border_color)) {
    $plot->SetPieBorderColor($border_color);
}
if (isset($border_on)) {
    $plot->SetDrawPieBorders($border_on);
}
if (isset($grid_color)) {
    $plot->SetGridColor($grid_color);
}
$plot->DrawGraph();
コード例 #14
0
ファイル: bars-center-label.php プロジェクト: myfarms/PHPlot
$tp = array_merge(array('title' => 'Bar Chart - Check Label Centering', 'suffix' => "", 'ND' => 4, 'NB' => 1, 'FSize' => 4, 'Shade' => 0), $tp);
require_once 'phplot.php';
# All the labels are A so we can look for centering.
$data = array();
for ($i = 1; $i <= $tp['ND']; $i++) {
    $row = array('A');
    for ($j = 1; $j <= $tp['NB']; $j++) {
        $row[] = $i + $j;
    }
    $data[] = $row;
}
$plot = new PHPlot(800, 600);
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle($tp['title'] . $tp['suffix']);
# Turn off X tick labels and ticks because they don't apply here:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
# Make the text font bigger for the labels:
$plot->SetFont('x_label', $tp['FSize']);
# Results may differ with or without shading:
if (isset($tp['Shade'])) {
    $plot->SetShading($tp['Shade']);
}
# TESTING:
#$plot->group_frac_width=1.0;
#$plot->bar_width_adjust=0.5;
$plot->DrawGraph();
#fwrite(STDERR, print_r($plot, True));
コード例 #15
0
ファイル: bars-stacked.php プロジェクト: myfarms/PHPlot
<?php

# $Id$
# PHPlot test: single row stacked bars should look like regular bars?
require_once 'phplot.php';
$data = array(array('Jan', 40), array('Feb', 90), array('Mar', 50), array('Apr', 40), array('May', 75), array('Jun', 45), array('Jul', 40), array('Aug', 35), array('Sep', 50), array('Oct', 45), array('Nov', 35), array('Dec', 40));
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('stackedbars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
$plot->SetTitle("Single-dataset stackedbars\nCompare to unstacked");
$plot->SetShading(0);
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
# Testing:
#$plot->group_frac_width = 1.0;
#$plot->bar_width_adjust=0.5;
$plot->DrawGraph();
コード例 #16
0
$cumulateddata = array();
$max = 1;
foreach ($stats->getTimestats($term, $REX['ADDON']['rexsearch_plugins'][$parent][$mypage]['settings']['searchtermselectmonthcount']) as $month) {
    $bardata[] = array(date('M', mktime(0, 0, 0, $month['m'], 1, 2010)) . "\n" . $month['count'], $month['count']);
    if ($month['count'] > $max) {
        $max = $month['count'];
    }
}
$title = $I18N->Msg('a587_stats_searchterm_timestats_title', empty($term) ? $I18N->Msg('a587_stats_searchterm_timestats_title0_all') : $I18N->Msg('a587_stats_searchterm_timestats_title0_single', $term), intval($_GET['monthcount']));
if (rex_lang_is_utf8()) {
    $title = utf8_decode($title);
}
// draw bars
$plot = new PHPlot(700, 240);
$plot->SetImageBorderType('none');
$plot->SetTransparentColor('white');
$plot->SetMarginsPixels(NULL, NULL, 26, NULL);
# Make sure Y axis starts at 0:
$plot->SetPlotAreaWorld(NULL, 0, NULL, NULL);
$len = strlen('' . $max);
$plot->SetYTickIncrement(max(1, ceil($max / pow(10, $len - 1)) * pow(10, $len - 2)));
# Main plot title:
$plot->SetTitle($title);
$plot->SetFont('title', 3);
// draw bars
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($bardata);
$plot->SetDataColors(array('#14568a', '#2c8ce0', '#dfe9e9'));
$plot->SetShading(ceil(48 / $REX['ADDON']['rexsearch_plugins'][$parent][$mypage]['settings']['searchtermselectmonthcount']));
$plot->DrawGraph();
コード例 #17
0
ファイル: create_chart.php プロジェクト: alexpagnoni/phplot
$graph->SetTitle($title);
$graph->SetXTitle($xlbl, $which_xtitle_pos);
$graph->SetYTitle($ylbl, $which_ytitle_pos);
$graph->SetLegend(array("A", "Bee", "Cee", "Dee"));
$graph->SetFileFormat($which_fileformat);
$graph->SetPlotType($which_plot_type);
$graph->SetUseTTF($which_use_ttf);
$graph->SetYTickIncrement($which_yti);
$graph->SetXTickIncrement($which_xti);
$graph->SetXTickLength($which_xtl);
$graph->SetYTickLength($which_ytl);
$graph->SetXTickCrossing($which_xtc);
$graph->SetYTickCrossing($which_ytc);
$graph->SetXTickPos($which_xtick_pos);
$graph->SetYTickPos($which_ytick_pos);
$graph->SetShading($which_shading);
$graph->SetLineWidth($which_line_width);
$graph->SetErrorBarLineWidth($which_errorbar_line_width);
$graph->SetDrawDashedGrid($which_dashed_grid);
switch ($which_draw_grid) {
    case 'x':
        $graph->SetDrawXGrid(TRUE);
        $graph->SetDrawYGrid(FALSE);
        break;
    case 'y':
        $graph->SetDrawXGrid(FALSE);
        $graph->SetDrawYGrid(TRUE);
        break;
    case 'both':
        $graph->SetDrawXGrid(TRUE);
        $graph->SetDrawYGrid(TRUE);
コード例 #18
0
	public function execute( $par ) {
		global $wgRequest, $wgOut, $wgLang, $wgAutoloadClasses;

		$this->setHeaders();
		$this->outputHeader();

		if ( !class_exists( 'PHPlot' ) && !isset($wgAutoloadClasses['PHPlot'] ) ) {
			$wgOut->addWikiMsg( 'uos-warn' );
			return;
		}

		$par = trim(strtolower($par));

		foreach ( $this->blacklist as $b ) {
			if ( $b === $par ) {
				$par = false;
				break;
			}
		}

		if ( !$par ) {
			$opts = array();
			$hiddenoptions = $this->getHiddenOptions();
			$name = SpecialPage::getTitleFor( 'UserOptionStats' )->getPrefixedText();
			foreach ( $this->getOptions() as $k ) {
				if( in_array( $k, $hiddenoptions ) ) {
					continue; # List hidden options separately (see below)
				}
				$opts[] = "[[$name/$k|$k]]";
			}
			$wgOut->addWikiMsg( 'uos-choose', $wgLang->commaList( $opts ) );
			if ( count( $hiddenoptions ) > 0 ) {
				$hiddenopts = array();
				foreach ( $hiddenoptions as $hk ) {
					$hiddenopts[] = "[[$name/$hk|$hk]]";
				}
				$wgOut->addWikiMsg( 'uos-choose-hidden', $wgLang->commaList( $hiddenopts ) );
			}
			return;
		}

		$dbr = wfGetDB( DB_SLAVE );

		$users = $dbr->select( 'user', '*', '', __METHOD__ );
		$data = array();
		$optionName = $par;
		foreach ( $users as $u ) {
			// New from row doesn't load user_properties, hence this is slow!
			$obj = User::newFromRow( $u );
			$opt = $obj->getOption( $optionName, wfMsg( 'uos-unknown' ) );

			if ( !isset($data[$opt]) ) $data[$opt] = 0;
			$data[$opt]++;
		}

		$realdata = array();
		$labels = array();

		// Most popular first, barring other
		arsort( $data );

		// After more than 7 the default colors start to loop :(
		// So use the last free color for "other" which includes the rest
		$max = 7;
		$rest = array_slice( $data, $max );
		$data = array_slice( $data, 0, $max );
		foreach ( $data as $k => $d ) {
			$labels[] = "$k ($d)";
			$realdata[] = array( $k, $d );
		}
		if ( count($rest) ) {
			$other = 0;
			foreach ( $rest as $v ) $other += $v;
			$labels[] = wfMsg( 'uos-other' ) . " ($other)";
			$realdata[] = array( 'other', $other );
		}

		$title = $wgRequest->getText( 'pietitle', wfMsg( 'uos-title', $optionName ) );
		$width = $wgRequest->getInt( 'width', 700 );
		$height = $wgRequest->getInt( 'height', 500 );
		$width = max( 200, min( 1000, $width ) );
		$height = max( 200, min( 1000, $height ) );
		$shading = $wgRequest->getInt( 'shading', 10 );
		$height = max( 0, min( 1000, $height ) );

		// Define the object
		$plot = new PHPlot( $width, $height );
		$plot->SetDataType('text-data-single');
		$plot->setDataValues( $realdata );
		$plot->SetPlotType('pie');
		$plot->SetLegend($labels);
		$plot->SetShading( $shading );
		$plot->SetLabelScalePosition(0.3);
		$plot->SetTitle( $title );

		// Better fonts
		$realFunction = array( 'FCFontFinder', 'find' );
		if ( is_callable( $realFunction ) ) {
			$font = FCFontFinder::find( $wgLang->getCode() );
			if ( $font ) {
				$plot->SetDefaultTTFont( $font );
			}
		}

		global $wgOut;
		$wgOut->disable();
		$plot->DrawGraph();
	}
コード例 #19
0
ファイル: hvstackedbar.php プロジェクト: myfarms/PHPlot
        $mode = 'Data';
    }
    // E.g. SetXDataLabelType()
    $subtitle[] = "Format (Set{$mode}LabelType) '{$formattype}, {$formatarg}'";
}
if (empty($subtitle)) {
    $title .= "\nDefaults (baseline)";
} else {
    $title .= "\n" . implode(", ", $subtitle);
}
$plot = new PHPlot(800, 600);
$plot->SetDefaultTTFont($phplot_test_ttfdir . $phplot_test_ttfonts['sans']);
$plot->SetPlotType('stackedbars');
$plot->SetDataType($horiz ? 'text-data-yx' : 'text-data');
$plot->SetDataValues($data);
$plot->SetTitle($title);
if (isset($textheight)) {
    $plot->SetFont($horiz ? 'x_label' : 'y_label', NULL, $textheight);
}
if (isset($textangle)) {
    call_user_func(array($plot, "Set{$dep_var}DataLabelAngle"), $textangle);
}
if (isset($shading)) {
    $plot->SetShading($shading);
}
call_user_func(array($plot, "Set{$ind_var}TickPos"), 'none');
call_user_func(array($plot, "Set{$dep_var}DataLabelPos"), 'plotstack');
if (isset($format)) {
    call_user_func(array($plot, "Set{$dep_var}{$mode}LabelType"), $formattype, $formatarg);
}
$plot->DrawGraph();
コード例 #20
0
function guifi_stats_chart06()
{
    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 = "3671";
        }
    } else {
        $zone_id = "3671";
    }
    $azone = array();
    $avalue = array();
    $azone[$zone_id] = array($zone_id);
    $achilds = array_keys(guifi_zone_childs_tree($zone_id, 1));
    foreach ($achilds as $key => $child) {
        if ($child != $zone_id) {
            $azone[$child] = array();
            $avalue[$child] = 0;
            $aschilds = guifi_zone_childs($child);
            foreach ($aschilds as $skey => $schild) {
                array_push($azone[$child], $schild);
            }
        }
    }
    $vsql = "select COUNT(*) as num, zone_id\n      from {guifi_location}\n      where timestamp_created >= " . $datemin . " and 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)) {
        foreach ($azone as $key => $grupzone) {
            if (in_array($record->zone_id, $grupzone)) {
                $avalue[$key] = $avalue[$key] + $record->num;
            }
        }
    }
    foreach ($avalue as $key => $value) {
        if ($value != 0) {
            $data[] = array(guifi_get_zone_name($key), $value);
            $tot = $tot + $value;
        }
    }
    $shapes = array('none');
    $plot = new PHPlot($gwidth, $gheight);
    $plot->SetPlotAreaWorld(0, 0, NULL, NULL);
    $plot->SetImageBorderType('plain');
    $plot->SetFileFormat('png');
    $plot->SetPlotType("pie");
    $plot->SetDataType("text-data-single");
    $plot->SetDataValues($data);
    $plot->SetDataColors(array('red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'brown', 'lavender', 'pink', 'gray', 'orange'));
    $plot->SetTTFPath($gDirTTFfonts);
    $plot->SetFontTTF('title', 'Vera.ttf', 12);
    $plot->SetFontTTF('legend', 'Vera.ttf', 7);
    if (isset($_GET['title'])) {
        $plot->SetTitle("guifi.net      \n" . t($_GET['title']));
    } else {
        if ($zone_id == "0") {
            $plot->SetTitle("guifi.net      \n" . t('Last year'));
        } else {
            $plot->SetTitle("guifi.net    \n" . t('zone') . ": " . guifi_get_zone_name($zone_id) . "\n" . t('Last year'));
        }
    }
    $plot->SetShading(1);
    $plot->SetLabelScalePosition(0.45);
    $plot->SetLegendStyle("left", "left");
    $plot->SetLegendPixels(0, 0);
    foreach ($data as $row) {
        $plot->SetLegend(implode(': ', $row));
    }
    $plot->SetIsInline(TRUE);
    $plot->DrawGraph();
}
コード例 #21
0
ファイル: charts_report.php プロジェクト: slims/s3st15_matoa
        // set plot data and colors
        while ($data = $stat_query->fetch_row()) {
            $plot_data[] = array($data[0], $data[1]);
            $data_colors[] = '#' . generateRandomColors();
        }
        break;
}
/**
 * Charts data definition end
 */
// Create plot
if ($plot_data && $chart) {
    // set plot titles
    $plot->SetTitle($chart_title);
    // set data
    $plot->SetDataValues($plot_data);
    // set plot colors
    $plot->SetDataColors($data_colors);
    // set plot shading
    $plot->SetShading(20);
    // set plot type to pie
    $plot->SetPlotType('pie');
    $plot->SetDataType('text-data-single');
    // set legend
    foreach ($plot_data as $row) {
        $plot->SetLegend(implode(': ', $row));
    }
    //Draw it
    $plot->DrawGraph();
}
exit;
コード例 #22
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>";
 }