Example #1
0
 public function renderGraph()
 {
     require_once 'libs/jpgraph/jpgraph.php';
     require_once 'libs/jpgraph/jpgraph_bar.php';
     require_once 'libs/jpgraph/jpgraph_line.php';
     $graph = new Graph(300, 200, 'auto');
     $graph->SetMarginColor('white');
     $graph->SetFrame(false);
     $graph->SetScale("textlin");
     $graph->SetY2Scale("lin");
     $graph->img->SetMargin(0, 30, 20, 65);
     $graph->yaxis->HideLabels();
     $graph->yaxis->HideTicks();
     $graph->yaxis->scale->SetGrace(20);
     $graph->y2axis->SetColor("black", "red");
     $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
     $labelsy = array();
     $datay = array();
     $datay2 = array();
     switch ($this->_controllerAction->getRequest()->getParam('type')) {
         case 'year':
             $this->_populateYearData($labelsy, $datay, $datay2);
             break;
         default:
             $this->_populateWeekData($labelsy, $datay, $datay2);
     }
     $graph->xaxis->SetTickLabels($labelsy);
     $locale = Zend_Registry::get('Zend_Locale');
     if ($locale == 'ja') {
         // the ttf file for FF_MINCHO is already encoded in utf-8
         $legend1 = $this->view->translate('Trusted sites');
         $legend2 = $this->view->translate('Sites per user');
     } else {
         // default ttf files are latin-1 encoded
         $legend1 = utf8_decode($this->view->translate('Trusted sites'));
         $legend2 = utf8_decode($this->view->translate('Sites per user'));
     }
     $bplot = new BarPlot($datay);
     $bplot->setLegend($legend1);
     $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER);
     $bplot->value->Show();
     $bplot->value->SetFormat('%d');
     $p1 = new LinePlot($datay2);
     $p1->SetColor("red");
     $p1->SetLegend($legend2);
     $graph->Add($bplot);
     $graph->AddY2($p1);
     $graph->legend->SetLayout(LEGEND_HOR);
     if ($locale == 'ja') {
         $graph->legend->setFont(FF_MINCHO, FS_NORMAL);
     }
     $graph->legend->Pos(0.5, 0.99, "center", "bottom");
     $graph->Stroke();
 }
 /**
  *
  */
 public function summary($id)
 {
     $iterationAux;
     //try {
     $project = Project::findOrFail($id);
     $iterations = Iterations::where('projectid', '=', $id)->get();
     //foreach($iterations as $var){
     //  $iterationAux = $iterationAux . var_dump($var);
     //}
     //}catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
     //}
     //die;
     JpGraph\JpGraph::load();
     JpGraph\JpGraph::module('bar');
     JpGraph\JpGraph::module('line');
     $datay = array(20, 30, 50, 80);
     $datay2 = array(30, 95, 70, 40);
     $datazero = array(0, 0, 0, 0);
     // Create the graph.
     $graph = new Graph(800, 500);
     $graph->title->Set('Example with 2 scale bars : ' . $project->name . ' : ' . $id . ' : ' . sizeof($iterations));
     // Setup Y and Y2 scales with some "grace"
     $graph->SetScale("textlin");
     $graph->SetY2Scale("lin");
     //$graph->yaxis->scale->SetGrace(30);
     //$graph->y2axis->scale->SetGrace(30);
     //$graph->ygrid->Show(true,true);
     $graph->ygrid->SetColor('gray', 'lightgray@0.5');
     // Setup graph colors
     $graph->SetMarginColor('white');
     $graph->y2axis->SetColor('darkred');
     // Create the "dummy" 0 bplot
     $bplotzero = new BarPlot($datazero);
     // Create the "Y" axis group
     $ybplot1 = new BarPlot($datay);
     $ybplot1->value->Show();
     $ybplot = new GroupBarPlot(array($ybplot1, $bplotzero));
     // Create the "Y2" axis group
     $ybplot2 = new BarPlot($datay2);
     $ybplot2->value->Show();
     $ybplot2->value->SetColor('darkred');
     $ybplot2->SetFillColor('darkred');
     $y2bplot = new GroupBarPlot(array($bplotzero, $ybplot2));
     // Add the grouped bar plots to the graph
     $graph->Add($ybplot);
     $graph->AddY2($y2bplot);
     $datax = array('A', 'B', 'C', 'D');
     $graph->xaxis->SetTickLabels($datax);
     // .. and finally stroke the image back to browser
     $graph->Stroke();
 }
Example #3
0
$graph->title->Set("Inverting both Y-axis");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetColor("white");
$graph->subtitle->Set("(Negated Y & Y2 axis)");
$graph->subtitle->SetFont(FF_FONT1, FS_NORMAL);
$graph->subtitle->SetColor("white");
// Setup axis
$graph->yaxis->SetLabelFormatCallback("_cb_negate");
$graph->xaxis->SetColor("lightblue", "white");
$graph->yaxis->SetColor("lightblue", "white");
$graph->ygrid->SetColor("blue");
// Setup Y2 axis
$graph->y2axis->SetLabelFormatCallback("_cb_negate");
$graph->y2axis->SetColor("darkred", "white");
$graph->y2scale->SetAutoMax(0);
// To make sure it starts with 0
// Setup plot 1
$lp1 = new LinePlot($ydata);
$lp1->SetColor("yellow");
$lp1->SetWeight(2);
$graph->Add($lp1);
// Setup plot 2
$lp2 = new LinePlot($y2data);
$lp2->SetColor("darkred");
$lp2->SetWeight(2);
$graph->AddY2($lp2);
$graph->Stroke();
?>


