Beispiel #1
4
function test_case($case)
{
    global $cases, $test_verbose, $n_tests, $n_pass, $n_fail, $test_save;
    $n_tests++;
    extract($cases[$case]);
    $title = "Test case {$n_tests}: {$data_type} (should match {$like})";
    # Make a data array that is valid (but not necessarily reasonable)
    # for any data type. One works for all except pie chart.
    if (!empty($pie)) {
        $plot_type = 'pie';
        $data = array(array('', 1), array('', 1), array('', 2));
    } else {
        $plot_type = 'lines';
        # Valid for text-data, data-data, and data-data-error:
        $data = array(array('', 1, 2, 2, 2), array('', 2, 4, 1, 1), array('', 3, 5, 2, 2));
    }
    $p1 = new PHPlot(400, 300);
    $p1->SetFailureImage(False);
    $p1->SetPrintImage(False);
    $p1->SetDataValues($data);
    $p1->SetDataType($data_type);
    // Alias data type
    $p1->SetPlotType($plot_type);
    $p1->DrawGraph();
    $p1_image = $p1->EncodeImage('raw');
    if ($test_save) {
        file_put_contents("dta-{$case}a_{$data_type}.png", $p1_image);
    }
    $p2 = new PHPlot(400, 300);
    $p2->SetFailureImage(False);
    $p2->SetPrintImage(False);
    $p2->SetDataValues($data);
    $p2->SetDataType($like);
    // Base data type - alias should match this
    $p2->SetPlotType($plot_type);
    $p2->DrawGraph();
    $p2_image = $p2->EncodeImage('raw');
    if ($test_save) {
        file_put_contents("dta-{$case}b_{$like}.png", $p2_image);
    }
    if ($p1_image == $p2_image) {
        $n_pass++;
        if ($test_verbose) {
            echo "Pass: {$title}\n";
        }
    } else {
        $n_fail++;
        echo "FAIL - Image Mismatch: {$title}\n";
    }
}
Beispiel #2
1
function graficoBarra($data, $archivo = "", $meta_data = array('titulo' => 'Sin Título', 'tituloX' => 'Eje X', 'tituloY' => 'Eje Y', 'color' => 'SkyBlue', 'width' => 800, 'height' => 600, 'angle' => 45), $legend = array("Datos"))
{
    # Objeto que crea el gráfico y su tama?o
    $plot = new PHPlot($meta_data['width'], $meta_data['height']);
    $plot->SetImageBorderType('plain');
    # Setea el archivo donde se guarda la imagen generada y no permite la visualización inmediata
    $plot->SetPrintImage(false);
    $plot->SetFileFormat("jpg");
    $plot->SetOutputFile($archivo);
    $plot->SetIsInline(true);
    # Envio de datos
    $plot->SetDataValues($data);
    # Tipo de gráfico y datos
    $plot->SetDataType("text-data");
    $plot->SetPlotType("bars");
    # Setiando el True type font
    //$plot->SetTTFPath(TTFPath);
    //$plot->SetUseTTF(TRUE);
    $plot->SetAxisFontSize(2);
    $plot->SetVertTickIncrement(7);
    //$plot->SetXTickLength(7);
    //$plot->SetDataColors($meta_data['color']);
    $plot->SetDataColors(array($meta_data['color'], 'red', 'white'));
    $plot->SetLegendPixels(1, 1);
    $plot->SetLegend($legend);
    # Etiquetas del eje Y:
    $plot->SetYTitle($meta_data['tituloY']);
    $plot->SetYDataLabelPos('plotin');
    # Título principal del gráfico:
    $plot->SetTitle($meta_data['titulo']);
    # Etiquetas eje X:
    $plot->SetXTitle($meta_data['tituloX']);
    if (isset($meta_data['angle'])) {
        $plot->SetXLabelAngle($meta_data['angle']);
    } else {
        $plot->SetXLabelAngle(45);
    }
    $plot->SetXTickLabelPos('none');
    $plot->SetXTickPos('none');
    # Método que dibuja el gráfico
    $plot->DrawGraph();
    $plot->PrintImage();
}
Beispiel #3
1
<?php

