Exemple #1
0
}
test('New PHPlot object', $p, $dcol, $bcol, $ecol);
$p->SetDataColors('red');
$p->SetDataBorderColors('blue');
$p->SetErrorBarColors('green');
test('Then set color arrays to single word', $p, 1, 1, 1);
$p = new PHPlot_pv();
$p->SetDataColors($c6);
$p->SetDataBorderColors($c6);
$p->SetErrorBarColors($c6);
test('New object, set color arrays to array of 6', $p, 6, 6, 6);
$p->SetDataColors();
$p->SetDataBorderColors();
$p->SetErrorBarColors();
test('Then use NULL, should be ignored', $p, 6, 6, 6);
$p->SetDataColors('');
$p->SetDataBorderColors('');
$p->SetErrorBarColors('');
test('Then set color arrays to default, using empty string', $p, $dcol, $bcol, $ecol);
$p = new PHPlot_pv();
$p->SetDataColors($c6);
$p->SetDataColors(False);
$p->SetDataBorderColors(False);
$p->SetErrorBarColors(False);
test('New object, using False also sets color arrays to default', $p, $dcol, $bcol, $ecol);
# ======== End of test cases and error reporting ==========
echo "setcolors results: {$n_tests} test cases, {$n_pass} pass, {$n_fail} fail\n";
if ($n_fail > 0) {
    exit(1);
}
# PHPlot test suite requires falling off the end, not exit, on success.
Exemple #2
0
function pmarg_test($call_SetMarginsPixels, $args_SetMarginsPixels, $call_SetPlotAreaPixels, $args_SetPlotAreaPixels, $return_margins)
{
    global $data, $margins_override, $plotarea_override;
    $p = new PHPlot_pv(PLOT_WIDTH, PLOT_HEIGHT);
    $p->SetTitle("Unused Title Goes Here");
    $p->SetDataType('data-data');
    $p->SetDataValues($data);
    $p->SetPlotType('lines');
    $p->SetXTickLabelPos('none');
    $p->SetXTickIncrement(1.0);
    $p->SetYTickIncrement(10.0);
    $p->SetYTickPos('both');
    $p->SetYTickLabelPos('both');
    $p->SetDrawXGrid(False);
    $p->SetDrawYGrid(False);
    $p->SetXTitle("Two Line\nX Axis Title");
    $p->SetYTitle("Three Line\nY Axis\nTitle");
    # Variant cases:
    if ($call_SetMarginsPixels) {
        call_user_func_array(array($p, 'SetMarginsPixels'), array_mask($margins_override, $args_SetMarginsPixels, 4));
    }
    if ($call_SetPlotAreaPixels) {
        call_user_func_array(array($p, 'SetPlotAreaPixels'), array_mask($plotarea_override, $args_SetPlotAreaPixels, 4));
    }
    # Produce but don't output the image. Comment out to test the test.
    $p->SetPrintImage(False);
    # Produce the graph:
    $p->DrawGraph();
    # Return the resulting margins or coordinates, as requested.
    $plot_area = $p->GET_plot_area();
    if ($return_margins) {
        return array($plot_area[0], PLOT_WIDTH - $plot_area[2], $plot_area[1], PLOT_HEIGHT - $plot_area[3]);
    }
    return $plot_area;
}
Exemple #3
0
<?php

# $Id$
# Testing phplot - Default TT font (1a): No default path or font set, usettf
require_once 'phplot.php';
// Extend PHPlot class to allow access to protected variable(s):
class PHPlot_pv extends PHPlot
{
    public function GET_default_ttfont()
    {
        return $this->default_ttfont;
    }
}
$data = array(array('A', 3, 6), array('B', 2, 4), array('C', 1, 2));
$p = new PHPlot_pv(800, 800);
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotType('bars');
$p->SetTitle('TTF default not set, SetUseTTF(true)');
$p->SetXTitle('X Axis Title');
$p->SetYTitle('Y Axis Title');
$p->SetUseTTF(True);
$p->DrawGraph();
fwrite(STDERR, "OK defaultfont1a: default_ttfont=" . $p->GET_default_ttfont() . "\n");
Exemple #4
0
<?php

