Example #1
0
 public function drawGraph()
 {
     // generate graphic
     $graph = new Graph($this->width, $this->height, "auto");
     $graph->SetScale("textlin");
     $graph->img->SetMargin(0, 0, 1, 0);
     //$graph->SetFrame(true);
     // generate bars
     $bplot = new BarPlot($this->data);
     $graph->Add($bplot);
     // format bars
     $bplot->SetFillColor('gray');
     //show background image if file exists
     if (false === empty($this->bgImg) && file_exists($this->bgImg)) {
         $graph->SetBackgroundImage($this->bgImg, BGIMG_FILLFRAME);
     }
     $bplot->SetFillGradient("gray", "darkgray", GRAD_HOR);
     $graph->yaxis->HideTicks(true, true);
     $graph->xaxis->HideLabels(true);
     // show graphic
     $graph->Stroke();
 }
<?php

// content="text/plain; charset=utf-8"
require_once '../jpgraph.php';
require_once '../jpgraph_line.php';
// Some data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph(350, 250);
$graph->SetScale("textlin");
$graph->SetMargin(40, 40, 50, 50);
// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);
// Steup graph titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER, FS_BOLD, 11);
$graph->subtitle->Set('"BGIMG_COPY"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg', BGIMG_COPY);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
    $fp = fopen($name, 'rb');
    // send the right headers
    header("Content-Type: image/png");
    header("Content-Length: " . filesize($name));
    // dump the picture and stop the script
    fpassthru($fp);
    exit;
}
$temperature_plot = new LinePlot($temperature, $ts);
$temperature_plot->SetColor('hotpink3');
$temperature_plot->SetWeight(2);
$temperature_plot->SetFillColor($line_fill_color);
$graph = new Graph($width, $height);
$graph->SetFrame(false);
if ($zoom_level == 0) {
    $graph->SetBackgroundImage('background_h_30_36.png', BGIMG_FILLPLOT);
} else {
    $graph->SetBackgroundImage('background_h_28_32.png', BGIMG_FILLPLOT);
}
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('datlin', $TEMPERATURE_MIN[$zoom_level], $TEMPERATURE_MAX[$zoom_level]);
$graph->Add($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);
Example #4
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
// Some data
$datay = array(28, 19, 18, 23, 12, 11);
$data2y = array(14, 18, 33, 29, 39, 55);
// A nice graph with anti-aliasing
$graph = new Graph(400, 200);
$graph->img->SetMargin(40, 180, 40, 40);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLPLOT);
$graph->img->SetAntiAliasing("white");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set("Background image");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Slightly adjust the legend from it's default position in the
// top right corner.
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Create the first line
$p1 = new LinePlot($datay);
$p1->mark->SetType(MARK_FILLEDCIRCLE);
$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(4);
$p1->SetColor("blue");
$p1->SetCenter();
$p1->SetLegend("Triumph Tiger -98");
$graph->Add($p1);
// ... and the second
Example #5
0
    }
}
// Data arrays
$datax = array(10, 20, 30, 40, 54, 60, 70, 80);
$datay = array(12, 23, 65, 18, 84, 28, 86, 44);
// Setup the graph
$graph = new Graph(400, 270);
// We add a small 1pixel left,right,bottom margin so the plot area
// doesn't cover the frame around the graph.
$graph->img->SetMargin(1, 1, 1, 1);
$graph->SetScale('linlin', 0, 100, 0, 100);
// We don't want any axis to be shown
$graph->xaxis->Hide();
$graph->yaxis->Hide();
// Use a worldmap as the background and let it fill the plot area
$graph->SetBackgroundImage(WORLDMAP, BGIMG_FILLPLOT);
// Setup a nice title with a striped bevel background
$graph->title->Set("Pushpin graph");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 16);
$graph->title->SetColor('white');
$graph->SetTitleBackground('darkgreen', TITLEBKG_STYLE1, TITLEBKG_FRAME_BEVEL);
$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED, 'blue', 'darkgreen');
// Finally create the scatterplot
$sp = new ScatterPlot($datay, $datax);
// We want the markers to be an image
$sp->mark->SetType(MARK_IMG_PUSHPIN, 'blue', 0.6);
// Install the Y-X callback for the markers
$sp->mark->SetCallbackYX('markCallback');
// ...  and add it to the graph
$graph->Add($sp);
// .. and output to browser
Example #6
0
$datay1 = array(140, 110, 50, 60);
$datay2 = array(35, 90, 190, 190);
$datay3 = array(20, 60, 70, 140);
// Create the basic graph
$graph = new Graph(450, 250, 'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 80, 30, 40);
// Adjust the position of the legend box
$graph->legend->Pos(0.02, 0.15);
// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('darkgray@0.5');
$graph->legend->SetFillColor('lightblue@0.3');
// Get localised version of the month names
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Set a nice summer (in Stockholm) image
$graph->SetBackgroundImage('stship.jpg', BGIMG_COPY);
// Set axis titles and fonts
$graph->xaxis->title->Set('Year 2002');
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetColor('white');
$graph->yaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->SetColor('white');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using alpha blending with a background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_COMIC, FS_NORMAL, 12);
}
foreach ($humidity as $value) {
    $bucket_pos = floor($value / $range_interval);
    if ($bucket_pos >= $INTERVAL_COUNT) {
        $bucket_pos = $INTERVAL_COUNT - 1;
    }
    $bucket[$bucket_pos]++;
    //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]);
}
$humidity_plot = new BarPlot($bucket);
$humidity_plot->SetColor('dodgerblue');
$humidity_plot->SetWeight(2);
$humidity_plot->SetFillColor('dodgerblue');
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('background_v_40_60.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('textlin');
$graph->Add($humidity_plot);
$graph->ygrid->SetColor("azure3");
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->xaxis->SetTickLabels($tick_labels);
$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('Number of occurrences');
Example #8
0
 private function createBubbleGraph($datax, $datay, $dataz, $datalabel, $title)
 {
     global $format;
     // Create the graph.
     // We need to create X,Y data vectors suitable for the
     // library from the above raw data.
     $n = count($datax);
     for ($i = 0; $i < $n; ++$i) {
         // Create a faster lookup array so we don't have to search
         // for the correct values in the callback function
         $format[strval($datax[$i])][strval($datay[$i])] = array($datalabel[$i], $dataz[$i]);
     }
     // Callback for markers
     // Must return array(width,border_color,fill_color,filename,imgscale)
     // If any of the returned values are '' then the
     // default value for that parameter will be used (possible empty)
     function FCallback($aYVal, $aXVal)
     {
         global $format;
         return array($format[strval($aXVal)][strval($aYVal)][0], '', $format[strval($aXVal)][strval($aYVal)][1], '', '');
     }
     $graph = new Graph($this->width, $this->height, "auto");
     // Set the background image
     $graph->SetBackgroundImage('protected/lib/jpgraph/gfx/riscmap.jpg', BGIMG_COPY);
     $graph->SetScale("linlin");
     $graph->img->SetMargin(60, 60, 60, 60);
     $graph->title->Set($title);
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     if ($this->shadow) {
         $graph->SetShadow();
     }
     // Use a lot of grace to get large scales since the ballon have
     // size and we don't want them to collide with the X-axis
     $graph->yaxis->scale->SetGrace(50, 10);
     $graph->yaxis->title->Set($this->ylabel[0]);
     $graph->xaxis->scale->SetGrace(50, 10);
     $graph->xaxis->title->Set($this->xlabel[0]);
     // Make sure X-axis as at the bottom of the graph and not at the default Y=0
     $graph->xaxis->SetPos('min');
     // Set X-scale to start at 0
     $graph->xscale->SetAutoMin('min');
     // Create the scatter plot
     $sp1 = new ScatterPlot($datay, $datax);
     $sp1->mark->SetType(MARK_FILLEDCIRCLE);
     // Uncomment the following two lines to display the values
     $sp1->value->Show();
     $sp1->value->SetFont(FF_FONT1, FS_BOLD);
     // Callback for markers
     $sp1->mark->SetCallbackYX("FCallback");
     // Add the scatter plot to the graph
     $graph->Add($sp1);
     return $graph;
 }
Example #9
0
/**
 * Un tableau contenant les moyennes des eleves pour chaque sequences
 * 
 * @param type $moyennes = array()
 */
function genererCourbe($moyennes, $rang, $codeperiode = "S")
{
    try {
        # Donnees de la courbe
        $ydata = $moyennes;
        $ydata2 = $moyennes;
        /* for ($i = 1; $i <= 6; $i++) {
           $r = rand(0, 20);
           $ydata[] = $r;
           $ydata2[] = $r;
           } */
        /** Definition des label de l'axe x */
        if ($codeperiode === "T") {
            $datax = array("TRIM1", "TRIM2", "TRIM3");
        } else {
            $datax = array("seq 1", "seq 2", "seq 3", "seq 4", "seq 5", "seq 6");
        }
        # Creation du graph
        $graph = new Graph(350, 250, 'auto');
        $graph->SetMarginColor('white');
        # Definir le max et le min des valeur X
        $graph->SetScale('textlin', 0, 20);
        #$graph->xaxis->title->Set("Séquences");
        $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12);
        $graph->yaxis->title->Set("Moyennes");
        $graph->xaxis->SetTickLabels($datax);
        $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12);
        if ($codeperiode === "T") {
            $graph->xaxis->SetTitle("Trimestres", "middle");
        } else {
            $graph->xaxis->SetTitle("Séquences", "middle");
        }
        $graph->SetBackgroundGradient('white', 'lightblue', GRAD_HOR, BGRAD_PLOT);
        # Adjuster les margins (left, right, top, bottom)
        $graph->SetMargin(40, 5, 21, 45);
        # Box autour du plotarea
        $graph->SetBox();
        # Un cadre ou frame autour de l'image
        $graph->SetFrame(false);
        # Definir le titre tabulaire
        $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 8);
        $graph->tabtitle->Set($_SESSION['anneeacademique']);
        # Definir le titre du graphe
        $graph->title->SetFont(FF_VERDANA, FS_BOLD, 8);
        $graph->title->SetAlign("right");
        if (count($ydata) > 1) {
            $prev = $ydata[count($ydata) - 2];
            if ($prev < $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance en hausse");
            } elseif ($prev == $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance constante");
            } else {
                $graph->title->Set("Performance en baisse");
            }
        }
        # Definir les grid X et Y
        $graph->ygrid->SetFill(true, '#BBBBBB@0.9', '#FFFFFF@0.9');
        //$graph->ygrid->SetLineStyle('dashed');
        //$graph->ygrid->SetColor('gray');
        //$graph->xgrid->SetLineStyle('dashed');
        $graph->xgrid->SetColor('gray');
        $graph->xgrid->Show();
        //$graph->ygrid->Show();
        #$graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_MARGIN);
        $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
        $graph->xaxis->SetLabelAngle(0);
        # Creation d'une bar pot
        $bplot = new BarPlot($ydata);
        $bplot->SetWidth(0.9);
        $fcol = '#440000';
        $tcol = '#FF9090';
        $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION);
        # Set line weigth to 0 so that there are no border around each bar
        $bplot->SetWeight(0);
        # Create filled line plot
        $lplot = new LinePlot($ydata2);
        $lplot->SetFillColor('skyblue@0.5');
        $lplot->SetStyle(1);
        $lplot->SetColor('navy@0.7');
        $lplot->SetBarCenter();
        $lplot->mark->SetType(MARK_SQUARE);
        $lplot->mark->SetColor('blue@0.5');
        $lplot->mark->SetFillColor('lightblue');
        $lplot->mark->SetSize(5);
        # Afficher les moyenne au dessus des barres
        $accbarplot = new AccBarPlot(array($bplot));
        $accbarplot->value->SetFormat("%.2f");
        $accbarplot->value->Show();
        $graph->Add($accbarplot);
        $graph->SetBackgroundImageMix(50);
        # Definir un fond d'ecran pour l'image
        $background = SITE_ROOT . "public/photos/eleves/" . $rang['PHOTOEL'];
        if (!empty($rang['PHOTOEL']) && file_exists(ROOT . DS . "public" . DS . "photos" . DS . "eleves" . DS . $rang['PHOTOEL'])) {
            $graph->SetBackgroundImage($background, BGIMG_FILLPLOT);
            # $icon = new IconPlot($background, 25, 25, 0.8, 50);
        } else {
            //$graph->SetBackgroundImage(SITE_ROOT . "public/img/". LOGO, BGIMG_FILLPLOT);
            # $icon = new IconPlot(SITE_ROOT . "public/img/ipw.png", 25, 25, 0.8, 50);
        }
        # $icon->SetAnchor('right', 'bottom');
        $graph->Add($lplot);
        // Display the graph
        $filename = ROOT . DS . "public" . DS . "tmp" . DS . $rang['IDELEVE'] . ".png";
        if (file_exists($filename)) {
            unlink($filename);
        }
        $graph->Stroke($filename);
        //echo "<img src='" . SITE_ROOT . "public/tmp/emp.png' />";
    } catch (Exception $e) {
        var_dump($e);
    }
}
$graph = new Graph(350,250);
$graph->SetScale("textlin");
$graph->SetMargin(40,40,50,50);

// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);

// Steup graph titles
//$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER,FS_BOLD,11);
$graph->subtitle->Set('"BGIMG_CENTER"');
$graph->subtitle->SetColor('darkred');

// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg',BGIMG_CENTER);
$graph->SetBackgroundImageMix(25);

// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");

// Add the plot to the graph
$graph->Add($lineplot);

// Display the graph
$graph->Stroke();
?>
    $ts_str = gmdate('r', $row['ts']);
    error_log("temp=" . $row['temperature'] . "||humidity=" . $row['humidity'] . "||ts=" . $row['ts'] . "||ts=" . $ts_str);
    $ts[] = $row['ts'];
    $temperature[] = $row['temperature'];
    $humidity[] = $row['humidity'];
}
$humidity_plot = new LinePlot($humidity, $ts);
$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');
Example #12
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
// Some data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph(350, 250);
$graph->SetScale("textlin");
$graph->SetMargin(40, 40, 50, 50);
// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);
// Steup graph titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER, FS_BOLD, 11);
$graph->subtitle->Set('"BGIMG_FREE"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg', BGIMG_FREE);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Example #13
0
//
$stat = tr('oc_stat');
$graph->title->SetFont(FF_GEORGIA, FS_NORMAL, 14);
$graph->title->Set($stat);
$graph->title->SetMargin(12);
$graph->footer->center->Set(tr('graph_statistics_01') . date('d:m:Y H:i:s'));
$graph->footer->center->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->footer->center->SetColor('darkgray');
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.5, 0.96, "center", "bottom");
$graph->legend->SetLineWeight(8);
$graph->img->SetMargin(45, 60, 50, 70);
$graph->SetFrame(false);
$graph->SetColor(array(245, 245, 245));
$graph->SetMarginColor(array(238, 238, 238));
$graph->SetBackgroundImage('images/statbg-oc.jpg', BGIMG_CENTER, 'auto');
//
// Skalierung, X- und Y-Achse formatieren
//
$graph->SetScale("intlin", 0, 0, $startDate, time());
$graph->SetY2Scale("lin");
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->xaxis->SetMajTickPositions($tickPositions, $tickLabels);
$graph->xaxis->SetTextLabelInterval(12);
$graph->yaxis->scale->SetGrace(10, 0);
$graph->yaxis->SetColor("blue");
$graph->y2axis->scale->SetGrace(10, 0);
$graph->y2axis->SetColor("darkgreen");
$lineCaches = new LinePlot($yDataCaches, $xDate);
$lineCaches->SetLegend(tr("graph_statistics_02"));
$lineCaches->SetColor("blue");
Example #14
0
 function generateStackedBarGraph($data, $legend_index = 0, $image = false, $aFillColors = array('red', 'green', 'orange', 'yellow', 'aqua', 'lime', 'teal', 'purple1', 'lightblue', 'blue'), $length = 500, $width = 300, $fontFamily = FF_FONT1, $fontStyle = FS_BOLD, $fontSize = '', $fontColor = 'black', $marginColor = 'white')
 {
     include_once XHELP_JPGRAPH_PATH . '/jpgraph_bar.php';
     $graph = new Graph($length, $width);
     $graph->title->Set($this->meta['name']);
     $graph->SetScale("textint");
     $graph->yaxis->scale->SetGrace(30);
     //$graph->ygrid->Show(true,true);
     $graph->ygrid->SetColor('gray', 'lightgray@0.5');
     // Setup graph colors
     $graph->SetMarginColor($marginColor);
     $datazero = array(0, 0, 0, 0);
     // Create the "dummy" 0 bplot
     $bplotzero = new BarPlot($datazero);
     // Set names as x-axis label
     $graph->xaxis->SetTickLabels($data[$legend_index]);
     // for loop through data array starting with element 1
     $aPlots = array();
     for ($i = 1; $i < count($data); $i++) {
         $ybplot1 = new BarPlot($data[$i]);
         $ybplot1->setFillColor($aFillColors[$i]);
         $ybplot1->value->Show();
         $ybplot1->value->SetFont($fontFamily, $fontStyle, $fontSize);
         $ybplot1->value->SetColor($fontColor);
         $aPlots[] = $ybplot1;
     }
     //$ybplot = new AccBarPlot(array($ybplot1,$bplotzero));
     $ybplot = new AccBarPlot($aPlots, $bplotzero);
     $graph->Add($ybplot);
     // Set graph background image
     $graph->SetBackgroundImage($image, BGIMG_FILLFRAME);
     $graph->Stroke();
 }
    header("Content-Length: " . filesize($name));
    // dump the picture and stop the script
    fpassthru($fp);
    exit;
}
$humidity_plot = new LinePlot($humidity, $ts);
$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);
if ($zoom_level == 0) {
    $graph->SetBackgroundImage('background_h_25_75.png', BGIMG_FILLPLOT);
} else {
    $graph->SetBackgroundImage('background_h_40_60.png', BGIMG_FILLPLOT);
}
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('datlin', $HUMIDITY_MIN[$zoom_level], $HUMIDITY_MAX[$zoom_level]);
$graph->Add($humidity_plot);
$graph->SetY2Scale('lin', $TEMPERATURE_MIN[$zoom_level], $TEMPERATURE_MAX[$zoom_level]);
$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);
Example #16
0
<?php

// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_line.php";
// Some data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph(350, 250);
$graph->SetScale("textlin");
$graph->SetMargin(40, 40, 50, 50);
// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);
// Steup graph titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER, FS_BOLD, 11);
$graph->subtitle->Set('"BGIMG_FILLPLOT"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Example #17
0
    }
}
$bplot = new BarPlot($datay);
$bplot->SetFillColor($c);
$bplot->SetWidth(0.6);
$bplot->SetShadow();
$bplot->value->SetFormat("%.1f%%");
$bplot->value->Show();
$day0 = strtotime(date("Y") . "-06-01");
$day1 = strtotime(date("Y") . "-09-15");
$day2 = strtotime(date("Y-m-d"));
$blue_start = ($day2 - $day0) / (60 * 60 * 24);
$blue_end = ($day2 - $day1) / (60 * 60 * 24);
if ($blue_start >= 0 xor $blue_end < 0) {
    //黄色
    $graph->SetBackgroundImage('/home/kouji/public_html/html/AutoTweet/image/denryoku_bg_new_y.png', BGIMG_FILLFRAME);
} else {
    //水色
    $graph->SetBackgroundImage('/home/kouji/public_html/html/AutoTweet/image/denryoku_bg_new_b.png', BGIMG_FILLFRAME);
}
$graph->SetBackgroundImageMix(100);
$graph->title->SetFont(FF_PGOTHIC, FS_NORMAL, 20);
$graph->title->Set("\n《大手電力会社 電力使用率》");
$z = date("H") % 3;
if ($z == 2) {
    $omimai = " 熊本地震の被災地の皆様に、心よりお見舞い申し上げます。\n";
} elseif ($z == 1) {
    $omimai = "東日本大震災の被災地の皆様に、心よりお見舞い申し上げます。\n";
} elseif ($z == 0) {
    $omimai = "鳥取県中部地震の被災地の皆様に、心よりお見舞い申し上げます。\n";
}
Example #18
0
}
// A fake depth curve
$ydata = array(0, 1, 4, 5, 8, 9, 10, 14, 16, 16, 16, 18, 20, 20, 20, 22, 22.5, 22, 19, 19, 15, 15, 15, 15, 10, 10, 10, 6, 5, 5, 5, 4, 4, 2, 1, 0);
// Negate all data
$n = count($ydata);
for ($i = 0; $i < $n; ++$i) {
    $ydata[$i] = round(-$ydata[$i]);
}
// Basic graph setup
$graph = new Graph(400, 300);
$graph->SetScale("linlin");
$graph->img->SetMargin(50, 50, 60, 40);
$graph->SetMarginColor('darkblue');
$graph->SetColor('darkblue');
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
$graph->SetBackgroundImage("blueblack400x300grad.png", 1);
//$graph->SetBackgroundImage("lightbluedarkblue400x300grad.png",1);
$graph->title->Set("Depth curve. Dive #2");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetColor("white");
$graph->subtitle->Set("(Negated Y-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");
$lp1 = new LinePlot($ydata);
$lp1->SetColor("yellow");
$lp1->SetWeight(2);
    $fp = fopen($name, 'rb');
    // send the right headers
    header("Content-Type: image/png");
    header("Content-Length: " . filesize($name));
    // dump the picture and stop the script
    fpassthru($fp);
    exit;
}
$sewer_plot = new LinePlot($sewer, $ts);
$sewer_plot->SetColor('darkgoldenrod');
$sewer_plot->SetWeight(2);
$sewer_plot->SetFillColor($line_fill_color);
$graph = new Graph($width, $height);
$graph->SetFrame(false);
if ($zoom_level == 0) {
    $graph->SetBackgroundImage('background_h_33_66.png', BGIMG_FILLPLOT);
} else {
    $graph->SetBackgroundImage('background_h_10_20.png', BGIMG_FILLPLOT);
}
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('datlin', $SEWER_MIN, $SEWER_MAX[$zoom_level]);
$graph->Add($sewer_plot);
$graph->ygrid->SetColor("azure3");
$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('darkgoldenrod');
}
foreach ($sewer as $value) {
    $bucket_pos = floor($value / $range_interval);
    if ($bucket_pos >= $INTERVAL_COUNT) {
        $bucket_pos = $INTERVAL_COUNT - 1;
    }
    $bucket[$bucket_pos]++;
    //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]);
}
$sewer_plot = new BarPlot($bucket);
$sewer_plot->SetColor('darkgoldenrod');
$sewer_plot->SetWeight(2);
$sewer_plot->SetFillColor('darkgoldenrod');
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('background_v_33_66.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('textlin');
$graph->Add($sewer_plot);
$graph->ygrid->SetColor("azure3");
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->xaxis->SetTickLabels($tick_labels);
$graph->yaxis->SetWeight(2);
$graph->yaxis->SetColor('darkgoldenrod');
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->yaxis->title->SetColor('darkgoldenrod');
$graph->yaxis->title->Set('Number of occurrences');
Example #21
0
<?php

// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_line.php";
// Some data
$datay = array(28, 19, 18, 23, 12, 11);
$data2y = array(14, 18, 33, 29, 39, 55);
// A nice graph with anti-aliasing
$graph = new Graph(400, 200);
$graph->img->SetMargin(40, 180, 40, 40);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_COPY);
$graph->img->SetAntiAliasing("white");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set("Background image");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Slightly adjust the legend from it's default position in the
// top right corner.
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Create the first line
$p1 = new LinePlot($datay);
$p1->mark->SetType(MARK_FILLEDCIRCLE);
$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(4);
$p1->SetColor("blue");
$p1->SetCenter();
$p1->SetLegend("Triumph Tiger -98");
$graph->Add($p1);
// ... and the second
$graph = new Graph(350,250);
$graph->SetScale("textlin");
$graph->SetMargin(40,40,50,50);

// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);

// Steup graph titles
//$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER,FS_BOLD,11);
$graph->subtitle->Set('"BGIMG_FILLFRAME"');
$graph->subtitle->SetColor('darkred');

// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg',BGIMG_FILLFRAME);
$graph->SetBackgroundImageMix(25);

// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");

// Add the plot to the graph
$graph->Add($lineplot);

// Display the graph
$graph->Stroke();
?>
Example #23
0
function graficar_defectos($eje_y, $x_label, $pareto, $titulo_eje_x, $titulo_eje_y, $title, $name)
{
    include "../jpgraph/src/jpgraph.php";
    include "../jpgraph/src/jpgraph_line.php";
    include "../jpgraph/src/jpgraph_bar.php";
    $graph = new Graph(820, 350);
    $graph->SetScale("textlin");
    $graph->SetMarginColor("#FFFFFF");
    $graph->img->SetMargin(80, 80, 60, 140);
    $graph->yaxis->SetTitleMargin(40);
    $graph->SetBackgroundImage("../imagenes/fondo.jpg", BGIMG_FILLFRAME);
    $graph->xaxis->SetLabelAngle(90);
    $graph->xaxis->SetTickLabels($x_label);
    $graph->legend->Pos(0.03, 0.3);
    $graph->title->SetColor("#000000");
    $graph->title->Set($title);
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    //$graph->yaxis->title->Set($titulo_eje_y);
    //$graph->xaxis->title->Set($titulo_eje_x);
    $graph->setcolor("#EEEEEE");
    $graph->setshadow("true", 3, "#aaaaaa");
    // Crear la gráfica de barras
    $bplot1 = new BarPlot($eje_y);
    $bplot1->SetWidth(0.3);
    $bplot1->SetYMin(0.02);
    $bplot1->SetFillColor("orange@0.2");
    $bplot1->SetShadow('darkgray');
    $bplot1->value->SetFormat("%0.1f");
    $bplot1->value->SetColor("darkred");
    $bplot1->value->Show();
    // Crear la gráfica de líneas
    $lplot = new LinePlot($pareto);
    $lplot->mark->SetType(MARK_FILLEDCIRCLE);
    $lplot->mark->SetFillColor("red");
    $lplot->mark->SetWidth(3);
    $lplot->SetColor("blue");
    $lplot->SetBarCenter();
    $graph->Add($bplot1);
    $graph->Add($lplot);
    $graph->Stroke("charts/" . $name);
}
Example #24
0
<?php

