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
$p->SetLegend($legend);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetPlotType($plottype);
$p->SetPlotAreaWorld(0, 0, 5, 10);
$p->SetXDataLabelPos('none');
$p->SetXTickIncrement(1.0);
$p->SetYTickIncrement(1.0);
# Option: Use legend shape markers?
$p->SetLegendUseShapes($useshapes);
# Option: Use TT Font, set size and optional line spacing scale:
if (!empty($fontsize)) {
    $p->SetFontTTF('legend', $font, $fontsize, $linespacing);
}
# Option: Varying point shape sizes:
if ($setpointsizes) {
    $p->SetPointSizes(array(2, 4, 8, 10, 16));
}
# Turn on backgrounds for visibility.
$p->SetBackgroundColor('SkyBlue');
$p->SetDrawPlotAreaBackground(True);
$p->SetPlotBgColor('plum');
# Option: Change alignment of lines/color boxes in legend?
if (isset($textalign)) {
    $p->SetLegendStyle($textalign, $colorboxalign);
}
# Opton: Scale factor for color box width?
if (isset($colorboxwidth)) {
    $p->legend_colorbox_width = $colorboxwidth;
}
$p->DrawGraph();
	/**
	 * Adds raw image data of the graph to the output.
	 * @param $opts FormOptions
	 */
	public function draw( FormOptions $opts ) {
		global $wgTranslatePHPlotFont, $wgLang;

		$width = $opts->getValue( 'width' );
		$height = $opts->getValue( 'height' );
		// Define the object
		$plot = new PHPlot( $width, $height );

		list( $legend, $resData ) = $this->getData( $opts );
		$count = count( $resData );
		$skip = intval( $count / ( $width / 60 ) - 1 );
		$i = $count;

		foreach ( $resData as $date => $edits ) {
			if ( $skip > 0 ) {
				if ( ( $count - $i ) % $skip !== 0 ) $date = '';
			}

			if ( strpos( $date, ';' ) !== false ) {
				list( , $date ) = explode( ';', $date, 2 );
			}

			array_unshift( $edits, $date );
			$data[] = $edits;
			$i--;
		}

		$font = FCFontFinder::find( $wgLang->getCode() );

		if ( $font ) {
			$plot->SetDefaultTTFont( $font );
		} else {
			$plot->SetDefaultTTFont( $wgTranslatePHPlotFont );
		}
		$plot->SetDataValues( $data );

		if ( $legend !== null ) {
			$plot->SetLegend( $legend );
		}

		$numberFont = FCFontFinder::find( 'en' );

		$plot->setFont( 'x_label', $numberFont, 8 );
		$plot->setFont( 'y_label', $numberFont, 8 );

		$yTitle = wfMsg( 'translate-stats-' . $opts['count'] );

		// Turn off X axis ticks and labels because they get in the way:
		$plot->SetYTitle( $yTitle );
		$plot->SetXTickLabelPos( 'none' );
		$plot->SetXTickPos( 'none' );
		$plot->SetXLabelAngle( 45 );


		$max = max( array_map( 'max', $resData ) );
		$max = self::roundToSignificant( $max, 1 );
		$max = round( $max, intval( -log( $max, 10 ) ) );

		$yTick = 10;
		while ( $max / $yTick > $height / 20 ) {
			$yTick *= 2;
		}

		// If we have very small case, ensure that there is at least one tick
		$yTick = min( $max, $yTick );
		$yTick = self::roundToSignificant( $yTick );
		$plot->SetYTickIncrement( $yTick );
		$plot->SetPlotAreaWorld( null, 0, null, $max );


		$plot->SetTransparentColor( 'white' );
		$plot->SetBackgroundColor( 'white' );

		// Draw it
		$plot->DrawGraph();
	}
Exemplo n.º 4
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.º 5
0
<?php

