Exemplo n.º 1
0
# Testing phplot - "Typical" plot with lots of elements, for manual
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));
# Size of plot is set by PDF 72dpi resolution:
$p = new PHPlot(400, 300);
$p->SetDataType('data-data');
$p->SetDataValues($data);
# Titles:
$p->SetTitle('A Plot Containing Some Lines');
$p->SetXTitle('Independent Variable');
$p->SetYTitle('Dependent Variable');
# 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(array('solid', 'dashed', 'solid'));
# Make the lines thicker:
$p->SetLineWidths(2);
# Image border:
$p->SetImageBorderType('raised');
$p->SetImageBorderColor('blue');
# Draw both grids:
$p->SetDrawXGrid(True);
$p->SetDrawYGrid(True);
# And a legend:
$p->SetLegend(array('x^3', 'x^2', '-10x'));
$p->SetPlotType('lines');
$p->DrawGraph();
Exemplo n.º 2
0
$title = "Test Attribute Resets:\n";
if (empty($test_resets)) {
    $title .= 'Baseline - red border, formatted labels';
} else {
    $title .= 'Reset to no border, no label formatting';
}
$plot = new PHPlot(400, 400);
$plot->SetTitle($title);
$plot->SetPlotType('lines');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotAreaWorld(-1000, 0);
$plot->SetXDataLabelPos('none');
$plot->SetXTickIncrement(500);
$plot->SetXLabelType('data', 0, '', 'M');
$plot->SetYTickIncrement(200000);
$plot->SetYLabelType('data', 2);
$plot->SetImageBorderType('raised');
$plot->SetImageBorderColor('red');
$plot->SetDrawXGrid(False);
$plot->SetDrawYGrid(False);
# Set $test_resets=True and include this file to test resets:
if (!empty($test_resets)) {
    # Reset to no border:
    $plot->SetImageBorderType('none');
    # Reset X to no formatting using empty string:
    $plot->SetXLabelType('');
    # Reset Y to no formatting using no argument:
    $plot->SetYLabelType();
}
$plot->DrawGraph();
Exemplo n.º 3
0
$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.
        $p->SetLegendPosition(0, 0, 'plot', 0, 0, 5, 5);
        break;
Exemplo n.º 4
0
} else {
    $message .= $text;
}
if (!empty($extra_chars)) {
    $message .= str_repeat(' Test', (int) ($extra_chars / 5));
}
$p = new PHPlot(800, 600);
if (!empty($use_gdfont)) {
    $p->SetFontGD('generic', 5);
} elseif (!empty($use_ttfont)) {
    $p->SetTTFPath($phplot_test_ttfdir);
    $p->SetFontTTF('generic', $phplot_test_ttfonts['serifitalic'], 14);
}
if (!empty($set_bgcolor)) {
    $p->SetBackgroundColor('yellow');
}
if (!empty($set_bgimage)) {
    $p->SetBgImage('images/bubbles.png', 'tile');
}
if (!empty($set_border)) {
    $p->SetImageBorderWidth(3);
    $p->SetImageBorderColor('red');
    $p->SetImageBorderType('raised');
}
if (!empty($noprint)) {
    $p->SetPrintImage(False);
}
$p->DrawMessage($message, $options);
if (!empty($noprint)) {
    echo $p->EncodeImage('raw');
}
Exemplo n.º 5
0
$p->SetTitle($title);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetDrawXGrid(False);
$p->SetDrawYGrid(False);
if (!empty($tp['plotborder'])) {
    $p->SetPlotBorderType($tp['plotborder']);
}
if (!empty($tp['pbcolor'])) {
    $p->SetGridColor($tp['pbcolor']);
}
if (!empty($tp['imageborder'])) {
    $p->SetImageBorderType($tp['imageborder']);
}
if (!empty($tp['ibcolor'])) {
    $p->SetImageBorderColor($tp['ibcolor']);
}
if (!empty($tp['ibwidth'])) {
    $p->SetImageBorderWidth($tp['ibwidth']);
}
# Move Y axis in so affect of plot area borders is more visible:
$p->SetYAxisPosition(0);
# Turn on all side labels, ticks, titles:
$p->SetXTickLabelPos('both');
$p->SetXTickPos('both');
$p->SetYTickLabelPos('both');
$p->SetYTickPos('both');
$p->SetPlotType('lines');
$p->SetXTitle('X Axis Title Here', 'both');
$p->SetYTitle('Y Axis Title Here', 'both');
$p->DrawGraph();