require_once '../jpgraph.php';
require_once '../jpgraph_line.php';
$datay = array(0, 3, 5, 12, 15, 18, 22, 36, 37, 41);
// Setup the graph
$graph = new Graph(320, 200);
$graph->title->Set('Education growth');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph->SetScale('intlin');
$graph->SetMarginColor('white');
$graph->SetBox();
//$graph->img->SetAntialiasing();
$graph->SetGridDepth(DEPTH_FRONT);
$graph->ygrid->SetColor('gray@0.7');
$graph->SetBackgroundImage('classroom.jpg', BGIMG_FILLPLOT);
// Masking graph
$p1 = new LinePlot($datay);
$p1->SetFillColor('white');
$p1->SetFillFromYMax();
$p1->SetWeight(0);
$graph->Add($p1);
// Line plot
$p2 = new LinePlot($datay);
$p2->SetColor('black@0.4');
$p2->SetWeight(3);
$p2->mark->SetType(MARK_SQUARE);
$p2->mark->SetColor('orange@0.5');
$p2->mark->SetFillColor('orange@0.3');
$graph->Add($p2);
// Output line
$month = array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
// Create datapoints where every point
$steps = 100;
for ($i = 0; $i < $steps; ++$i) {
    $datay[$i] = log(pow($i, $i / 10) + 1) * sin($i / 15) + 35;
    $databarx[] = sprintf("198%d %s", floor($i / 12), $month[$i % 12]);
    // Simulate an accumulated value for every 5:th data point
    if ($i % 6 == 0) {
        $databary[] = abs(25 * sin($i) + 5);
    } else {
        $databary[] = 0;
    }
}
// New graph with a background image and drop shadow
$graph = new Graph(450, 300, "auto");
$graph->SetBackgroundImage("tiger_bkg.png", 3);
$graph->SetShadow();
// Use an integer X-scale
$graph->SetScale("textlin");
// Set title and subtitle
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("100 data points, X-Scale: 'text'");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$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.05, 0.5, "right", "center");
// Display every 10:th datalabel
Example #26
0
}
#Resolution de la database:
$xdb = 620;
$ydb = 310;
# Resolution de l'image
$ximg = 1264;
$yimg = 694;
# Rapport :
$rapport_x = $ximg / $xdb;
$rapport_y = $yimg / $ydb;
// Some data
$yadapt = 310;
// A nice graph with anti-aliasing
$graph = new Graph($ximg, $yimg, "auto");
$graph->img->SetMargin(1, 1, 1, 1);
$graph->SetBackgroundImage("../../pixmaps/mappemonde.jpg", BGIMG_FILLFRAME);
//$graph->img->SetAntiAliasing(false);
$graph->SetScale("lin", 1, $yimg, 1, $ximg);
$graph->ygrid->Show(false, false);
$graph->xgrid->Show(false, false);
$graph->xaxis->Hide();
$graph->yaxis->Hide();
$pays = array();
$data = array();
// DB DATA from datawarehouse.geo
require_once 'ossim_db.inc';
$db = new ossim_db();
$conn = $db->connect();
$vol_max = 0;
foreach ($ips as $country => $val) {
    $cou = explode(":", $country);
Example #27
0
$month = array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
// Create datapoints where every point
$steps = 100;
for ($i = 0; $i < $steps; ++$i) {
    $datay[$i] = log(pow($i, $i / 10) + 1) * sin($i / 15) + 35;
    $databarx[] = sprintf("198%d %s", floor($i / 12), $month[$i % 12]);
    // Simulate an accumulated value for every 5:th data point
    if ($i % 6 == 0) {
        $databary[] = abs(25 * sin($i) + 5);
    } else {
        $databary[] = 0;
    }
}
// New graph with a background image and drop shadow
$graph = new Graph(450, 300);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME);
$graph->SetShadow();
// Use an integer X-scale
$graph->SetScale("textlin");
// Set title and subtitle
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("100 data points, X-Scale: 'text'");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$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.05, 0.5, "right", "center");
// Display every 10:th datalabel
Example #28
0
 function generateGraph()
 {
     if ($this->getVar('hasGraph') == 0) {
         return false;
     }
     if ($this->getVar('hasResults') == 0) {
         $this->_setResults();
     }
     $aResults = $this->getVar('results');
     $graph = new Graph(500, 300);
     $graph->title->Set($this->meta['name']);
     $graph->SetScale("textint");
     $graph->yaxis->scale->SetGrace(30);
     //$graph->ygrid->Show(true,true);
     $graph->ygrid->SetColor('gray', 'lightgray@0.5');
     // Setup graph colors
     $graph->SetMarginColor('white');
     $i = 0;
     $data = array();
     foreach ($aResults as $result) {
         $data[0][] = $result['name'];
         $data[1][] = $result['ticketsResponded'];
         $data[2][] = $result['callsClosed'];
         $data[3][] = $result['avgResponseTime'];
     }
     $datazero = array(0, 0, 0, 0);
     // Create the "dummy" 0 bplot
     $bplotzero = new BarPlot($datazero);
     // Set names as x-axis label
     $graph->xaxis->SetTickLabels($data[0]);
     // Create the "Y" axis group
     foreach ($data as $d) {
         $ybplot1 = new BarPlot($d);
         $ybplot1->value->Show();
         $ybplot = new GroupBarPlot(array($ybplot1, $bplotzero));
         $graph->Add($ybplot);
     }
     // Set graph background image
     $graph->SetBackgroundImage(XHELP_IMAGE_PATH . '/graph_bg.jpg', BGIMG_FILLFRAME);
     $graph->Stroke();
 }