Example #4
0
function draw_bp($actual, $graph_details)
{
    $w = 700;
    $h = 450;
    $arr_xlabel = array();
    $arr_diastolic = array();
    $arr_systolic = array();
    $arr_status = array();
    //print_r($actual);
    foreach ($actual as $key => $value) {
        array_push($arr_xlabel, $value[0]);
        array_push($arr_diastolic, $value[1]);
        array_push($arr_systolic, $value[2]);
        array_push($arr_status, $value[3]);
    }
    $graph = new Graph($w, $h);
    $graph->SetScale('intlin');
    $graph->SetY2Scale('int', 0, 200);
    $graph->SetMargin(40, 70, 40, 60);
    $graph->title->Set($graph_details[0] . ' of ' . get_px_name());
    $graph->xaxis->title->Set($graph_details[1]);
    $graph->yaxis->title->Set($graph_details[2]);
    $graph->xaxis->SetTickLabels($arr_xlabel);
    $lineplot = new LinePlot($arr_diastolic);
    $lineplot2 = new LinePlot($arr_systolic);
    $lineplot->SetColor('blue');
    $lineplot->SetWeight(2);
    $lineplot2->SetColor('red');
    $lineplot2->SetWeight(2);
    $lineplot->value->Show();
    $lineplot2->value->Show();
    $graph->Add($lineplot);
    $graph->AddY2($lineplot2);
    $lineplot->SetLegend('Systolic');
    $lineplot2->SetLegend('Diastolic');
    $graph->legend->SetLayout(LEGEND_HOR);
    $graph->legend->Pos(0.5, 0.99, 'center', 'bottom');
    $graph->Stroke();
}
 $lineplot2 = new LinePlot($ydata2);
 $lineplot2->SetColor("green");
 $lineplot3 = new LinePlot($ydata3);
 $lineplot3->SetColor("orange");
 $lineplot4 = new LinePlot($ydata4);
 $lineplot4->SetColor("navy");
 $lineplot5 = new LinePlot($ydata5);
 $lineplot5->SetColor("red");
 $lineplot5->SetWeight(2);
 $lineplot5->mark->SetType(MARK_IMG_STAR, "blue", 0.7);
 // Add the plot to the graph
 $graph->Add($lineplot);
 $graph->Add($lineplot2);
 $graph->Add($lineplot3);
 //$graph->Add($lineplot4);
 $graph->AddY2($lineplot5);
 $graph->y2axis->SetColor("red");
 // Afficher les données sur la ligne des blanchissages.
 $lineplot4->value->SetFormat("%d");
 $lineplot4->value->show();
 // Afficher les données sur la ligne Moy/pj
 $lineplot5->value->SetFormat("%1.2f");
 $lineplot5->value->show();
 // Set the legends for the plots
 $lineplot->SetLegend("Pts");
 $lineplot2->SetLegend("Vict.");
 $lineplot3->SetLegend("Parties");
 //$lineplot4->SetLegend("Blanch.");
 $lineplot5->SetLegend("Moy/pj");
 // Adjust the legend position
 $graph->legend->Pos(0.05, 0.5, "right", "center");