# $Id$
# PHPlot error test - semantic error - mismatched data type and plot type
require_once 'phplot.php';
$data = array(array('a', 1, 1), array('b', 2, 3), array('c', 3, 5));
$plot = new PHPlot();
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotType('bars');
$plot->DrawGraph();
Beispiel #4
0
 /**
  * Create PHPlot instance initializing common options
  *
  * @param int $width
  * @param int $height
  * @return PHPlot
  */
 private function create($width, $height)
 {
     $plot = new PHPlot($width, $height);
     $plot->SetTTFPath($this->fonts_path);
     $plot->SetUseTTF(true);
     return $plot;
 }
Beispiel #5
0
 function __construct($output_file, $plot_type, $data_type, $data_values)
 {
     parent::__construct(64, 64, $output_file);
     $this->SetIsInline(True);
     // Needed to output to file
     # Turn everything off - just a plot in a box.
     $this->SetMarginsPixels(2, 2, 2, 2);
     $this->SetPlotBorderType('none');
     $this->SetXDataLabelPos('none');
     $this->SetXTickLabelPos('none');
     $this->SetXTickPos('none');
     $this->SetYDataLabelPos('none');
     $this->SetYTickLabelPos('none');
     $this->SetYTickPos('none');
     $this->SetDrawXGrid(False);
     $this->SetDrawYGrid(False);
     $this->SetDrawXAxis(False);
     $this->SetDrawYAxis(False);
     $this->SetPlotType($plot_type);
     $this->SetDataType($data_type);
     $this->SetDataValues($data_values);
     $this->SetDataColors(array('red', 'blue', 'DarkGreen', 'magenta'));
     $this->SetShading(0);
     $this->SetLabelScalePosition(0);
     // Turn off pie chart labels
     $this->SetLineStyles('solid');
 }
Beispiel #6
0
function test_init()
{
    global $returns_alpha, $p, $test_verbose;
    $p = new PHPlot();
    // Global
    # Determine if SetRGBColor returns a 3 or 4 element array:
    $test_array = $p->SetRGBColor('');
    if (count($test_array) == 3) {
        $style = "3 element arrays (old style)";
        $returns_alpha = False;
    } elseif (count($test_array) == 4) {
        $style = "4 element arrays (new style)";
        $returns_alpha = True;
    } else {
        fwrite(STDERR, "u.colors: Unexpected return style from SetRGBArray\n");
        exit(1);
    }
    if ($test_verbose) {
        echo "Checking SetRGBColor return: {$style}\n";
    }
}
Beispiel #7
0
function test_init()
{
    global $returns_alpha, $p, $q, $test_verbose;
    $p = new PHPlot_truecolor();
    // Global
    $q = new PHPlot();
    // Global
    # Determine if SetRGBColor returns a 3 or 4 element array for the base
    # class, and keeps the alpha value:
    $test_array = $q->SetRGBColor(array(10, 10, 10, 10));
    if (count($test_array) == 3) {
        $style = "3 element arrays (old style)";
        $returns_alpha = False;
    } elseif (count($test_array) == 4 && $test_array[3] != 0) {
        $style = "4 element arrays (new style, with alpha)";
        $returns_alpha = True;
    } else {
        fwrite(STDERR, "u.colors: Unexpected return style from SetRGBArray\n");
        exit(1);
    }
    if ($test_verbose) {
        echo "Checking SetRGBColor return: {$style}\n";
    }
}
Beispiel #8
0
<?php