# $Id$
# Testing phplot - Default TT font (2a): Local path and default font.
# This test requires a specific font (see TEST_FONT) be present in the images/
# directory. The listed font is redistributable under the Open Fonts License.
require_once 'phplot.php';
define('TEST_FONT', 'FreeUniversal-Regular.ttf');
// Extend PHPlot class to allow access to protected variable(s):
class PHPlot_pv extends PHPlot
{
    public function GET_default_ttfont()
    {
        return $this->default_ttfont;
    }
}
$data = array(array('A', 3, 6), array('B', 2, 4), array('C', 1, 2));
$p = new PHPlot_pv(800, 800);
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotType('bars');
$p->SetTitle('Local TTF path and default font');
$p->SetXTitle('X Axis Title');
$p->SetYTitle('Y Axis Title');
$p->SetTTFPath(getcwd() . DIRECTORY_SEPARATOR . 'images');
$p->SetDefaultTTFont(TEST_FONT);
$p->SetUseTTF(True);
$p->DrawGraph();
fwrite(STDERR, "OK defaultfont2a: default_ttfont=" . $p->GET_default_ttfont() . "\n");
Exemple #5
0
}
$errors = 0;
$mime_type = 'image/jpeg';
# Data arrays for 2 frames, text-data.
$data1 = array(array('', 1, 2, 3), array('', 2, 4, 6), array('', 3, 6, 9));
$data2 = array(array('', 2, 4, 6), array('', 3, 6, 9), array('', 4, 8, 6));
# Check the overall structure of a frame. Return True if OK, else False.
# Frame needs: boundary, content type and content length, then the image.
# This does nothing with the image (there is another test for that).
function check_frame($frame, $boundary)
{
    global $mime_type;
    return preg_match("--{$boundary}\\s", $frame) && preg_match("Content-Type: {$mime_type}\\si", $frame) && preg_match("Content-Length: (\\d*)\\si", $frame);
}
# Initial plot object setup:
$plot = new PHPlot_pv(640, 480);
$plot->SetDataType('text-data');
$plot->SetPlotType('lines');
$plot->SetFileFormat('jpg');
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->SetXDataLabelPos('none');
$plot->SetPlotAreaWorld(NULL, 0, NULL, 10);
$plot->SetPrintImage(False);
# StartStream does no output, only headers (which we cannot catch using the
# CLI), so just check the variables it sets:
$plot->StartStream();
$boundary = $plot->GET_stream_boundary();
# Check: Stream frame header includes content-type with expected MIME type
$sfh = $plot->GET_stream_frame_header();
if (!preg_match("Content-Type: {$mime_type}", $sfh)) {
Exemple #6
0
<?php

# $Id$
# Testing phplot - Color Chart
require_once 'phplot.php';
// Extend PHPlot class to allow access to protected variable(s):
class PHPlot_pv extends PHPlot
{
    public function GET_rgb_array()
    {
        return $this->rgb_array;
    }
}
$p = new PHPlot_pv(800, 700);
# Use internal color map rgb_array to get a list of colors:
$colors = array_keys($p->GET_rgb_array());
sort($colors);
$nc = count($colors);
# Make a data array with 1 point, $nc data sets:
$dp = array('');
for ($i = 0; $i < $nc; $i++) {
    $dp[] = $nc - $i;
}
$data = array($dp);
$p->SetPlotType('bars');
$p->SetDataType('text-data');
$p->SetDataValues($data);
# Use all colors:
$p->SetDataColors($colors);
$p->SetShading(0);
# Make a legend with all the color names:
Exemple #7
0
# $Id$
# PHPlot Example: Line-Point plot showing point shapes
# If the variable $use_default_shapes is set (from a calling script), show
# the default shapes, otherwise show all shapes.
require_once 'phplot.php';
// Extend PHPlot class to allow access to protected variable(s):
class PHPlot_pv extends PHPlot
{
    public function GET_point_shapes()
    {
        return $this->point_shapes;
    }
}
# This is a list of selected colors in the PHPlot 'small' map:
$colors = array('orange', 'blue', 'maroon', 'red', 'peru', 'cyan', 'black', 'gold', 'purple', 'YellowGreen', 'SkyBlue', 'green', 'SlateBlue', 'navy', 'aquamarine1', 'violet', 'salmon', 'brown', 'pink', 'DimGrey');
$plot = new PHPlot_pv(800, 600);
# Define the $shapes array, used for both the point shapes and legend:
if (isset($use_default_shapes)) {
    # Cheat: grab phplot's internal shapes
    $shapes = $plot->GET_point_shapes();
    $title_suffix = ' (PHPlot Defaults)';
} else {
    $shapes = array('bowtie', 'box', 'circle', 'cross', 'delta', 'diamond', 'dot', 'down', 'halfline', 'home', 'hourglass', 'line', 'plus', 'rect', 'star', 'target', 'triangle', 'trianglemid', 'up', 'yield');
    $title_suffix = ' (All Shapes)';
}
# Number of shapes defines the number of lines to draw:
$n_shapes = count($shapes);
# Make offset diagonal lines, one for each shape:
$ppl = 6;
# Number of points per line.
$data = array();