session_start();
require_once 'phplot.php';
echo $_GET[countKeywords];
$data = array(array('新增文件', intval($_GET[countnew])), array('删除文件', intval($_GET[countdel])), array('修改文件', intval($_GET[countmodify])));
$plot = new PHPlot(350, 280);
$plot->SetTTFPath('./public');
$plot->SetDefaultTTFont('SIMHEI.TTF');
$plot->SetUseTTF(True);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetPlotBorderType('full');
$plot->SetBackgroundColor('#ffffcc');
$plot->SetDrawPlotAreaBackground(True);
$plot->SetPlotBgColor('#ffffff');
$plot->SetDataValues($data);
$plot->SetTitle("新增文件数:{$_GET['countnew']} 删除文件数:{$_GET['countdel']} 修改文件数:{$_GET['countmodify']}");
$plot->SetTitleColor('#D9773A');
foreach ($data as $row) {
    $plot->Setshading(10);
}
$plot->SetDataBorderColors('black');
$plot->DrawGraph();
	/**
	* Generate a graph for this tag
	* @param string $tag
	* @param string $filePath
	* @return bool, success
	*/
	public function makePngGraph( $tag, $filePath ) {
		if( !function_exists( 'ImageCreate' ) ) {
			// GD is not installed
			return false;
		}
		global $wgPHPlotDir, $wgMemc;
		require_once( "$wgPHPlotDir/phplot.php" ); // load classes
		// Define the object
		$plot = new PHPlot( 1000, 400 );
		// Set file path
		$dir = dirname($filePath);
		// Make sure directory exists
		if( !file_exists($dir) && !wfMkdirParents( $dir, 0777, __METHOD__ ) ) {
			throw new MWException( 'Could not create file directory!' );
		}
		$plot->SetOutputFile( $filePath );
		$plot->SetIsInline( true );
		$data = array();
		$totalVal = $totalCount = $n = 0;
		// Define the data using the DB rows
		list($res,$u,$maxC,$days) = $this->doQuery( $tag );
		if( !$maxC ) {
			return false;
		}
		// Label spacing
		$int = intval( ceil($days/10) ); // 10 labels at most
		foreach( $res as $row ) {
			$totalVal += (int)$row->rfh_total;
			$totalCount += (int)$row->rfh_count;
			$dayCount = (real)$row->rfh_count;
			if( !$row->rfh_count ) {
				continue; // bad data
			}
			// Nudge values up by 1
			$dayAve = 1 + (real)$row->rfh_total/(real)$row->rfh_count;
			$cumAve = 1 + (real)$totalVal/(real)$totalCount;
			$year = intval( substr( $row->rfh_date, 0, 4 ) );
			$month = intval( substr( $row->rfh_date, 4, 2 ) );
			$day = intval( substr( $row->rfh_date, 6, 2 ) );
			# Fill in days with no votes to keep spacing even
			if( isset($lastDate) ) {
				$dayGap = wfTimestamp(TS_UNIX,$row->rfh_date) - wfTimestamp(TS_UNIX,$lastDate);
				$x = intval( $dayGap/86400 );
				# Day gaps...
				for( $x; $x > 1; --$x ) {
					$data[] = array("",$lastDAve,$lastRAve,0);
					$n++;
				}
			}
			$n++;
			# Label point?
			if( $n >= $int || !count($data) ) {
				$p = ($days > 31) ? "{$month}-".substr( $year, 2, 2 ) : "{$month}/{$day}";
				$n = 0;
			} else {
				$p = "";
			}
			$data[] = array( $p, $dayAve, $cumAve, $dayCount );
			$lastDate = $row->rfh_date;
			$lastDAve = $dayAve;
			$lastRAve = $cumAve;
		}
		// Minimum sample size
		if( count($data) < 2 ) {
			return false;
		}
		// Re-scale voter count to fit to graph
		$this->dScale = ceil($maxC/5);
		// Cache the scale value to memory
		$key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period );
		$wgMemc->set( $key, $this->dScale, 7*24*3600 );
		// Fit to [0,4]
		foreach( $data as $x => $dataRow ) {
			$data[$x][3] = $dataRow[3]/$this->dScale;
		}
		$plot->SetDataValues($data);
		$plot->SetPointShapes( array('dot','dot','dot') );
		$plot->setPointSizes( array(1,1,4) );
		$plot->SetDataColors( array('blue','green','red') );
		$plot->SetLineStyles( array('solid','solid','solid') );
		$plot->SetBackgroundColor('#F8F8F8');
		// Turn off X axis ticks and labels because they get in the way:
		$plot->SetXTickLabelPos('none');
		$plot->SetXTickPos('none');
		$plot->SetYTickIncrement( .5 );
		// Set plot area
		$plot->SetPlotAreaWorld( 0, 0, null, 5 );
		// Show total number of votes
		$plot->SetLegend( array("#{$totalCount}") );
		// Draw it!
		$plot->DrawGraph();
		return true;
	}