Example #6
0
// Setup the scales for X,Y and Y2 axis
$graph->SetScale("intlin");
// X and Y axis
$graph->SetY2Scale("lin");
// Y2 axis
// Overall graph title
$graph->title->Set('Synchronized Y & Y2 scales');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
// Title for X-axis
$graph->xaxis->title->Set('Measurement');
$graph->xaxis->title->SetMargin(5);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 11);
// Create Y data set
$lplot = new LinePlot($datay);
$graph->yaxis->title->Set('Celcius (C)');
$graph->yaxis->title->SetMargin(5);
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 11);
// ... and add the plot to the Y-axis
$graph->Add($lplot);
// Create Y2 scale data set
$l2plot = new LinePlot($datay);
$l2plot->SetWeight(0);
$graph->y2axis->title->Set('Fahrenheit (F)');
$graph->y2axis->title->SetMargin(5);
// Some extra margin to clear labels
$graph->y2axis->title->SetFont(FF_ARIAL, FS_NORMAL, 11);
$graph->y2axis->SetLabelFormatCallback('toFahrenheit');
$graph->y2axis->SetColor('navy');
// ... and add the plot to the Y2-axis
$graph->AddY2($l2plot);
$graph->Stroke();
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->y2axis->SetTickSide(SIDE_RIGHT);
$graph->y2axis->SetColor('black', 'blue');
$graph->y2axis->SetLabelFormat('%3d.0%%');
// Create a bar pot
$bplot = new BarPlot($data_freq);
// Create targets and alt texts for the image maps. One for each bar
// (In this example this is just "dummy" targets)
$targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$bplot->SetCSIMTargets($targ, $alts);
// Create accumulative graph
$lplot = new LinePlot($data_accfreq);
// We want the line plot data point in the middle of the bars
$lplot->SetBarCenter();
// Use transperancy
$lplot->SetFillColor('lightblue@0.6');
$lplot->SetColor('blue@0.6');
//$lplot->SetColor('blue');
$graph->AddY2($lplot);
// Setup the bars
$bplot->SetFillColor("orange@0.2");
$bplot->SetValuePos('center');
$bplot->value->SetFormat("%d");
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
$bplot->value->Show();
// Add it to the graph
$graph->Add($bplot);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
Example #8
0
$x = array($clientrawextra['459'], $clientrawextra['460'], $clientrawextra['461'], $clientrawextra['462'], $clientrawextra['463'], $clientrawextra['464'], $clientrawextra['465'], $clientrawextra['466'], $clientrawextra['467'], $clientrawextra['468'], $clientrawextra['469'], $clientrawextra['470'], $clientrawextra['471'], $clientrawextra['472'], $clientrawextra['473'], $clientrawextra['474'], $clientrawextra['475'], $clientrawextra['476'], $clientrawextra['477'], $clientrawextra['478'], $clientrawextra['578'], $clientrawextra['579'], $clientrawextra['580'], $clientrawextra['581']);
$datax = $x;
// Create the graph and specify the scale for both Y-axis
$graph = new Graph($xsize, $ysize, "auto", 30);
$graph->SetScale("textlin");
$graph->SetY2Scale("lin", 0, 100);
$graph->SetShadow();
$graph->SetMarginColor("{$margincolour}");
// Adjust the margin
$graph->SetMargin($lm, $rm, $tm, $bm);
// Create the two linear plot
$lplot = new LinePlot($ydata);
$lplot2 = new LinePlot($y2data);
// Add the plot to the graph
$graph->Add($lplot);
$graph->AddY2($lplot2);
$lplot->SetWeight(2);
$lplot2->SetWeight(2);
//titles
$graph->title->Set("{$txt_temp} - {$txt_hum} {$txt_24h}");
$graph->title->Align("left", "top");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->title->SetColor("{$textcolour}");
//x-axis
$graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->xaxis->SetTitlemargin(25);
$graph->xaxis->SetLabelMargin(10);
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle($label_angle);
$graph->xaxis->SetTextLabelInterval($label_interval);
Example #9
0
$ybplot1->value->SetMargin(5);
$ybplot1->value->SetAngle(60);
//$ybplot1->SetFormt('$%01.2f');
$ybplot1->SetFillGradient("#408CFF", "#F0F0FF", GRAD_HOR);
$ybplot = new GroupBarPlot(array($ybplot1, $bplotzero));
// Setup font for axis
//Bottom Lables
$graph->xaxis->SetFont(FF_GEORGIA, FS_NORMAL, 10);
$graph->xaxis->SetColor("#1B1B1B");
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
//Left Lables
$graph->yaxis->SetFont(FF_GEORGIA, FS_NORMAL, 10);
$graph->yaxis->SetColor('#1B1B1B');
//$graph->y2axis->SetFont(FF_VERDANA,FS_NORMAL,10);
// Create the "Y2" axis group
$ybplot2 = new BarPlot($datay);
$ybplot2->value->Show();
$ybplot2->value->SetColor('#008000');
$ybplot2->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
$ybplot2->value->SetMargin(0);
$ybplot2->value->SetAngle(60);
//$ybplot2->value->SetFormt('$%01.2f');
$ybplot2->SetFillGradient("#80FF80", "#E8FFE8", GRAD_HOR);
$y2bplot = new GroupBarPlot(array($bplotzero, $ybplot2));
// Setup X-axis labels
// Add the grouped bar plots to the graph
$graph->Add($ybplot);
$graph->AddY2($y2bplot);
// .. and finally stroke the image back to browser
$graph->Stroke();
Example #10
0
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_line.php";
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
$y2data = array(354, 200, 265, 99, 111, 91, 198, 225, 293, 251);
$graph = new Graph(350, 300);
$graph->SetAngle(40);
$graph->img->SetMargin(80, 80, 80, 80);
$graph->SetScale("textlin");
$graph->SetY2Scale("lin");
$graph->SetShadow();
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot2 = new LinePlot($y2data);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
$graph->y2axis->SetColor("orange");
$graph->title->Set("Example 1 rotated graph (40 degree)");
$graph->legend->Pos(0.05, 0.1, "right", "top");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
$graph->yaxis->SetColor("blue");
$lineplot->SetLegend("Plot 1");
$lineplot2->SetLegend("Plot 2");
Example #11
0
$graph->legend->Pos(0.1, 0.06, "right", "top");
// Create the linear plot
$lineplot = new LinePlot($soil, $times);
$graph->Add($lineplot);
$lineplot->SetColor("blue");
$lineplot->SetWeight(3);
$lineplot->SetLegend("4in Soil Temp");
// Create the linear plot
$lineplot4 = new LinePlot($c_soil, $times);
$graph->Add($lineplot4);
$lineplot4->SetColor("purple");
$lineplot4->SetStyle("dashed");
$lineplot4->SetWeight(2);
$lineplot4->SetLegend("4in Soil Temp Climate");
$bp2 = new BarPlot($srad, $times);
$graph->AddY2($bp2);
$bp2->SetFillColor("pink");
$bp2->SetWidth(4.0);
$bp2->SetLegend("Solar Rad");
// Create the linear plot
$lineplot3 = new LinePlot($c_srad, $times);
$graph->AddY2($lineplot3);
$lineplot3->SetColor("red");
$lineplot3->SetWeight(2);
$lineplot3->SetStyle("dashed");
$lineplot3->SetLegend("Solar Rad Climate");
// Display the graph
$graph->Stroke();
?>