//Include the code
include "../phplot.php";
//Define the object
$graph = new PHPlot();
//Define some data
include "./data.php";
$graph->SetDataValues($example_data);
//Don't print until we say so
$graph->SetPrintImage(0);
//Draw it
$graph->DrawGraph();
//Define some colors
$ndx_color = $graph->SetIndexColor("blue");
$ndx_color1 = $graph->SetIndexColor("orange");
//The image data colors are now ndx_data_color[]
$graph->DrawDashedLine(250, $graph->plot_area[1], 250, 250, 4, 0, $graph->ndx_data_color[0]);
$graph->DrawDashedLine($graph->xtr(5), $graph->ytr(12), $graph->xtr(20), $graph->ytr(42), 5, 3, $ndx_color);
$graph->DrawDashedLine($graph->plot_area[0], 250, $graph->plot_area[2], 250, 2, 0, $ndx_color1);
$graph->DrawDashedLine($graph->plot_area[0], 251, $graph->plot_area[2], 251, 2, 0, $ndx_color1);
//Now print the image
$graph->PrintImage();
Beispiel #9
0
<?php

# $Id$
# PHPlot Example: Pie/text-data-single
require_once 'phplot.php';
# The data labels aren't used directly by PHPlot. They are here for our
# reference, and we copy them to the legend below.
$data = array(array('Australia', 7849), array('Dem Rep Congo', 299), array('Canada', 5447), array('Columbia', 944), array('Ghana', 541), array('China', 3215), array('Philippines', 791), array('South Africa', 19454), array('Mexico', 311), array('United States', 9458), array('USSR', 9710));
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('pie');
$plot->SetDataType('text-data-single');
$plot->SetDataValues($data);
# Set enough different colors;
$plot->SetDataColors(array('red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'brown', 'lavender', 'pink', 'gray', 'orange'));
# Main plot title:
$plot->SetTitle("World Gold Production, 1990\n(1000s of Troy Ounces)");
# Build a legend from our data array.
# Each call to SetLegend makes one line as "label: value".
foreach ($data as $row) {
    $plot->SetLegend(implode(': ', $row));
}
$plot->DrawGraph();
Beispiel #10
0
<?php

# $Id$
# PHPlot test: Overlay OHLC chart with lines
# From PHPlot forum 2010-12-20
require_once 'phplot.php';
// First data array for OHLC data: Date, Open, High, Low, Close
$data1 = array(array('Dec  6', 20, 24, 19, 22), array('Dec  7', 22, 26, 20, 26), array('Dec  8', 26, 28, 22, 24), array('Dec  9', 24, 30, 22, 28), array('Dec 10', 28, 30, 15, 18));
$n_points = count($data1);
// Second data array contains two lines, calculated from above.
// 1st is opening prices, 2nd is middle of the daily range = (low+high)/2.
$data2 = array();
for ($i = 0; $i < $n_points; $i++) {
    $data2[] = array('', $data1[$i][1], ($data1[$i][2] + $data1[$i][3]) / 2);
}
$p = new PHPlot(800, 600);
$p->SetPrintImage(0);
// Do not output image until told
// First plot:
$p->SetDataValues($data1);
$p->SetDataType('text-data');
$p->SetPlotType('ohlc');
$p->SetPlotAreaWorld(NULL, 0);
// For Y to start at 0
$p->SetXTickPos('none');
$p->SetTitle('OHLC and Line Plot Overlay');
$p->SetXTitle('Date', 'plotdown');
$p->SetYTitle('Security Price', 'plotleft');
$p->SetDrawPlotAreaBackground(True);
$p->SetPlotBgColor('PeachPuff');
$p->SetMarginsPixels(50, 50, 50, 50);
Beispiel #11
0
<?php

# $Id$
# Test: Area plot with non-decreasing, 0, and <0 Y values
require_once 'phplot.php';
$data = array(array('1960', 100, 70, 60, 54, 16, 2), array('1970', 100, 80, 63, 54, 0, 20), array('1980', 100, 80, 54, 67, 27, 25), array('1990', 100, 95, 69, -54, 28, 10), array('2000', 100, 72, 72, 54, 38, 5));
$plot = new PHPlot(800, 600);
$plot->SetTitle('Area plot with non-decreasing, 0, and <0 Y values');
$plot->SetPlotType('area');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
#$plot->SetYTickIncrement(1);
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->DrawGraph();
Beispiel #12
0
# Load the PHPlot class library:
require_once '../phplot/phplot.php';
# Define the data array: Label, the 3 data sets.
# Year,  Features, Bugs, Happy Users:
include "../conexao.php";
connect();
$sql = "SELECT data,COUNT(data) as total FROM criacao_literaria.historico \r\n\t\twhere acao='login' \r\n\t\tGROUP BY data \r\n\t\tORDER BY data desc\r\n\t\tLIMIT 12;";
$Resultado = mysql_query($sql) or die("Erro: " . mysql_error());
$i = 0;
$data = array();
while ($array_exibir = mysql_fetch_array($Resultado)) {
    $data[] = array($array_exibir['data'], $array_exibir['total']);
    $i++;
}
# Create a PHPlot object which will make an 800x400 pixel image:
$p = new PHPlot(800, 400);
# Use TrueType fonts:
//$p->SetDefaultTTFont('./arial.ttf');
# Set the main plot title:
$p->SetTitle('Histórico 10 dias');
$p->SetPrecisionY(1);
# Select the data array representation and store the data:
$p->SetDataType('text-data');
$p->SetDataValues($data);
# Select the plot type - bar chart:
$p->SetPlotType('lines');
# Define the data range. PHPlot can do this automatically, but not as well.
//$p->SetPlotAreaWorld(0, 0, 9, 400);
# Select an overall image background color and another color under the plot:
//$p->SetBackgroundColor('#ffffcc');
//$p->SetDrawPlotAreaBackground(True);
Beispiel #13
0
# $Id$
# PHPlot test: Legend tests, including SetLegendStyle() - Baseline - 1
# This uses config.php to identify TrueType font locations and names.
require_once 'config.php';
# 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' => 'Legend Test', 'suffix' => ' (baseline)', 'use_ttf' => False, 'textalign' => NULL, 'colorboxalign' => NULL, 'legendfont' => NULL, 'line_spacing' => NULL, 'text' => NULL, 'px' => NULL, 'py' => NULL, 'wx' => NULL, 'wy' => NULL, 'ttfont' => $phplot_test_ttfonts['sans'], 'ttfdir' => $phplot_test_ttfdir, 'ttfsize' => 14, 'cbwa' => NULL), $tp);
require_once 'phplot.php';
$data = array(array('', 0, 0, 0, 0), array('', 1, 1, 2, 3), array('', 2, 2, 4, 6), array('', 3, 3, 6, 9));
if (!isset($tp['text'])) {
    $tp['text'] = array('Plot Line 1', 'Longer label for Plot Line 2', 'line 3');
}
$p = new PHPlot(800, 600);
if ($tp['use_ttf']) {
    $p->SetTTFPath($tp['ttfdir']);
    $p->SetDefaultTTFont($tp['ttfont']);
}
# Set line spacing:
if (isset($tp['line_spacing'])) {
    $p->SetLineSpacing($tp['line_spacing']);
}
$p->SetTitle($tp['title'] . $tp['suffix']);
# Need to set the font for TTF even if legendfont isn't given, to get the size.
if ($tp['use_ttf']) {
    if (isset($tp['legendfont'])) {
        $p->SetFont('legend', $tp['legendfont'], $tp['ttfsize']);
    } else {
        $p->SetFont('legend', $tp['ttfont'], $tp['ttfsize']);
Beispiel #14
0
    $cdt = cos($dtheta);
    $sdt = sin($dtheta);
    $x = $r;
    $y = 0.0;
    for ($grp = 1; $grp <= $tp['ngroups']; $grp++) {
        $row = array("={$grp}=");
        for ($bar = 1; $bar <= $tp['nbars']; $bar++) {
            $row[] = floor($x + 0.5);
            $tx = $x * $cdt - $y * $sdt;
            $y = $x * $sdt + $y * $cdt;
            $x = $tx;
        }
        $data[] = $row;
    }
}
$p = new PHPlot(800, 600);
$p->SetTitle($tp['title'] . $tp['suffix']);
$p->SetDataType('text-data');
$p->SetDataValues($data);
# Options:
#  Note: <=5.0rc3 used x_label font. This was corrected.
if (isset($tp['fontsize'])) {
    $p->SetFont('y_label', $tp['fontsize']);
}
if (isset($tp['shading'])) {
    $p->SetShading($tp['shading']);
}
# Note: This didn't work <= 5.0rc3
if (isset($tp['yprec'])) {
    $p->SetPrecisionY($tp['yprec']);
}
Beispiel #15
0
<?php

//Include the code
include "../phplot.php";
//Define the object and get background image 0cars.jpg
//////NOTE! THIS EXAMPLE WILL ONLY WORK IF YOU HAVE
//////JPEG SUPPORT ENABLED. (Use a different file as a background
//////if you have png or gif enabled.
$graph = new PHPlot(500, 223, "", "0cars.jpg");
//Set some data
$example_data = array(array("55", 5), array("60", 10), array("65", 20), array("70", 30), array("75", 25), array("80", 10));
$graph->SetDataValues($example_data);
//Set up some nice formatting things
$graph->SetTitle("Speed Histogram");
$graph->SetXLabel("Miles per Hour");
$graph->SetYLabel("Percent of Cars");
$graph->SetVertTickIncrement(5);
$graph->SetPlotAreaWorld(0, 0, 6, 35);
//Make the margins nice for the background image
$graph->SetMarginsPixels(80, 35, 35, 70);
//Set up some color and printing options
$graph->background_done = 1;
//The image background we get from 0cars.jpg
$graph->SetDrawPlotAreaBackground(0);
//Plot Area background we get from the image
$graph->SetDataColors(array("white"), array("black"));
//Set Output format
$graph->SetFileFormat("png");
//Draw it
$graph->DrawGraph();
Beispiel #16
0
        return FALSE;
    }
    // Read and check the file header.
    $row = fgetcsv($f);
    if ($row === FALSE || $row[0] != 'Date' || $row[1] != 'Open' || $row[2] != 'High' || $row[3] != 'Low' || $row[4] != 'Close') {
        fwrite(STDERR, "Incorrect header in: {$filename}\n");
        return FALSE;
    }
    // Read the rest of the file and convert.
    while ($d = fgetcsv($f)) {
        $data[] = array('', strtotime($d[0]), $d[1], $d[2], $d[3], $d[4]);
    }
    fclose($f);
    return $data;
}
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->SetTitle("Candlesticks Financial Plot (data-data)\nMSFT Q1 2009");
$plot->SetDataType('data-data');
$plot->SetDataValues(read_prices_data_data(DATAFILE));
$plot->SetPlotType('candlesticks');
$plot->SetDataColors(array('SlateBlue', 'black', 'SlateBlue', 'black'));
$plot->SetXLabelAngle(90);
$plot->SetXLabelType('time', '%Y-%m-%d');
$plot->SetXTickIncrement(7 * 24 * 60 * 60);
// 1 week interval
if (method_exists($plot, 'TuneYAutoRange')) {
    $plot->TuneYAutoRange(0);
}
// Suppress Y zero magnet (PHPlot >= 6.0.0)
Beispiel #17
0
<?php

# $Id$
# Testing phplot - data-data ordering
require_once 'phplot.php';
# 10 lines, one for each shape:
$data = array(array('', 1, 20), array('', 2, 2), array('', 3, 19), array('', 4, 3), array('', 6, 4), array('', 7, 17), array('', 8, 5), array('', 9, 16), array('', 5, 18), array('', 10, 6));
$p = new PHPlot();
$p->SetTitle('Out-of-order data-data points');
$p->SetPlotType('lines');
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetPlotAreaWorld(0, 0, 12, 25);
$p->SetXTickIncrement(1);
$p->SetYTickIncrement(1);
# We don't use the data labels (all set to '') so might as well turn them off:
$p->SetXDataLabelPos('none');
# Draw both grids:
$p->SetDrawXGrid(True);
$p->SetDrawYGrid(True);
# The default
$p->DrawGraph();
Beispiel #18
0
# PHPlot Example - Horizontal Error Plot
require_once 'phplot.php';
# The experimental results as a series of temperature measurements:
$results = array(98, 102, 100, 103, 101, 105, 110, 108, 109);
# The accuracy of our measuring equipment is +/- 5%
$error_factor = 0.05;
# Convert the experimental results to a PHPlot data array for error plots.
function reduce_data($results, $error_factor)
{
    # Use the average of measurements to approximate the error amount:
    $err = $error_factor * array_sum($results) / count($results);
    # Build the 'data-data-yx-error' data array:
    $data = array();
    $i = 1;
    foreach ($results as $value) {
        $data[] = array("Sample {$i}", $i++, $value, $err, $err);
    }
    return $data;
}
$plot = new PHPlot(800, 600);
$plot->SetTitle('Experiment Results');
$plot->SetXTitle('Melting Temperature (degrees C)');
$plot->SetDataValues(reduce_data($results, $error_factor));
$plot->SetDataType('data-data-yx-error');
$plot->SetPlotType('points');
$plot->SetYTickPos('none');
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->SetPlotAreaWorld(80);
$plot->DrawGraph();
Beispiel #19
0
# as date/time labels.
require_once 'phplot.php';
#                   H  M  S   m  d   y
$base_time = mktime(0, 0, 12, 6, 30, 2004);
$interval = 60 * 60;
$data = array();
# This is a quadratic from 0,0 to 50,20 to 100,0:
for ($i = 0; $i <= 100; $i++) {
    if ($i % 24 == 0) {
        $t = $base_time + $i * $interval;
    } else {
        $t = '';
    }
    $data[] = array($t, $i, $i * (0.8 - 0.008 * $i));
}
$p = new PHPlot(800, 600);
$p->SetTitle('Date X labels - 8 hour ticks, 24 hour labels');
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetPlotAreaWorld(0, 0, 100, 20);
$p->SetXLabelType('time');
# For example:
# %Y-%m-%d  2004-12-31
# %b %Y     Dec 2004
# %b %d, %Y Dec 31, 2004
# %d %b     31 Dec
$p->SetXTimeFormat('%m/%d %H:%M');
# Turn off X tick labels, use our data labels only:
$p->SetXTickLabelPos('none');
# But we can use the tick marks themselves if we make them line up right.
$p->SetXTickIncrement(8);
Beispiel #20
0
mt_srand(0);
$data = array();
for ($x = 0; $x < 16; $x++) {
    $row = array('', $x);
    for ($j = 0; $j < 10; $j++) {
        $row[] = mt_rand(0, $x + $j);
    }
    $data[] = $row;
}
# This gets imploded to be the title, after options are added on:
$title = array("Lines plot");
if ($tp['truecolor']) {
    $p = new PHPlot_truecolor(1024, 768);
    $title[] = "Truecolor";
} else {
    $p = new PHPlot(1024, 768);
    $title[] = "Palette Color";
}
$p->SetCallback('draw_setup', 'pre_plot');
$p->SetCallback('draw_all', 'post_plot');
# Reload data colors and apply alpha to all:
if (isset($tp['alpha'])) {
    $p->SetDataColors(NULL, NULL, $tp['alpha']);
    $title[] = "Alpha=" . $tp['alpha'];
}
$p->SetFileFormat($tp['output']);
$title[] = strtoupper($tp['output']) . ' Output';
if ($tp['antialias']) {
    $title[] = "Antialiased";
}
if ($tp['noalphablend']) {
Beispiel #21
0
<?php

require_once 'phplot.php';
$data = array(array('Pos', $_GET['pos']), array('Neg', $_GET['neg']));
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle('Falsos Negativos');
# Make a legend for the 3 data sets plotted:
$plot->SetLegend(array('FP', 'FN'));
# Turn off X tick labels and ticks because they don't apply here:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->DrawGraph();
Beispiel #22
0
# PHPlot / contrib / color_range : Example
# $Id$
# This is a bar chart with a color gradient for the bars in each group.
require_once 'phplot.php';
require_once 'color_range.php';
$bars_per_group = 10;
$x_values = 4;
mt_srand(1);
$data = array();
for ($i = 0; $i < $x_values; $i++) {
    $row = array($i);
    for ($j = 0; $j < $bars_per_group; $j++) {
        $row[] = mt_rand(0, 100);
    }
    $data[] = $row;
}
$p = new PHPlot(800, 600);
$p->SetTitle('Example - Bar Chart with gradient colors');
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotAreaWorld(0, 0, $x_values, 100);
# This isn't necessary, as we do know how many data sets (bars_per_group):
$n_data = count_data_sets($data, 'text-data');
# Make a gradient color map:
$colors = color_range($p->SetRGBColor('SkyBlue'), $p->SetRGBColor('DarkGreen'), $n_data);
$p->SetDataColors($colors);
$p->SetXTickLabelPos('none');
$p->SetXTickPos('none');
$p->SetPlotType('bars');
$p->DrawGraph();
Beispiel #23
0
<?php

# $Id$
# PHPlot Test: bug 2914403 Pie + X/Y titles: Undefined property error
# The bug was that X and Y titles were supposed to be ignored, but if
# set then an undefined property error occurred.
require_once 'phplot.php';
$data = array(array('', 50), array('', 30), array('', 20));
$plot = new PHPlot(800, 600);
$plot->SetTitle('Pie + X/Y Title Bug');
$plot->SetXTitle('Ignored X title');
$plot->SetYTitle('Ignored Y title');
$plot->SetImageBorderType('plain');
$plot->SetDataType('text-data-single');
$plot->SetDataValues($data);
$plot->SetPlotType('pie');
$plot->DrawGraph();
Beispiel #24
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();
<?php 
//Include the code
include_once '../library/phplot/phplot.php';
//Define the object
$data = array(array('Jan', 40, 2, 4), array('Feb', 30, 3, 4), array('Mar', 20, 4, 4), array('Apr', 10, 5, 4), array('May', 3, 6, 4), array('Jun', 7, 7, 4), array('Jul', 10, 8, 4), array('Aug', 15, 9, 4), array('Sep', 20, 5, 4), array('Oct', 18, 4, 4), array('Nov', 16, 7, 4), array('Dec', 14, 3, 30));
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle('Shaded Bar Chart with 3 Data Sets');
# Make a legend for the 3 data sets plotted:
$plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration'));
# Turn off X tick labels and ticks because they don't apply here:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->DrawGraph();
Beispiel #26
0
/**
 * Function to generate random color
 * Taken from http://www.jonasjohn.de/snippets/php/random-color.htm
 * Licensed in Public Domain
 */
function generateRandomColors()
{
    @mt_srand((double) microtime() * 1000000);
    $_c = '';
    while (strlen($_c) < 6) {
        $_c .= sprintf("%02X", mt_rand(0, 255));
    }
    return $_c;
}
// create PHPLot object
$plot = new PHPlot(770, 515);
$plot_data = array();
$data_colors = array();
// default chart
$chart = 'total_title_gmd';
$chart_title = __('Total Titles By Medium/GMD');
if (isset($_GET['chart'])) {
    $chart = trim($_GET['chart']);
}
/**
 * Defines data here
 */
switch ($chart) {
    case 'total_title_colltype':
        $chart_title = __('Total Items By Collection Type');
        $stat_query = $dbs->query('SELECT coll_type_name, COUNT(item_id) AS total_items
<?php

/* $Id: inline_image.php,v 1.2 2004-05-04 15:23:45 alex Exp $ */
if (!isset($_GET['which_title'])) {
    echo <<<EOF
<pre>
           *************************************************
           * This file is meant to be called only from the *
           *                   <a href="test_setup.php">test page</a>                   *
           * It will fail if called by itself.             *
           *************************************************
</pre>
EOF;
    exit;
}
// From PHP 4.?, register_globals is off, take it into account (MBD)
include '../phplot.php';
$graph = new PHPlot();
include './data.php';
$graph->SetTitle("{$_GET['which_title']}");
$graph->SetDataValues($example_data);
$graph->SetIsInline('1');
$graph->SetFileFormat("{$_GET['which_format']}");
$graph->DrawGraph();
  to obtain it through the world-wide-web, please send a note to    
  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();
Beispiel #29
0
$result = mysql_query("SELECT Max(player_money_total_amount) max,min(player_money_total_amount) min FROM meridian103.player_money_total;");
while ($row = mysql_fetch_assoc($result)) {
    $max = $row['max'];
    $min = $row['min'];
}
$min -= 1000000;
mysql_free_result($result);
*/
$result = mysql_query("SELECT player_money_total_amount amount, player_money_total_time time from meridian103.player_money_total where date(player_money_total_time) = date(now()) order by player_money_total_time ASC;");
while ($row = mysql_fetch_assoc($result)) {
    $data[] = array($row['time'], $row['amount']);
}
mysql_free_result($result);
mysql_close($link);
//Define the object
$plot = new PHPlot();
$plot->SetTitle("Server 103 Total Shillings over Time - Period 1 Day");
$plot->SetFontGD('y_label', 5);
$plot->SetFontGD('x_label', 5);
//$plot->SetPlotAreaWorld(NULL,$min,NULL,$max);
$plot->SetXLabelAngle(90);
$plot->SetYDataLabelPos('plotin');
$plot->SetDrawYDataLabelLines('false');
//$plot->SetFontGD('y_title', 5);
//$plot->SetFontGD('x_title', 5);
$plot->SetDataValues($data);
//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
//Draw it
$plot->DrawGraph();
Beispiel #30
-1
<?php

# $Id$
# PHPlot test: Box plot, with image map area outlines shown.
# This produces a plot image with the areas that would be in an image map
# outlined. It does not produce HTML or an image map.
require_once 'phplot.php';
$data = array(array('A', 1, 10, 12, 15, 17, 20), array('B', 2, 5, 10, 16, 20, 24, 2, 3, 4), array('C', 3, 12, 13, 14, 15, 16, 20), array('D', 4, 10, 11, 12, 13, 14), array('E', 5, 12, 12, 15, 18, 20), array('F', 6, 12, 14, 16, 18, 18), array('G', 7, 10, 10, 15, 20, 20));
$data_type = 'data-data';
$plot_type = 'boxes';
$title = "PHPlot Test: {$plot_type} plot with image map areas outlined";
# Callback for 'data_points': Outline the area
function store_map($im, $passthru, $shape, $row, $col, $x1, $y1, $x2, $y2)
{
    static $color = NULL;
    if (!isset($color)) {
        $color = imagecolorallocate($im, 255, 0, 0);
    }
    imagesetthickness($im, 3);
    imagerectangle($im, $x1, $y1, $x2, $y2, $color);
    imagesetthickness($im, 1);
}
$plot = new PHPlot(800, 600);
$plot->SetTitle($title);
$plot->SetImageBorderType('plain');
$plot->SetDataValues($data);
$plot->SetDataType($data_type);
$plot->SetPlotType($plot_type);
$plot->SetPlotAreaWorld(0, 0, 8, 25);
$plot->SetCallback('data_points', 'store_map');
$plot->DrawGraph();