Exemplo n.º 7
0
     $stat['data'][0][] = 0;
 }
 foreach ($plot_defaults as $key => $value) {
     if (!isset($stat[$key])) {
         $stat[$key] = $value;
     }
 }
 //Define the object
 $graph = new PHPlot($stat['xsize'], $stat['ysize']);
 $graph->SetDataType($stat['data_type']);
 $graph->SetFileFormat($stat['file_format']);
 $graph->SetPlotType($stat['graphtype']);
 $graph->SetDefaultTTFont('../tagsets/fonts/FreeSerif.ttf');
 $graph->SetPlotBorderType('none');
 // plotleft, plotright, both, full, none
 $graph->SetBackgroundColor($stat['background_color']);
 if ($stat['graphtype'] == 'bars') {
     $graph->SetShading(0);
     $graph->SetPlotAreaWorld(NULL, 0);
 }
 if (count($stat['legend']) > 0) {
     foreach ($stat['legend'] as $key => $val) {
         if (strlen($val) > 23) {
             $stat['legend'][$key] = substr($val, 0, 20) . '...';
         }
     }
     $graph->SetLegend($stat['legend']);
 }
 if ($stat['legend_x'] && $stat['legend_y']) {
     $graph->SetLegendPixels($stat['legend_x'], $stat['legend_y']);
 }