Example #12
0
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetPos(0.01, 0.9399999999999999, 'left', 'top');
$graph->legend->SetLineSpacing(3);
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCEE@0.5');
$graph->ygrid->Show();
$graph->xgrid->Show();
$graph->yaxis->scale->ticks->SetLabelFormat("%5.1f");
$graph->yaxis->scale->ticks->SetLabelFormat("%5.0f");
$graph->y2axis->scale->ticks->Set(100, 25);
$graph->y2axis->scale->ticks->SetLabelFormat("%-4.0f");
// Create the linear plot
$lineplot = new LinePlot($temps, $times);
$lineplot->SetLegend("Temperature");
$lineplot->SetColor("red");
//$lineplot->SetWeight(2);
// Create the linear plot
$lineplot2 = new LinePlot($dewps, $times);
$lineplot2->SetLegend("Dew Point");
$lineplot2->SetColor("blue");
//$lineplot2->SetWeight(2);
// Create the linear plot
$lineplot3 = new LinePlot($srad, $times);
$lineplot3->SetLegend("Solar Rad");
$lineplot3->SetColor("black");
//$lineplot3->SetWeight(2);
$graph->Add($lineplot2);
$graph->Add($lineplot);
if ($station != 'SPEI4') {
    $graph->AddY2($lineplot3);
}
$graph->Stroke();
Example #13
0
//$graph->AddText($tx3);
// Add the plot to the graph
$graph->Add($fz);
if (max($tcs0) != "" && isset($_GET["s0"])) {
    $graph->Add($lineplot);
}
if (max($tcs1) != "" && isset($_GET["s1"])) {
    $graph->Add($lineplot2);
}
if (max($tcs2) != "" && isset($_GET["s2"])) {
    $graph->Add($lineplot3);
}
if (max($tcs3) != "" && isset($_GET["s3"])) {
    $graph->Add($lineplot4);
}
if (max($Asubc) != "" && isset($_GET["subc"])) {
    $graph->Add($lineplot5);
}
if (max($Atmpf) != "" && isset($_GET["tmpf"])) {
    $graph->Add($lineplot6);
}
if (max($Adwpf) != "" && isset($_GET["dwpf"])) {
    $graph->Add($lineplot7);
}
if (max($pcpn) != "" && isset($_GET["pcpn"])) {
    $graph->AddY2($bp1);
}
$graph->Stroke();
?>

