public function doGet(WebAppRequest $req, WebAppResponse $res)
 {
     // Bootstraps Innomatic
     require_once 'innomatic/core/InnomaticContainer.php';
     $innomatic = InnomaticContainer::instance('innomaticcontainer');
     // Sets Innomatic base URL
     $baseUrl = '';
     $webAppPath = $req->getUrlPath();
     if (!is_null($webAppPath) && $webAppPath != '/') {
         $baseUrl = $req->generateControllerPath($webAppPath, true);
     }
     $innomatic->setBaseUrl($baseUrl);
     $innomatic->setInterface(InnomaticContainer::INTERFACE_WEB);
     $home = WebAppContainer::instance('webappcontainer')->getCurrentWebApp()->getHome();
     $innomatic->bootstrap($home, $home . 'core/conf/innomatic.ini');
     $id = basename($req->getParameter('id'));
     //$id = basename($_GET['id']);
     $args = unserialize(file_get_contents(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id));
     require_once 'phplot/PHPlot.php';
     $graph = new PHPlot($args['width'], $args['height']);
     $graph->SetIsInline('1');
     //$graph->SetDataColors( array("blue",'white'),array("black") );
     //$graph->$line_style = array('dashed','dashed','solid','dashed','dashed','solid');
     // Base
     $graph->SetDataValues($args['data']);
     $graph->SetPlotType($args['plottype']);
     // Appearance
     $graph->SetPointShape($args['pointshape']);
     $graph->SetPointSize($args['pointsize']);
     $graph->SetTitle($args['title']);
     // Color
     $graph->SetBackgroundColor($args['backgroundcolor']);
     $graph->SetGridColor($args['gridcolor']);
     if (count($args['legend'])) {
         $graph->SetLegend($args['legend']);
     }
     $graph->SetLineWidth($args['linewidth']);
     $graph->SetTextColor($args['textcolor']);
     $graph->SetDataColors(array(array(145, 165, 207), array(114, 167, 112), array(71, 85, 159), array(175, 83, 50), array(247, 148, 53), array(240, 231, 125), array(154, 204, 203), array(201, 164, 196)), 'black');
     //$graph->data_color = array( array(145,165,207), array(114,167,112), array(71,85,159), array(175,83,50), array(247,148,53), array(240,231,125), array(154,204,203), array(201,164,196) );
     //array('blue','green','yellow','red','orange');
     $graph->DrawGraph();
     unlink(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id);
 }
