Example #1
0
include 'lib/jpgraph/src/jpgraph.php';
include 'lib/jpgraph/src/jpgraph_bar.php';
function colorized($p, $fd = NULL)
{
    return $fd === true ? 'red' : ($p < 50 ? 'white' : ($p < 80 ? 'lightgray' : ($p <= 100 ? 'lightgreen' : ($p < 110 ? 'orange' : 'red'))));
}
// Get data from client
$w = isset($_REQUEST['w']) ? $_REQUEST['w'] : 320;
$h = isset($_REQUEST['h']) ? $_REQUEST['h'] : 240;
$t = isset($_REQUEST['t']) ? str_replace('_', ' ', $_REQUEST['t']) : 'Bar chart';
$x = isset($_REQUEST['d']) ? explode(',', $_REQUEST['d']) : array();
$y = isset($_REQUEST['u']) ? explode(',', $_REQUEST['u']) : array();
$f = isset($_REQUEST['f']) ? explode(',', $_REQUEST['f']) : array();
$c = array();
foreach ($y as $i => $v) {
    $c[] = colorized($v, $f[$i] == 0) . '@0.30';
}
// Create the graph.
$graph = new Graph($w, $h);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Adjust the margin slightly so that we use the
// entire area (since we don't use a frame)
$graph->SetMargin(30, 1, 20, 5);
// Box around plotarea
$graph->SetBox();
// No frame around the image
$graph->SetFrame(false);
// Setup the tab title
$graph->tabtitle->Set('  ' . $t . '  ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 12);
Example #2
0
<?php

use mageekguy\atoum;
define('TEST_ROOT', __DIR__ . DIRECTORY_SEPARATOR . 'tests');
function colorized()
{
    $color = -1;
    if (false !== ($term = getenv('TERM'))) {
        if (preg_match('/\\d+/', $term, $matches) > 0) {
            $color = $matches[0];
        }
    }
    if ($color < 0) {
        $color = system('tput colors 2> /dev/null');
    }
    return $color >= 256;
}
if (colorized()) {
    $script->addDefaultReport()->addField(new atoum\report\fields\runner\atoum\logo())->addField(new atoum\report\fields\runner\result\logo());
}
$script->noCodeCoverageForNamespaces('mageekguy');
$script->bootstrapFile(TEST_ROOT . DIRECTORY_SEPARATOR . 'bootstrap.php');
$runner->addTestsFromDirectory(TEST_ROOT . DIRECTORY_SEPARATOR . 'units');