Example #14
0
$graph->y2axis->scale->SetGrace(10, 0);
$graph->y2axis->SetColor("darkgreen");
$lineCaches = new LinePlot($yDataCaches, $xDate);
$lineCaches->SetLegend(tr("graph_statistics_02"));
$lineCaches->SetColor("blue");
$lineCaches->SetStyle("solid");
$lineCaches->SetWeight(3);
$lineCaches->SetStepStyle();
$graph->Add($lineCaches);
$lineFound = new LinePlot($yDataLogs, $xDate);
$lineFound->SetLegend(tr("graph_statistics_03"));
$lineFound->SetColor("darkgreen");
$lineFound->SetStyle("solid");
$lineFound->SetWeight(2);
$lineFound->SetStepStyle();
$graph->AddY2($lineFound);
//
// Infotexte einfuegen
//
$txtStat1 = new Text(tr('graph_statistics_04') . strftime('%d-%m-%Y', time()));
$txtStat1->SetPos(55, 55);
$txtStat1->SetFont(FF_ARIAL, FS_NORMAL, 10);
$lineHeight = $txtStat1->GetFontHeight($graph->img);
$hiddenCaches = XDb::xSimpleQueryValue("SELECT COUNT(*) FROM `caches` WHERE (`status`=1 OR `status`=2 OR `status`=3)", 0);
$txtStat2 = new Text(tr('graph_statistics_05') . str_replace(',', '.', number_format($hiddenCaches)));
$txtStat2->SetPos(55, 55 + $lineHeight * 1.5);
$txtStat2->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat2->SetColor('blue');
$activeCaches = XDb::xSimpleQueryValue("SELECT COUNT(*) FROM `caches` WHERE `status`=1", 0);
$txtStat3 = new Text(tr('graph_statistics_06') . str_replace(',', '.', number_format($activeCaches)));
$txtStat3->SetPos(55, 55 + $lineHeight * 2.5);
Example #15
0
$graph->tabtitle->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->SetColor('wheat');
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetPos(0.01, 0.9399999999999999, 'left', 'top');
$graph->legend->SetLineSpacing(3);
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCEE@0.5');
$graph->ygrid->Show();
$graph->xgrid->Show();
$graph->yaxis->scale->ticks->SetLabelFormat("%5.1f");
$graph->yaxis->scale->ticks->Set(90, 15);
$graph->yaxis->scale->ticks->SetLabelFormat("%5.0f");
$graph->yaxis->scale->ticks->SetLabelFormat("%5.0f");
$graph->yaxis->SetColor("blue");
$graph->yaxis->SetTitle("Wind Direction [N=0, E=90, S=180, W=270]");
// Create the linear plot
$lineplot = new LinePlot($smph, $times);
$lineplot->SetLegend($wLabel);
$lineplot->SetColor("red");
$lp1 = new LinePlot($gust, $times);
$lp1->SetLegend("Peak Wind Gust");
$lp1->SetColor("black");
// Create the linear plot
$sp1 = new ScatterPlot($drct, $times);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("blue");
$sp1->mark->SetWidth(3);
$sp1->SetLegend("Wind Direction");
$graph->Add($sp1);
$graph->AddY2($lineplot);
$graph->AddY2($lp1);
$graph->Stroke();
Example #16
0
*/
$l1 = new LinePlot($y1);
$l1->SetColor("red");
$l1->SetWeight(2);
$l1->SetLegend("High Temp");
$l1->SetStyle('dashed');
$l2 = new LinePlot($y2);
$l2->SetColor("blue");
$l2->SetWeight(2);
$l2->SetLegend("Low Temp");
$l2->SetStyle('dashed');
$lp1 = new LinePlot($cy1);
$lp1->SetColor("red");
$lp1->SetLegend("CDF (high temp)");
$lp1->AddArea($h5, $h95, LP_AREA_NOT_FILLED, "lightred");
$lp1->AddArea($hm, $hm, LP_AREA_FILLED, "lightred");
$lp1->SetWeight(2);
$lp2 = new LinePlot($cy2);
$lp2->SetColor("blue");
$lp2->SetLegend("CDF (low temp)");
$lp2->AddArea($l5, $l95, LP_AREA_NOT_FILLED, "lightblue");
$lp2->AddArea($lm, $lm, LP_AREA_FILLED, "lightblue");
$lp2->SetWeight(2);
// Add the plot to the graph
//$graph->Add($gbplot);
$graph->AddY2($l1);
$graph->AddY2($l2);
$graph->Add($lp1);
$graph->Add($lp2);
// Display the graph
$graph->Stroke();
Example #17
0
function GenerateGraph($nodeID)
{
    global $DBfile, $GRAPH, $DisplayDATE, $GetDATE;
    $i = 0;
    $db = db_con($DBfile);
    $query = $db->query("SELECT place,time,supplyV,temp,hum,date(time,'unixepoch') AS Date FROM werte WHERE Date='" . $GetDATE . "' AND nodeID='" . $nodeID . "'");
    while ($result = $query->fetch(PDO::FETCH_ASSOC)) {
        $place = $result['place'];
        $TIME[$i] = $result['time'];
        $TEMP[$i] = $result['temp'] / 100;
        $HUM[$i] = $result['hum'] / 100;
        $SUPPLYV[$i] = $result['supplyV'] / 1000;
        $i++;
    }
    if ($i == 0) {
        return;
    }
    // Create the graph. These two calls are always required
    $graph = new Graph(1100, 350);
    $graph->SetScale("datlin");
    $graph->SetShadow();
    $graph->SetMargin(50, 50, 20, 100);
    $graph->title->Set('' . $place . ': ' . $DisplayDATE . '');
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    //$graph->xaxis->title->Set("Zeit");
    //$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    $graph->yaxis->title->Set("Temperatur °C");
    $graph->yaxis->SetTitlemargin(40);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->SetLabelFormatCallback('TimeCallback');
    $graph->xaxis->SetLabelAngle(90);
    $graph->xaxis->scale->SetTimeAlign(MINADJ_15);
    $lineplot = new LinePlot($TEMP, $TIME);
    $lineplot->SetColor("red");
    $lineplot->SetLegend("Temperature ");
    $lineplotb = new LinePlot($HUM, $TIME);
    $lineplotb->SetColor("blue");
    $lineplotb->SetWeight(2);
    $lineplotb->SetLegend("Humidity ");
    $graph->SetY2Scale("lin");
    $graph->AddY2($lineplotb);
    $graph->y2axis->title->Set("Luftfeuchte % ");
    $graph->y2axis->title->SetColor("blue");
    $graph->y2axis->SetTitlemargin(40);
    // Add the plot to the graph
    $graph->Add($lineplot);
    // Adjust the legend position
    $graph->legend->Pos(0.5, 0.98, "center", "bottom");
    // Display the graph
    //$graph->Stroke();
    // generate image file for HTML pages
    // Get the handler to prevent the library from sending the
    // image to the browser
    $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
    $graph->img->SetImgFormat($GRAPH['SetImgFormat']);
    $fileName = "" . $GRAPH['DIR'] . "/" . $nodeID . "." . $GRAPH['SetImgFormat'] . "";
    $graph->img->Stream($fileName);
    unset($TIME);
    unset($TEMP);
    unset($HUM);
    unset($SUPPLYV);
}
Example #18
0
$graph = new Graph(500, 300);
$graph->SetScale("loglog");
$graph->SetY2Scale("lin");
$graph->y2axis->SetColor("blue", "blue");
$graph->img->SetMargin(50, 70, 40, 50);
$graph->title->Set("Geoelektrik");
$graph->xaxis->title->Set("Auslage ab/2 [m]");
$graph->yaxis->title->Set("rho_s [Ohm m]");
$graph->y2axis->title->Set("mn/2 [m]");
$graph->y2axis->title->SetColor("blue");
$graph->y2axis->SetTitleMargin(35);
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xgrid->Show(true, true);
$graph->ygrid->Show(true, true);
// Create the linear plot
$lineplot = new LinePlot($rhos, $ab2);
$lineplot->SetWeight(1);
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetWidth(2);
// Create scatter plot
$scplot = new ScatterPlot($mn2, $ab2);
$scplot->mark->SetType(MARK_FILLEDCIRCLE);
$scplot->mark->SetColor("blue");
$scplot->mark->SetWidth(2);
// Add plots to the graph
$graph->AddY2($scplot);
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
$humidity_plot->SetColor('dodgerblue');
$humidity_plot->SetWeight(2);
$humidity_plot->SetFillColor($line_fill_color);
$temperature_plot = new LinePlot($temperature, $ts);
$temperature_plot->SetColor('hotpink3');
$temperature_plot->SetWeight(2);
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('traffic40_60.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('datlin', 0, 100);
$graph->Add($humidity_plot);
$graph->SetY2Scale('lin', 5, 30);
$graph->AddY2($temperature_plot);
$graph->ygrid->SetColor("azure3");
$graph->ygrid->Show(true, true);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->scale->SetDateFormat('g a');
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->yaxis->SetWeight(2);
$graph->yaxis->SetColor('dodgerblue');
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->yaxis->title->SetColor('dodgerblue');
$graph->yaxis->title->Set('%RH');
$graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, $font_size);
$graph->yaxis->title->SetAngle(90);
$graph->yaxis->title->SetMargin(10);
$graph->yaxis->SetTickPositions(array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100), null);
Example #20
0
function graph_cumulative_bydate($p_metrics, $p_graph_width = 300, $p_graph_height = 380)
{
    $t_graph_font = graph_get_font();
    error_check(is_array($p_metrics) ? count($p_metrics) : 0, plugin_lang_get('cumulative') . ' ' . lang_get('by_date'));
    if (plugin_config_get('eczlibrary') == ON) {
        $graph = new ezcGraphLineChart();
        $graph->background->color = '#FFFFFF';
        $graph->xAxis = new ezcGraphChartElementNumericAxis();
        $graph->data[0] = new ezcGraphArrayDataSet($p_metrics[0]);
        $graph->data[0]->label = plugin_lang_get('legend_reported');
        $graph->data[0]->color = '#FF0000';
        $graph->data[1] = new ezcGraphArrayDataSet($p_metrics[1]);
        $graph->data[1]->label = plugin_lang_get('legend_resolved');
        $graph->data[1]->color = '#0000FF';
        $graph->data[2] = new ezcGraphArrayDataSet($p_metrics[2]);
        $graph->data[2]->label = plugin_lang_get('legend_still_open');
        $graph->data[2]->color = '#000000';
        $graph->additionalAxis[2] = $nAxis = new ezcGraphChartElementNumericAxis();
        $nAxis->chartPosition = 1;
        $nAxis->background = '#005500';
        $nAxis->border = '#005500';
        $nAxis->position = ezcGraph::BOTTOM;
        $graph->data[2]->yAxis = $nAxis;
        $graph->xAxis->labelCallback = 'graph_date_format';
        $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer();
        $graph->xAxis->axisLabelRenderer->angle = -45;
        $graph->legend->position = ezcGraph::BOTTOM;
        $graph->legend->background = '#FFFFFF80';
        $graph->driver = new ezcGraphGdDriver();
        //$graph->driver->options->supersampling = 1;
        $graph->driver->options->jpegQuality = 100;
        $graph->driver->options->imageFormat = IMG_JPEG;
        $graph->title = plugin_lang_get('cumulative') . ' ' . lang_get('by_date');
        $graph->options->font = $t_graph_font;
        $graph->renderToOutput($p_graph_width, $p_graph_height);
    } else {
        foreach ($p_metrics[0] as $i => $vals) {
            if ($i > 0) {
                $plot_date[] = $i;
                $reported_plot[] = $p_metrics[0][$i];
                $resolved_plot[] = $p_metrics[1][$i];
                $still_open_plot[] = $p_metrics[2][$i];
            }
        }
        $graph = new Graph($p_graph_width, $p_graph_height);
        $graph->img->SetMargin(40, 40, 40, 170);
        if (ON == plugin_config_get('jpgraph_antialias')) {
            $graph->img->SetAntiAliasing();
        }
        $graph->SetScale('linlin');
        $graph->yaxis->SetColor("red");
        $graph->SetY2Scale("lin");
        $graph->SetMarginColor('white');
        $graph->SetFrame(false);
        $graph->title->Set(plugin_lang_get('cumulative') . ' ' . lang_get('by_date'));
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->legend->Pos(0.05, 0.9, 'right', 'bottom');
        $graph->legend->SetShadow(false);
        $graph->legend->SetFillColor('white');
        $graph->legend->SetLayout(LEGEND_HOR);
        $graph->legend->SetFont($t_graph_font);
        $graph->yaxis->scale->ticks->SetDirection(-1);
        $graph->yaxis->SetFont($t_graph_font);
        $graph->y2axis->SetFont($t_graph_font);
        if (FF_FONT2 <= $t_graph_font) {
            $graph->xaxis->SetLabelAngle(60);
        } else {
            $graph->xaxis->SetLabelAngle(90);
            # can't rotate non truetype fonts
        }
        $graph->xaxis->SetLabelFormatCallback('graph_date_format');
        $graph->xaxis->SetFont($t_graph_font);
        $p1 = new LinePlot($reported_plot, $plot_date);
        $p1->SetColor('blue');
        $p1->SetCenter();
        $p1->SetLegend(plugin_lang_get('legend_reported'));
        $graph->AddY2($p1);
        $p3 = new LinePlot($still_open_plot, $plot_date);
        $p3->SetColor('red');
        $p3->SetCenter();
        $p3->SetLegend(plugin_lang_get('legend_still_open'));
        $graph->Add($p3);
        $p2 = new LinePlot($resolved_plot, $plot_date);
        $p2->SetColor('black');
        $p2->SetCenter();
        $p2->SetLegend(plugin_lang_get('legend_resolved'));
        $graph->AddY2($p2);
        if (helper_show_query_count()) {
            $graph->subtitle->Set(db_count_queries() . ' queries (' . db_time_queries() . 'sec)');
            $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
        }
        $graph->Stroke();
    }
}
Example #21
0
 /**
  * Runs the phpOpenTracker API call.
  *
  * @param  array $parameters
  * @return mixed
  * @access public
  */
 function run($parameters)
 {
     global $locale;
     $parameters['interval'] = isset($parameters['interval']) ? $parameters['interval'] : false;
     $parameters['month_names'] = isset($parameters['month_names']) ? $parameters['month_names'] : false;
     if (!$parameters['month_names']) {
         $parameters['month_names'] = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     }
     $timestamp = time();
     $steps = array('hour' => 3600, 'day' => 86400, 'month' => 2592000, 'year' => 31536000);
     $starttitle = '';
     $endtitle = '';
     switch ($parameters['interval']) {
         case 'hour':
             $starthour = $hour = date('H', $parameters['start']);
             $endhour = date('H', $parameters['end']);
             $starttitle .= $starthour . ':00 ';
             $endtitle .= $endhour . ':00 ';
         case 'day':
             $startday = $day = date('d', $parameters['start']);
             $endday = date('d', $parameters['end']);
             $starttitle .= $startday . '. ';
             $endtitle .= $endday . '. ';
         case 'month':
             $startmonth = $month = date('m', $parameters['start']);
             $endmonth = date('m', $parameters['end']);
             $starttitle .= $parameters['month_names'][$startmonth - 1] . ' ';
             $endtitle .= $parameters['month_names'][$endmonth - 1] . ' ';
         case 'year':
             $startyear = $year = date('Y', $parameters['start']);
             $endyear = date('Y', $parameters['end']);
             $starttitle .= $startyear;
             $endtitle .= $endyear;
     }
     $title = $starttitle . ' - ' . $endtitle;
     for ($start = $parameters['start']; $start < $parameters['end']; $start += $steps[$parameters['interval']]) {
         if ($parameters['interval'] == 'month') {
             $steps['month'] = $steps['day'] * date('t', $start);
         }
         $end = $start + $steps[$parameters['interval']] - 1;
         if ($start <= $timestamp) {
             $apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start, 'end' => $end, 'constraints' => $parameters['constraints']);
             $y_pi[] = phpOpenTracker::get(array_merge(array('api_call' => 'page_impressions'), $apiCallParameters));
             $y_visits[] = phpOpenTracker::get(array_merge(array('api_call' => 'visits'), $apiCallParameters));
         } else {
             $y_pi[] = 0;
             $y_visits[] = 0;
         }
         switch ($parameters['interval']) {
             case 'hour':
                 $x_label[] = date('H', mktime($hour, 0, 0, $startmonth, $startday, $startyear)) . ':00';
                 $hour++;
                 break;
             case 'day':
                 $x_label[] = date('d', mktime(0, 0, 0, $startmonth, $day, $startyear));
                 $day++;
                 break;
             case 'month':
                 $x_label[] = date('m', mktime(0, 0, 0, $month, 1, $startyear));
                 $month++;
                 break;
             case 'year':
                 $x_label[] = date('Y', mktime(0, 0, 0, 1, 1, $year));
                 $year++;
                 break;
         }
     }
     if ($parameters['interval'] == 'hour') {
         $angle = 50;
         $xasisFontSize = $parameters['font_size'] - 2;
     } else {
         $angle = 0;
         $xasisFontSize = $parameters['font_size'];
     }
     $graph = new Graph($parameters['width'], $parameters['height'], 'auto');
     $graph->img->SetMargin(40, 40, 20, 40);
     $graph->SetScale('textlin');
     $graph->SetY2Scale('lin');
     $graph->SetShadow();
     $pi_plot = new LinePlot($y_pi);
     $pi_plot->SetColor($parameters['color1']);
     $pi_plot->SetLegend($locale->get('admin_stat', 'field_monthlyvisitor'));
     $pi_plot->SetWeight(2);
     $visits_plot = new LinePlot($y_visits);
     $visits_plot->SetColor($parameters['color2']);
     $visits_plot->SetLegend($locale->get('admin_stat', 'field_monthlyimp'));
     $visits_plot->SetWeight(2);
     $graph->Add($pi_plot);
     $graph->AddY2($visits_plot);
     $graph->xaxis->SetTickLabels($x_label);
     $graph->xaxis->SetLabelAngle($angle);
     $graph->xaxis->SetFont($parameters['font'], $parameters['font_style'], $xasisFontSize);
     $graph->xaxis->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->yaxis->SetColor('black');
     $graph->yaxis->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->yaxis->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->y2axis->SetColor('black');
     $graph->y2axis->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->y2axis->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->title->Set($title);
     $graph->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->Stroke();
 }