Exemplo n.º 2
0
$graph->SetMarginsPixels(50, 50, 50, 50);
$graph->SetLegend(array('Time in Flight', 'Time to Stop'));
//Lets have a legend
$graph->SetLegendWorld(1, 8);
//Lets have a legend position
//Draw it
$graph->DrawGraph();
//////////////////////NEXT SETTINGS
$example_data = array(array("a", 60), array("b", 40), array("c", 50), array("d", 50), array("e", 80), array("f", 90), array("f", 40));
$graph->SetDataValues($example_data);
$graph->SetDataColors(array("red"), array("green"));
$graph->SetDrawXDataLabels(0);
//We already got them in the first graph
$graph->SetPlotAreaWorld(0, 0, 7.5, 100);
//New Plot Area
$graph->SetLegend(array('Size of Dog'));
//Lets add a second legend
$graph->DrawLegend(55, 55, '');
//Set Params of another Y Axis
$graph->SetVertTickPosition('yaxis');
$graph->SetYGridLabelType('right');
$graph->SetYAxisPosition(7.5);
$graph->SetPrecisionY(0);
$graph->SetTickColor('red');
$graph->SetTextColor('red');
$graph->SetGridColor('red');
$graph->DrawYAxis();
//Draw the New data over the first graph
$graph->DrawLines();
$graph->DrawDots();
$graph->PrintImage();
Exemplo n.º 3
0
{
    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');
}
$p->DrawGraph();
Exemplo n.º 4
0
function guifi_stats_chart07()
{
    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 = "0";
        }
        //"3671";
    } else {
        $zone_id = "0";
    }
    $avalue = array();
    $adata = array();
    for ($i = 0; $i < 10; $i++) {
        $adata[] = array(0, 0);
    }
    $vsql = "select sum(if(timestamp_created >= " . $datemin . ",1,0)) as num, count(*) as total, zone_id\n      from {guifi_location}\n      where 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)) {
        if ($record->total >= 20) {
            $vn = $record->num / $record->total * 100;
            $vmin = 0;
            for ($i = 1; $i < 10; $i++) {
                if ($adata[$vmin][1] > $adata[$i][1]) {
                    $vmin = $i;
                }
            }
            if ($vn > $adata[$vmin][1]) {
                $adata[$vmin][0] = $record->zone_id;
                $adata[$vmin][1] = $vn;
            }
        }
    }
    for ($i = 0; $i < 10; $i++) {
        if ($adata[$i][1] != 0) {
            $avalue[$adata[$i][0]] = $adata[$i][1];
        }
    }
    arsort($avalue);
    foreach ($avalue as $key => $value) {
        if ($value != 0) {
            $data[] = array(substr(guifi_get_zone_name($key), 0, 20) . "  �", $value);
        }
    }
    $shapes = array('none');
    $plot = new PHPlot($gwidth, $gheight);
    $plot->SetPlotAreaWorld(0, 0, NULL, NULL);
    $plot->SetFileFormat('png');
    $plot->SetDataType("text-data");
    $plot->SetDataValues($data);
    $plot->SetPlotType("bars");
    $plot->SetXTickIncrement(1);
    $plot->SetSkipBottomTick(TRUE);
    $plot->SetSkipLeftTick(TRUE);
    $plot->SetTickLength(0);
    //$plot->SetXTickPos('none');
    $plot->SetYDataLabelPos('plotin');
    $plot->SetYLabelType('data', 0);
    $plot->SetTickColor('grey');
    $plot->SetTTFPath($gDirTTFfonts);
    $plot->SetFontTTF('title', 'Vera.ttf', 12);
    $plot->SetFontTTF('x_label', 'Vera.ttf', 8);
    if (isset($_GET['title'])) {
        $plot->SetTitle("guifi.net      \n" . t($_GET['title']));
    } else {
        if ($zone_id == "0") {
            $plot->SetTitle("guifi.net      \n" . t('Largest annual increase'));
        } else {
            $plot->SetTitle("guifi.net    " . t('zone') . ": " . guifi_get_zone_name($zone_id) . "\n" . t('Largest annual increase'));
        }
    }
    //$plot->SetXTitle(t('Zones'));
    $plot->SetYTitle(t('% increase'));
    $plot->SetXDataLabelPos('plotdown');
    //$plot->SetXLabelAngle(45);
    $plot->SetXDataLabelAngle(75);
    $plot->SetGridColor('red');
    $plot->SetPlotBorderType('left');
    $plot->SetDataColors(array('orange'));
    $plot->SetTextColor('DimGrey');
    $plot->SetTitleColor('DimGrey');
    $plot->SetLightGridColor('grey');
    $plot->SetBackgroundColor('white');
    $plot->SetTransparentColor('white');
    $plot->SetIsInline(TRUE);
    $plot->DrawGraph();
}
Exemplo n.º 5
0
function plot_guifi()
{
    include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php';
    $result = db_query("select COUNT(*) as num, MONTH(FROM_UNIXTIME(timestamp_created)) as mes, YEAR(FROM_UNIXTIME(timestamp_created)) as ano from {guifi_location} where status_flag='Working' GROUP BY YEAR(FROM_UNIXTIME(timestamp_created)),MONTH(FROM_UNIXTIME(timestamp_created)) ");
    $inicial = 5;
    $nreg = $inicial;
    $tot = 0;
    $ano = 2004;
    $mes = 5;
    $items = 2004;
    $label = "";
    while ($record = db_fetch_object($result)) {
        if ($record->ano >= 2004) {
            if ($mes == 12) {
                $mes = 1;
                $ano++;
            } else {
                $mes++;
            }
            while ($ano < $record->ano || $mes < $record->mes) {
                $nreg++;
                if ($mes == 6) {
                    $label = $ano;
                } else {
                    $label = '';
                }
                $data[] = array("{$label}", $nreg, $tot, '');
                if ($mes == 12) {
                    $mes = 1;
                    $ano++;
                } else {
                    $mes++;
                }
            }
            $tot += $record->num;
            $nreg++;
            if ($mes == 6) {
                $label = $ano;
            } else {
                $label = '';
            }
            $data[] = array("{$label}", $nreg, $tot, '');
        } else {
            $tot += $record->num;
        }
    }
    while ($mes < 12) {
        $nreg++;
        $mes++;
        if ($mes == 6) {
            $label = $ano;
        } else {
            $label = '';
        }
        $data[] = array("{$label}", $nreg, "");
    }
    $items = ($ano - $items + 1) * 12;
    if ($tot % 1000 < 30) {
        $data[$nreg - $inicial - 1][3] = $tot;
        $vt = floor($tot / 1000) * 1000;
        $vtitle = $vt . " " . t('Nodes') . "!!!";
        $tcolor = 'red';
    } else {
        $vtitle = t('Working nodes');
        $tcolor = 'DimGrey';
    }
    $shapes = array('none', 'circle');
    $plot = new PHPlot(200, 150);
    $plot->SetPlotAreaWorld(0, 0, $items, NULL);
    $plot->SetFileFormat('png');
    $plot->SetDataType("data-data");
    $plot->SetDataValues($data);
    $plot->SetPlotType("linepoints");
    $plot->SetYTickIncrement(2000);
    $plot->SetXTickIncrement(12);
    $plot->SetSkipBottomTick(TRUE);
    $plot->SetSkipLeftTick(TRUE);
    $plot->SetXAxisPosition(0);
    $plot->SetPointShapes($shapes);
    $plot->SetPointSizes(10);
    $plot->SetTickLength(3);
    $plot->SetDrawXGrid(TRUE);
    $plot->SetTickColor('grey');
    $plot->SetTitle($vtitle);
    $plot->SetDrawXDataLabelLines(FALSE);
    $plot->SetXLabelAngle(0);
    $plot->SetXLabelType('custom', 'Plot1_LabelFormat');
    $plot->SetGridColor('red');
    $plot->SetPlotBorderType('left');
    $plot->SetDataColors(array('orange'));
    $plot->SetTextColor('DimGrey');
    $plot->SetTitleColor($tcolor);
    $plot->SetLightGridColor('grey');
    $plot->SetBackgroundColor('white');
    $plot->SetTransparentColor('white');
    $plot->SetXTickLabelPos('none');
    $plot->SetXDataLabelPos('plotdown');
    $plot->SetIsInline(TRUE);
    $plot->DrawGraph();
}
Exemplo n.º 6
0
# $Id$
# PHPlot test: Coloring various items
require_once 'phplot.php';
$data = array();
$x = 0.0;
$dx = M_PI / 4.0;
for ($i = 0; $i < 50; $i++) {
    $y = $x * sin($x);
    $data[] = array('', $i, $y);
    $x += $dx;
}
$plot = new PHPlot(800, 600);
$plot->SetPlotType('lines');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetLineWidths(2);
$plot->SetPlotAreaWorld(0, -40, 50, 40);
# Turn everything on to test colors:
$plot->SetTitle("Color Tests\n" . " SetGridColor blue (used for axes, legend border)\n" . " SetLightGridColor magenta\n" . " SetTextColor red\n" . " SetTickColor green\n" . " SetTitleColor gold");
$plot->SetDrawXGrid(True);
$plot->SetDrawYGrid(True);
$plot->SetLegend('Color Tests');
$plot->SetXTitle('X Title Here');
$plot->SetYTitle('Y Title Here');
# Set colors:
$plot->SetGridColor('blue');
$plot->SetLightGridColor('magenta');
$plot->SetTextColor('red');
$plot->SetTickColor('green');
$plot->SetTitleColor('gold');
$plot->DrawGraph();
Exemplo n.º 7
0
<?php

