예제 #1
0
<?php

// content="text/plain; charset=utf-8"
// $Id: stockex2.php,v 1.1 2003/01/31 17:41:29 aditus Exp $
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_stock.php';
$datay = array(34, 42, 27, 45, 55, 25, 12, 59, 38, 49, 32, 64, 34, 40, 29, 42, 40, 29, 22, 45);
// Setup basic graph
$graph = new Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
$graph->SetFrame(false);
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->SetBox();
$graph->tabtitle->Set(' Week 34 ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_NORMAL, 12);
// Get week days in curent locale
$days = $gDateLocale->GetShortDay();
array_shift($days);
// Start on monday
$graph->xaxis->SetTickLabels($days);
// Create stock plot
$p1 = new StockPlot($datay);
// Indent plot so first and last bar isn't on the edges
$p1->SetCenter();
// Add and stroke
$graph->Add($p1);
$graph->Stroke();
예제 #2
0
 function __construct($datay, $datax = false)
 {
     $this->iTupleSize = 5;
     parent::__construct($datay, $datax);
 }
예제 #3
0
 private function _renderPlotStock($groupID)
 {
     $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
     $plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
     $dataValues = array();
     //	Loop through each data series in turn and build the plot arrays
     foreach ($plotOrder as $i => $v) {
         $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues();
         foreach ($dataValuesX as $j => $dataValueX) {
             $dataValues[$plotOrder[$i]][$j] = $dataValueX;
         }
     }
     if (empty($dataValues)) {
         return;
     }
     $dataValuesPlot = array();
     // Flatten the plot arrays to a single dimensional array to work with jpgraph
     for ($j = 0; $j < count($dataValues[0]); $j++) {
         for ($i = 0; $i < $seriesCount; $i++) {
             $dataValuesPlot[] = $dataValues[$i][$j];
         }
     }
     // Set the x-axis labels
     $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);
         $this->_graph->xaxis->SetTickLabels($datasetLabels);
     }
     $seriesPlot = new StockPlot($dataValuesPlot);
     $seriesPlot->SetWidth(20);
     $this->_graph->Add($seriesPlot);
 }
예제 #4
0
 function BoxPlot($datay, $datax = false)
 {
     $this->iTupleSize = 5;
     parent::StockPlot($datay, $datax);
 }
예제 #5
0
<?php

// content="text/plain; charset=utf-8"
// Example of a stock chart
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_stock.php';
// Data must be in the format : open,close,min,max
$datay = array(34, 42, 27, 45, 55, 25, 14, 59, 15, 40, 12, 47, 62, 38, 25, 65, 38, 49, 32, 64);
// Setup a simple graph
$graph = new Graph\Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetMarginColor('lightblue');
$graph->title->Set('Stockchart example');
// Create a new stock plot
$p1 = new StockPlot($datay);
// Width of the bars (in pixels)
$p1->SetWidth(9);
// Uncomment the following line to hide the horizontal end lines
//$p1->HideEndLines();
// Add the plot to the graph and send it back to the browser
$graph->Add($p1);
$graph->Stroke();
예제 #6
0
     $lplot26 = new LinePlot($median26);
     $lplot26->SetColor('salmon');
     $graph->Add($lplot26);
     $lplot13 = new LinePlot($median13);
     $lplot13->SetColor('seagreen');
     $graph->Add($lplot13);
 }
 if ($type == 7 || $type == 8) {
     $lplot13 = new LinePlot($median13);
     $lplot13->SetColor('seagreen');
     $graph->Add($lplot13);
     $lplot = new LinePlot($median5);
     $lplot->SetColor('salmon');
     $graph->Add($lplot);
 }
 $p1 = new StockPlot($datay);
 $p1->SetColor('blue', 'blue', 'red', 'red');
 if ($type == 1) {
     $p1->SetWidth(50);
 } elseif ($type == 2) {
     $p1->SetWidth(8);
 } elseif ($type == 3 || $type == 5) {
     $p1->SetWidth(4);
 } else {
     $p1->SetWidth(2);
 }
 $p1->HideEndLines();
 $p1->SetCenter();
 $graph->Add($p1);
 $graph->xaxis->HideLabels();
 $graph->xaxis->HideTicks(true, true);
예제 #7
0
 public function createGraph2($params = array(), $params2 = array())
 {
     $em = $this->getDoctrine()->getManager();
     list($param1, $param2, $param3, $y_eixo, $k, $nome, $tipo) = $params;
     list($ydata3, $ydata4, $dia_fim, $dia_ini, $code, $circuit) = $params2;
     $fields = $em->createQuery("SELECT d._719MediaOut, d._719MediaIn, d._719PeakOut, d._719PeakIn, \n\t\t\t            \t\td.cirInRec, d.cirOutRec, d.day FROM CocarBundle:DailyPerformance d \n\t\t\t            \t\tWHERE (d.day >= :start \n\t\t\t            \t\t\tAND d.day <= :end)\n    \t\t\t\t\t\t\t\tAND d.codeInterface = :code")->setParameter('start', $dia_ini)->setParameter('end', $dia_fim)->setParameter('code', $code)->getResult();
     $i = 0;
     foreach ($fields as $f) {
         $p1 = $param1 == 'cir_out_rec' ? $f['cirOutRec'] : $f['cirInRec'];
         $p2 = $param2 == '7_19_media_out' ? $f['_719MediaOut'] : $f['_719MediaIn'];
         $p3 = $param3 == '7_19_pico_out' ? $f['_719PeakOut'] : $f['_719PeakIn'];
         $ydata = $param1 == 'cir_out_rec' ? $ydata4[$i] : $ydata3[$i];
         $datay[] = $ydata / 20 + $p1 / $k;
         $datay[] = $p1 / $k;
         $datay[] = $p2 / $k;
         $datay[] = $p3 / $k;
         $a[] = $f['day']->format('d/m');
         $i++;
     }
     // Create the graph. These two calls are always required
     $graph = new \Graph(580, 280, "auto");
     $graph->SetScale("textlin");
     $graph->img->SetMargin(60, 10, 5, 60);
     // Create the bar plots
     $b1plot = new \StockPlot($datay);
     $b1plot->SetWidth(9);
     $graph->title->Set("{$tipo}");
     $graph->yaxis->title->Set($y_eixo);
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->xaxis->SetTickLabels($a);
     $graph->xaxis->SetLabelAngle(90);
     //acrescenta linhas de cir
     $lineplot3 = new \LinePlot($ydata3);
     $lineplot4 = new \LinePlot($ydata4);
     $lineplot3->SetColor("red");
     $lineplot3->SetWeight(1);
     $lineplot4->SetColor("red");
     $lineplot4->SetWeight(1);
     if ($tipo == "ENTRADA APS (últimos 30 dias) - Média/Taxa95%/Máx") {
         $graph->Add($lineplot4);
     } else {
         $graph->Add($lineplot3);
     }
     $b1plot->SetWeight(2);
     $b1plot->SetColor('blue', 'blue', 'orange', 'red');
     // ...and add it to the graPH
     $graph->Add($b1plot);
     //Display the graph
     $graph->SetFrame(false);
     $nome_graf = $this->dir . "graficos/daily/" . $code . "_" . $nome . ".png";
     $graph->Stroke($nome_graf);
 }