Example #22
0
$graph->img->SetMargin(40, 140, 40, 80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.03, 0.5, "right", "center");
// Display every 6:th tickmark
$graph->xaxis->SetTextTickInterval(6);
// Label every 2:nd tick mark
$graph->xaxis->SetTextLabelInterval(2);
// Setup the labels
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetFillColor("orange");
$b1->SetAbsWidth(8);
// Drop shadow on bars adjust the default values a little bit
$b1->SetShadow("steelblue", 2, 2);
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->AddY2($b1);
// Finally output the  image
$graph->Stroke();
?>


Example #23
0
$graph->title->Set("Monthly Rainfall Climatology for " . $cities[strtoupper($station)]['name']);
$subt = sprintf("Annual precip of %.2f inches over %.0f days", array_sum($climate), array_sum($days));
$graph->subtitle->Set($subt);
$graph->title->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->yaxis->SetTitle("Precipitation [inches]");
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->yaxis->SetTitleMargin(35);
$graph->yaxis->title->SetColor("blue");
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->xaxis->SetPos("min");
$graph->xaxis->SetTitleMargin(15);
$graph->legend->Pos(0.2, 0.09);
$graph->legend->SetLayout(LEGEND_HOR);
// Create the linear plot
$bp0 = new BarPlot($climate);
$bp0->SetFillColor("blue");
$bp1 = new BarPlot($days);
$bp1->SetFillColor("red");
$z = new BarPlot($zeros);
$z->SetFillColor("red");
$gbplot = new GroupBarPlot(array($bp0, $z));
$gbplot->SetWidth(0.6);
$graph->Add($gbplot);
$gbplot2 = new GroupBarPlot(array($z, $bp1));
$gbplot2->SetWidth(0.6);
$graph->AddY2($gbplot2);
// Display the graph
$graph->Stroke();
?>

