Exemplo n.º 1
0
 /**
  * Create PHPlot instance initializing common options
  *
  * @param int $width
  * @param int $height
  * @return PHPlot
  */
 private function create($width, $height)
 {
     $plot = new PHPlot($width, $height);
     $plot->SetTTFPath($this->fonts_path);
     $plot->SetUseTTF(true);
     return $plot;
 }
Exemplo n.º 2
0
<?php

session_start();
require_once 'phplot.php';
echo $_GET[countKeywords];
$data = array(array('新增文件', intval($_GET[countnew])), array('删除文件', intval($_GET[countdel])), array('修改文件', intval($_GET[countmodify])));
$plot = new PHPlot(350, 280);
$plot->SetTTFPath('./public');
$plot->SetDefaultTTFont('SIMHEI.TTF');
$plot->SetUseTTF(True);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetPlotBorderType('full');
$plot->SetBackgroundColor('#ffffcc');
$plot->SetDrawPlotAreaBackground(True);
$plot->SetPlotBgColor('#ffffff');
$plot->SetDataValues($data);
$plot->SetTitle("新增文件数:{$_GET['countnew']} 删除文件数:{$_GET['countdel']} 修改文件数:{$_GET['countmodify']}");
$plot->SetTitleColor('#D9773A');
foreach ($data as $row) {
    $plot->Setshading(10);
}
$plot->SetDataBorderColors('black');
$plot->DrawGraph();
Exemplo n.º 3
0
////////////////////////////////////////////////
//Required Settings
include "../phplot.php";
$graph = new PHPlot($xsize_in, $ysize_in);
$graph->SetDataType($which_data_type);
// Must be first thing
$graph->SetDataValues($data);
//Optional Settings (Don't need them)
//	$graph->SetTitle("This is a\n\rmultiple line title\n\rspanning three lines.");
$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);
 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();
         }
     }
 }
Exemplo n.º 5
0
$label[25] = "Day 25";
$label[30] = "Day 30";
Error_Reporting(0);
for ($i = 0; $i <= 30; $i++) {
    $a += rand(-1, 2);
    $b = $a * rand(0, 1) / 10;
    $c = $a * rand(0, 1) / 10;
    $data[] = array("{$label[$i]}", $i + 1, $a, $b, $c);
}
//Define the data for error bars
$graph->SetDataType("linear-linear-error");
//Must be first thing
//Set the Graph particulars
$graph->SetPrecisionX(0);
$graph->SetPrecisionY(0);
$graph->SetUseTTF("0");
$graph->SetDrawYGrid("1");
// 1 = true
$graph->SetDataValues($data);
$graph->SetImageArea(600, 400);
$graph->SetVertTickIncrement("");
$graph->SetHorizTickIncrement(1);
$graph->SetErrorBarLineWidth(1);
$graph->SetYScaleType("log");
$graph->SetPointShape("halfline");
$graph->SetErrorBarShape("line");
$graph->SetPlotType("points");
$graph->SetXGridLabelType("title");
$graph->SetXLabel("Day");
$graph->SetYLabel("index");
$graph->SetTitle("Stock Market Data");
Exemplo n.º 6
0
    $case = 0;
}
require_once 'phplot.php';
# This has some valid font info:
require_once 'config.php';
$data = array(array('A', 1, 4), array('B', 2, 6), array('C', 3, 0));
$p = new PHPlot(400, 300);
$p->SetTitle('Error test');
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetXDataLabelPos('none');
# Errors:
switch ($case) {
    case 1:
        # Test: Turn on TTF without path setup
        $p->SetUseTTF(True);
        break;
    case 2:
        # Test: Bad default font with path
        $p->SetDefaultTTFont("/no/such/path/to/font.ttf");
        break;
    case 3:
        # Test: Bad default font without path
        $p->SetDefaultTTFont("nosuchfont.ttf");
        break;
    case 4:
        # Test: Bad font path
        $p->SetTTFPath("/no/such/font/dir");
        break;
    case 5:
        # Test: Good font path and default, bad font selected
 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();
         }
     }
 }