Exemplo n.º 8
0
# $Id$
# PHPlot test - Multiple Pie Charts, with label and other variations
require_once 'phplot.php';
$data = array(array('Gold', 20), array('Silver', 13), array('Copper', 7), array('Tin', 18), array('Bronze', 10), array('Iron', 4), array('Platinum', 2), array('Nickel', 5));
$data_type = 'text-data-single';
# Build legend from data array:
$legend = array();
foreach ($data as $row) {
    $legend[] = $row[0] . ' = ' . $row[1];
}
# Common setup for all plots on the image:
$plot = new PHPlot(800, 625);
$plot->SetTitle('Multiple pie charts');
$plot->SetPrintImage(False);
$plot->SetBackgroundColor('wheat');
$plot->SetDrawPlotAreaBackground(True);
$plot->SetPlotType('pie');
$plot->SetDataType($data_type);
$plot->SetDataValues($data);
$plot->SetPlotBorderType('full');
#$plot->SetLabelScalePosition(0.50);
# Plot 1 - upper left
$plot->SetPlotAreaPixels(4, 25, 398, 323);
$plot->SetPieLabelType('label');
$plot->SetPlotBgColor('plum');
$plot->DrawGraph();
# Plot 2 - upper right
$plot->SetPlotAreaPixels(402, 25, 797, 323);
$plot->SetPieLabelType('index');
$plot->SetPlotBgColor('salmon');
Exemplo n.º 9
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.º 10
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.º 11
0
# Create object
$p = new PHPlot($image_width, $image_height);
$p->SetPrintImage(0);
// Do not output image until told
# Set up for first plot:
$p->SetDataValues($data);
$p->SetDataType('text-data');
$p->SetPlotType($plot_type);
$p->SetXTickPos('none');
$p->SetYDataLabelPos('plotin');
$p->SetTitle($title);
$p->SetXTitle('X Axis Title');
$p->SetYTitle('Y Axis Title');
$p->SetDrawPlotAreaBackground(True);
$p->SetPlotBgColor('PeachPuff');
$p->SetBackgroundColor('lavender');
$p->SetImageBorderType('solid');
$p->SetImageBorderColor('navy');
$p->SetImageBorderWidth(3);
$p->SetPlotBorderType('full');
$p->SetLegend(array('Path A', 'Path B', 'Path C', 'Path D'));
switch ($legend_positioning) {
    case 'world':
        $p->SetLegendWorld(0.1, 35);
        break;
    case 'pixels':
        $p->SetLegendPixels(50, 50);
        break;
    case 'plotrelative':
        # This places the upper left corner of the legend box at an offset of
        # (5,5) from the upper left corner of the plot area.
Exemplo n.º 12
0
$legend = array('Data set 1', 'Data set 2', 'Error', 'Difference', 'Alternate');
$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);
}
include "/usr/lib/phplot/phplot.php";
include "/usr/lib/phplot/rgb.inc.php";
include "/tmp/plot.data.php";
// Test data
//$cvs_data = array(
//	array( "", "2000/03/15", 750),
//	array("", "2010/04/18", 1700),
//	array("", "2015/05/19", 2000),
//	array("", "2030/06/20", 400)
//	);
$graph = new PHPlot(238, 220);
$graph->SetIsInline("1");
$graph->SetDataType("text-data");
$graph->SetPlotType("bars");
$graph->SetDataValues($cvs_data);
// Specify plotting area details
$graph->SetImageArea(238, 220);
$graph->SetPlotAreaPixels(55, 20, 208, 190);
$graph->SetPrecisionY("0");
$graph->SetVertTickIncrement("100");
$graph->SetTickLength("5");
$graph->SetTitleFontSize("2");
$graph->SetPlotBgColor(204, 204, 204);
$graph->SetPlotBorderType("left");
$graph->SetBackgroundColor($ColorArray["gray80"]);
// Define the X axis
$graph->SetXLabel("Date");
// Define the Y axis
$graph->SetDataColors(array("blue", "red"), array("black"));
$graph->SetFileFormat("png");
$graph->DrawGraph();
Exemplo n.º 14
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.º 15
0
}
# Create a PHPlot object which will make a 600x400 pixel image:
$p = new PHPlot(850, 300);
# Use TrueType fonts:
$p->SetDefaultTTFont('phplot/simsun.ttc');
# Set the main plot title:
$p->SetTitle('版本非PASS测试例数量直方图');
# Select the data array representation and store the data:
$p->SetDataType('text-data');
$p->SetDataValues($data);
# Select the plot type - bar chart:
$p->SetPlotType('bars');
# Define the data range. PHPlot can do this automatically, but not as well.
//$p->SetPlotAreaWorld(0, 0, 7, 100);
# Select an overall image background color and another color under the plot:
$p->SetBackgroundColor('#CCDDED');
$p->SetDrawPlotAreaBackground(True);
$p->SetPlotBgColor('#CCDDED');
# Draw lines on all 4 sides of the plot:
$p->SetPlotBorderType('full');
# Set a 3 line legend, and position it in the upper left corner:
$p->SetLegend(array('No Pass'));
$p->SetLegendWorld(0.1, 95);
# Turn data labels on, and all ticks and tick labels off:
$p->SetXDataLabelPos('plotdown');
$p->SetXTickPos('none');
$p->SetXTickLabelPos('none');
$p->SetYTickPos('none');
$p->SetYTickLabelPos('none');
# Generate and output the graph now:
$p->DrawGraph();
Exemplo n.º 16
0
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require 'libs/phplot/phplot.php';
$color = array('DarkGreen', 'green', 'orange', 'blue', 'red', 'SkyBlue', 'purple', 'peru', 'cyan', 'salmon', 'SlateBlue', 'yellow', 'magenta', 'aquamarine1', 'gold', 'violet');
$data = $this->data;
$lebar = $this->lebar * 0.4;
$plot = new PHPlot($lebar, 250);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('pie');
$plot->SetDataType('text-data-single');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle('TIPE NASKAH ' . date('Y'));
$plot->SetBackgroundColor('#eeeeff');
# Make a legend for the 3 data sets plotted:
# Turn off X tick labels and ticks because they don't apply here:
$plot->SetDataColors(array('lavender', 'red', 'green', 'blue', 'yellow', 'SlateBlue', 'cyan', 'magenta', 'brown', 'pink', 'gray', 'orange', 'purple', 'peru', 'salmon', 'aquamarine1', 'violet', 'gold'));
$plot->SetDataColors($color);
foreach ($data as $row) {
    $plot->SetLegend(implode(': ', $row));
}
# Place the legend in the upper left corner:
$plot->SetLegendPixels(5, 5);
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->DrawGraph();
Exemplo n.º 17
0
<?php