Example #24
0
 $graph->legend->Pos(0.52, 0.92, 'center');
 $bar1 = new BarPlot($data_total_mail);
 $bar2 = new BarPlot($data_total_virii);
 $bar3 = new BarPlot($data_total_spam);
 if ($is_MCP_enabled === true) {
     $bar4 = new BarPlot($data_total_mcp);
 }
 $line1 = new LinePlot($data_total_size);
 if ($is_MCP_enabled === true) {
     $abar1 = new AccBarPlot(array($bar2, $bar3, $bar4));
 } else {
     $abar1 = new AccBarPlot(array($bar2, $bar3));
 }
 $gbplot = new GroupBarPlot(array($bar1, $abar1));
 $graph->Add($gbplot);
 $graph->AddY2($line1);
 $bar1->SetColor('blue');
 $bar1->SetFillColor('blue');
 $bar1->SetLegend('Mail');
 $bar2->SetColor('orange');
 $bar2->SetFillColor('orange');
 $bar2->SetLegend('Viruses');
 $bar3->SetColor('red');
 $bar3->SetFillColor('red');
 $bar3->SetLegend('Spam');
 if ($is_MCP_enabled === true) {
     $bar4->SetFillColor('lightblue');
     $bar4->SetLegend('MCP');
 }
 $line1->SetColor('lightgreen');
 $line1->SetFillColor('lightgreen');
Example #25
0
$graph->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->yaxis->SetTitle("Wind Direction [Deg]");
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->xaxis->SetTitle("Local Valid Time");
$graph->y2axis->SetTitle("Wind Speed [knots]");
$graph->y2axis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->y2axis->SetTitleMargin(35);
$graph->xaxis->SetTitleMargin(55);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
if ($i > 72) {
    $graph->xaxis->SetTextTickInterval(6);
}
//$graph->y2axis->SetColor("blue");
$graph->yaxis->SetColor("blue");
// Create the linear plot
$sp1 = new ScatterPlot($ydata1);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("blue");
$sp1->mark->SetWidth(3);
$sp1->SetLegend("Wind Dir");
// Create the linear plot
$lineplot1 = new LinePlot($ydata2);
$lineplot1->SetColor("black");
$lineplot1->SetLegend("Wind Speed");
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.1, 0.06, "right", "top");
// Add the plot to the graph
$graph->Add($sp1);
$graph->AddY2($lineplot1);
// Display the graph
$graph->Stroke();