require 'amproot.php';
init_amp_root();
OpenLibrary('phplot.library');
$id = basename($_GET['id']);
$args = unserialize(file_get_contents(TMP_PATH . 'phplot/' . $id));
$graph = new PHPlot($args['width'], $args['height']);
$graph->SetIsInline('1');
//$graph->SetDataColors( array("blue",'white'),array("black") );
//$graph->$line_style = array('dashed','dashed','solid','dashed','dashed','solid');
// Base
$graph->SetDataValues($args['data']);
$graph->SetPlotType($args['plottype']);
// Appearance
$graph->SetPointShape($args['pointshape']);
$graph->SetPointSize($args['pointsize']);
$graph->SetTitle($args['title']);
// Color
$graph->SetBackgroundColor($args['backgroundcolor']);
$graph->SetGridColor($args['gridcolor']);
if (count($args['legend'])) {
    $graph->SetLegend($args['legend']);
}
$graph->SetLineWidth($args['linewidth']);
$graph->SetTextColor($args['textcolor']);
$graph->SetDataColors(array(array(145, 165, 207), array(114, 167, 112), array(71, 85, 159), array(175, 83, 50), array(247, 148, 53), array(240, 231, 125), array(154, 204, 203), array(201, 164, 196)), 'black');
//$graph->data_color = array( array(145,165,207), array(114,167,112), array(71,85,159), array(175,83,50), array(247,148,53), array(240,231,125), array(154,204,203), array(201,164,196) );
//array('blue','green','yellow','red','orange');
$graph->DrawGraph();
unlink(TMP_PATH . 'phplot/' . $id);
Exemplo n.º 8
0
        $row[] = sin($x + $i * $phase_factor);
    }
    $data[] = $row;
}
$plot = new PHPlot(1000, 800);
$plot->SetPlotType('linepoints');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetTitle("Line Plot, {$n} phases of Sin(x)");
$plot->SetPlotAreaWorld(0, -1, 2 * M_PI, 1);
# Range: [0,-1] : [2 Pi, 1]
$plot->SetXTickIncrement(M_PI / 8.0);
# X tick step
$plot->SetYTickIncrement(0.2);
# Y tick step
$plot->SetXLabelType('data', 3);
# Format X tick labels as N.NNN
$plot->SetLineStyles('solid');
# Make all lines solid
$plot->SetYLabelType('data', 1);
# Format Y tick labels as N.N
$plot->SetDrawXGrid(True);
# Draw X grid lines
$plot->SetDrawYGrid(True);
# Draw Y grid lines
# Because one of the data colors is almost white, switch to black background:
$plot->SetBackgroundColor('black');
$plot->SetTitleColor('white');
$plot->SetTextColor('white');
$plot->SetGridColor('white');
$plot->DrawGraph();
Exemplo n.º 9
0
$p = new PHPlot(800, 600);
$p->SetTitle($title);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetPlotType('points');
$p->SetLegend($legend);
$p->SetPlotAreaWorld(0, 0, 6, 6);
$p->SetPointSizes(8);
# Wide left margin, leaving room for legend:
$p->SetMarginsPixels(200);
# Put the legend to the left of plot area, starting about 1/4 down:
$p->SetLegendPosition(1, 0, 'plot', -0.1, 0.25);
# Colors:
if (!empty($image_bg_color)) {
    $p->SetBackgroundColor($image_bg_color);
}
if (!empty($plot_bg_color)) {
    $p->SetPlotBgColor($plot_bg_color);
    $p->SetDrawPlotAreaBackground(True);
}
if (!empty($legend_bg_color)) {
    $p->SetLegendBgColor($legend_bg_color);
}
$p->SetLegendUseShapes($use_shapes);
if (!empty($text_color)) {
    $p->SetTextColor($text_color);
}
if (!empty($legend_text_color)) {
    $p->SetLegendTextColor($legend_text_color);
}
$p->DrawGraph();