# $Id$
# PHPlot error test - invalid color name
require_once 'phplot.php';
$data = array(array('a', 1, 1), array('b', 2, 3), array('c', 3, 5));
$plot = new PHPlot();
$plot->SetBackgroundColor('solid');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
$plot->SetPlotType('lines');
$plot->DrawGraph();
Exemplo n.º 18
0
# This really needs to be displayed in a browser above something to see.
# This is a parameterized test. Other scripts can set $tp and then include
# this script. The parameters are shown in the defaults array below:
if (!isset($tp)) {
    $tp = array();
}
$tp = array_merge(array('title' => 'Transparent Background', 'suffix' => " (default)", 'FFormat' => NULL), $tp);
require_once 'phplot.php';
$data = array(array('', -4, -64, 16, 40), array('', -3, -27, 9, 30), array('', -2, -8, 4, 20), array('', -1, -1, 1, 10), array('', 0, 0, 0, 0), array('', 1, 1, 1, -10), array('', 2, 8, 4, -20), array('', 3, 27, 9, -30), array('', 4, 64, 16, -40));
$p = new PHPlot();
# File format GIF or PNG, to test transparency:
if (isset($tp['FFormat'])) {
    $p->SetFileFormat($tp['FFormat']);
}
# Background color will be transparent:
$p->SetBackgroundColor('yellow');
$p->SetTransparentColor('yellow');
$p->SetTitle($tp['title'] . $tp['suffix']);
$p->SetDataType('data-data');
$p->SetDataValues($data);
# We don't use the data labels (all set to '') so might as well turn them off:
$p->SetXDataLabelPos('none');
# Need to set area and ticks to get reasonable choices.
$p->SetPlotAreaWorld(-4, -70, 4, 80);
$p->SetXTickIncrement(1);
$p->SetYTickIncrement(10);
# Don't use dashes for 3rd line:
$p->SetLineStyles('solid');
# Make the lines thicker:
$p->SetLineWidths(3);
# Draw both grids:
Exemplo n.º 19
0
<?php

# PHPlot Example - Horizontal Bars
require_once 'phplot.php';
$data = array(array('San Francisco CA', 20.11), array('Reno NV', 7.5), array('Phoenix AZ', 8.300000000000001), array('New York NY', 49.7), array('New Orleans LA', 64.2), array('Miami FL', 52.3), array('Los Angeles CA', 13.2), array('Honolulu HI', 18.3), array('Helena MT', 11.3), array('Duluth MN', 31.0), array('Dodge City KS', 22.4), array('Denver CO', 15.8), array('Burlington VT', 36.1), array('Boston MA', 42.5), array('Barrow AL', 4.2));
$plot = new PHPlot(800, 800);
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->SetTitle("Average Annual Precipitation (inches)\n" . "Selected U.S. Cities");
$plot->SetBackgroundColor('gray');
#  Set a tiled background image:
$plot->SetPlotAreaBgImage('images/drop.png', 'centeredtile');
#  Force the X axis range to start at 0:
$plot->SetPlotAreaWorld(0);
#  No ticks along Y axis, just bar labels:
$plot->SetYTickPos('none');
#  No ticks along X axis:
$plot->SetXTickPos('none');
#  No X axis labels. The data values labels are sufficient.
$plot->SetXTickLabelPos('none');
#  Turn on the data value labels:
$plot->SetXDataLabelPos('plotin');
#  No grid lines are needed:
$plot->SetDrawXGrid(FALSE);
#  Set the bar fill color:
$plot->SetDataColors('salmon');
#  Use less 3D shading on the bars:
$plot->SetShading(2);
$plot->SetDataValues($data);
$plot->SetDataType('text-data-yx');
$plot->SetPlotType('bars');
Exemplo n.º 20
0
  license@systemsmanager.net so we can mail you a copy immediately.
*/
include DIR_WS_CLASSES . 'phplot.php';
$year = $_GET['year'] ? $_GET['year'] : date('Y');
$month = $_GET['month'] ? $_GET['month'] : date('n');
$days = date('t', mktime(0, 0, 0, $month)) + 1;
$stats = array();
for ($i = 1; $i < $days; $i++) {
    $stats[] = array($i, '0', '0');
}
$banner_stats_query = smn_db_query("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . "'");
while ($banner_stats = smn_db_fetch_array($banner_stats_query)) {
    $stats[$banner_stats['banner_day'] - 1] = array($banner_stats['banner_day'], $banner_stats['value'] ? $banner_stats['value'] : '0', $banner_stats['dvalue'] ? $banner_stats['dvalue'] : '0');
}
$graph = new PHPlot(600, 350, 'images/graphs/banner_daily-' . $banner_id . '.' . $banner_extension);
$graph->SetFileFormat($banner_extension);
$graph->SetIsInline(1);
$graph->SetPrintImage(0);
$graph->SetSkipBottomTick(1);
$graph->SetDrawYGrid(1);
$graph->SetPrecisionY(0);
$graph->SetPlotType('lines');
$graph->SetPlotBorderType('left');
$graph->SetTitleFontSize('4');
$graph->SetTitle(sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0, 0, 0, $month)), $year));
$graph->SetBackgroundColor('white');
$graph->SetVertTickPosition('plotleft');
$graph->SetDataValues($stats);
$graph->SetDataColors(array('blue', 'red'), array('blue', 'red'));
$graph->DrawGraph();
$graph->PrintImage();
Exemplo n.º 21
0
 $WhereClause = "WHERE " . $WhereClause . " salesanalysis.periodno>=" . $_POST['FromPeriod'] . " AND salesanalysis.periodno <= " . $_POST['ToPeriod'];
 $SQL = "SELECT salesanalysis.periodno,\n\t\t\t\tperiods.lastdate_in_period,\n\t\t\t\tSUM(CASE WHEN budgetoractual=1 THEN " . $SelectClause . " ELSE 0 END) AS sales,\n\t\t\t\tSUM(CASE WHEN  budgetoractual=0 THEN " . $SelectClause . " ELSE 0 END) AS budget\n\t\tFROM salesanalysis INNER JOIN periods ON salesanalysis.periodno=periods.periodno " . $WhereClause . "\n\t\tGROUP BY salesanalysis.periodno,\n\t\t\tperiods.lastdate_in_period\n\t\tORDER BY salesanalysis.periodno";
 $graph->SetTitle($GraphTitle);
 $graph->SetTitleColor('blue');
 $graph->SetOutputFile('companies/' . $_SESSION['DatabaseName'] . '/reports/salesgraph.png');
 $graph->SetXTitle(_('Month'));
 if ($_POST['GraphValue'] == 'Net') {
     $graph->SetYTitle(_('Sales Value'));
 } elseif ($_POST['GraphValue'] == 'GP') {
     $graph->SetYTitle(_('Gross Profit'));
 } else {
     $graph->SetYTitle(_('Quantity'));
 }
 $graph->SetXTickPos('none');
 $graph->SetXTickLabelPos('none');
 $graph->SetBackgroundColor('selection');
 $graph->SetTitleColor('blue');
 $graph->SetFileFormat('png');
 $graph->SetPlotType($_POST['GraphType']);
 $graph->SetIsInline('1');
 $graph->SetShading(5);
 $graph->SetDrawYGrid(TRUE);
 $graph->SetDataType('text-data');
 $SalesResult = DB_query($SQL, $db);
 if (DB_error_no($db) != 0) {
     prnMsg(_('The sales graph data for the selected criteria could not be retrieved because') . ' - ' . DB_error_msg($db), 'error');
     include 'includes/footer.inc';
     exit;
 }
 if (DB_num_rows($SalesResult) == 0) {
     prnMsg(_('There is not sales data for the criteria entered to graph'), 'info');