Initial Commit of AgileBill Open Source
104
includes/pear/Image/docs/examples/antialias.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Antialiasing usage
|
||||
*
|
||||
* Other:
|
||||
* Setup canvas, Many plotareas with one legend, Setup fillarray (filling one
|
||||
* plot with different colors depeding on dataset)
|
||||
*
|
||||
* $Id: antialias.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
// include libraries
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
// create a PNG canvas and enable antialiasing (canvas implementation)
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 300, 'antialias' => 'native'));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 8 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
// set the font
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the layout
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Antialiased Sample Chart', 12)),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea1 = Image_Graph::factory('plotarea'),
|
||||
$Plotarea2 = Image_Graph::factory('plotarea')
|
||||
),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
80
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
// add grids
|
||||
$Grid =& $Plotarea1->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid->setLineColor('silver');
|
||||
$Grid =& $Plotarea2->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid->setLineColor('silver');
|
||||
|
||||
// setup legend
|
||||
$Legend->setPlotarea($Plotarea1);
|
||||
$Legend->setPlotarea($Plotarea2);
|
||||
|
||||
// create the dataset
|
||||
$Datasets =
|
||||
array(
|
||||
Image_Graph::factory('random', array(10, 2, 15, true)),
|
||||
Image_Graph::factory('random', array(10, 2, 15, true)),
|
||||
Image_Graph::factory('random', array(10, 2, 15, true))
|
||||
);
|
||||
|
||||
// create the plot as stacked area chart using the datasets
|
||||
$Plot =& $Plotarea1->addNew('Image_Graph_Plot_Area', array($Datasets, 'stacked'));
|
||||
|
||||
// set names for datasets (for legend)
|
||||
$Datasets[0]->setName('Jylland');
|
||||
$Datasets[1]->setName('Fyn');
|
||||
$Datasets[2]->setName('Sj<53>lland');
|
||||
|
||||
// set line color for plot
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// create and populate the fillarray
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
|
||||
// set a fill style
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
// add other plots
|
||||
$Plot =& $Plotarea2->addNew('line', $Datasets[0]);
|
||||
$Plot->setLineColor('blue@0.2');
|
||||
$Plot =& $Plotarea2->addNew('line', $Datasets[1]);
|
||||
$Plot->setLineColor('yellow@0.2');
|
||||
$Plot =& $Plotarea2->addNew('line', $Datasets[2]);
|
||||
$Plot->setLineColor('green@0.2');
|
||||
|
||||
// set color
|
||||
$Plotarea1->setFillColor('silver@0.3');
|
||||
$Plotarea2->setFillColor('silver@0.3');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
|
||||
?>
|
54
includes/pear/Image/docs/examples/axis_direction.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Axis direction
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: axis_direction.php,v 1.1 2005/09/30 18:59:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(10);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// setup the plotarea, legend and their layout
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Changing Axis Direction', 12)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea1 = Image_Graph::factory('plotarea'),
|
||||
$Plotarea2 = Image_Graph::factory('plotarea'),
|
||||
50
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
$Plot1 =& $Plotarea1->addNew('line', array(&$Dataset));
|
||||
$Plot1->setLineColor('red');
|
||||
|
||||
$Plot2 =& $Plotarea2->addNew('line', array(&$Dataset));
|
||||
$Plot2->setLineColor('red');
|
||||
|
||||
$AxisY =& $Plotarea2->getAxis('y');
|
||||
$AxisY->setInverted(true);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
61
includes/pear/Image/docs/examples/canvas.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This is just a basic example with some non-specific geometric shapes and
|
||||
* texts.
|
||||
*
|
||||
* LICENSE: This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version. This library is distributed in the hope that it
|
||||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details. You should have received a copy of
|
||||
* the GNU Lesser General Public License along with this library; if not, write
|
||||
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*
|
||||
* @category Images
|
||||
* @package Image_Canvas
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
||||
* @version CVS: $Id: canvas.php,v 1.1 2005/08/03 21:11:22 nosey Exp $
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
|
||||
*/
|
||||
|
||||
include_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory((isset($_GET['canvas']) ? $_GET['canvas'] : 'png'), array('width' => 400, 'height' => 300));
|
||||
|
||||
$Canvas->setLineColor('black');
|
||||
$Canvas->rectangle(array('x0' => 0, 'y0' => 0, 'x1' => 399, 'y1' => 299));
|
||||
|
||||
$Canvas->setGradientFill(array('direction' => 'horizontal', 'start' => 'red', 'end' => 'blue'));
|
||||
$Canvas->setLineColor('black');
|
||||
$Canvas->ellipse(array('x' => 199, 'y' => 149, 'rx' => 50, 'ry' => 50));
|
||||
|
||||
$Canvas->setFont(array('name' => 'Arial', 'size' => 12));
|
||||
$Canvas->addText(array('x' => 0, 'y' => 0, 'text' => 'Demonstration of what Image_Canvas do!'));
|
||||
|
||||
$Canvas->setFont(array('name' => 'Times New Roman', 'size' => 12));
|
||||
$Canvas->addText(array('x' => 399, 'y' => 20, 'text' => 'This does not demonstrate what is does!', 'alignment' => array('horizontal' => 'right')));
|
||||
|
||||
$Canvas->setFont(array('name' => 'Courier New', 'size' => 7, 'angle' => 270));
|
||||
$Canvas->addText(array('x' => 350, 'y' => 50, 'text' => 'True, but it\'s all independent of the format!', 'alignment' => array('horizontal' => 'right')));
|
||||
|
||||
$Canvas->setFont(array('name' => 'Garamond', 'size' => 10));
|
||||
$Canvas->addText(array('x' => 199, 'y' => 295, 'text' => '[Changing format is done by changing 3 letters in the source]', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
|
||||
|
||||
$Canvas->addVertex(array('x' => 50, 'y' => 200));
|
||||
$Canvas->addVertex(array('x' => 100, 'y' => 200));
|
||||
$Canvas->addVertex(array('x' => 100, 'y' => 250));
|
||||
$Canvas->setFillColor('red@0.2');
|
||||
$Canvas->polygon(array('connect' => true));
|
||||
|
||||
$Canvas->image(array('x' => 398, 'y' => 298, 'filename' => './pear-icon.png', 'alignment' => array('horizontal' => 'right', 'vertical' => 'bottom')));
|
||||
|
||||
$Canvas->show();
|
||||
?>
|
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Explaining category axis ordering
|
||||
*
|
||||
* Other:
|
||||
* None specifc
|
||||
*
|
||||
* $Id: category_axis_explanation.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 500, 'height' => 200, 'antialias' => true));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(9);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Plotarea =& $Graph->addNew('plotarea');
|
||||
|
||||
$Datasets[0] =& Image_Graph::factory('dataset');
|
||||
$Datasets[1] =& Image_Graph::factory('dataset');
|
||||
$Datasets[2] =& Image_Graph::factory('dataset');
|
||||
|
||||
$Datasets[0]->addPoint('this', 1);
|
||||
$Datasets[0]->addPoint('can', 3);
|
||||
$Datasets[0]->addPoint('make', 2);
|
||||
$Datasets[0]->addPoint('correctly', 1);
|
||||
|
||||
$Datasets[1]->addPoint('sentence', 1);
|
||||
$Datasets[1]->addPoint('can', 1);
|
||||
$Datasets[1]->addPoint('sense', 2);
|
||||
$Datasets[1]->addPoint('written', 2);
|
||||
$Datasets[1]->addPoint('correctly', 2);
|
||||
|
||||
$Datasets[2]->addPoint('actually', 3);
|
||||
$Datasets[2]->addPoint('make', 2);
|
||||
$Datasets[2]->addPoint('if', 3);
|
||||
$Datasets[2]->addPoint('written', 1);
|
||||
|
||||
|
||||
// expecting the following X-axis order
|
||||
// 'this sentence can actually make sense if written correctly'
|
||||
// making points be placed in the following order:
|
||||
//
|
||||
// |this|sentence|can|actually|make|sense|if|written|correctly|
|
||||
// 1 |_1__|________|_2_|________|_3__|_____|__|_______|____4____|
|
||||
// 2 |____|___1____|_2_|________|____|__3__|__|___4___|____5____|
|
||||
// 3 |____|________|___|___1____|_2__|_____|3_|___4___|_________|
|
||||
//
|
||||
// if an append-algorithm were to be (wrongly) used it would yield
|
||||
// 'this can make correctly sentence sense written actually if'
|
||||
// making points be placed in the following order:
|
||||
//
|
||||
// |this|can|make|correctly|sentence|sense|written|actually|if|
|
||||
// 1 |_1__|_2_|_3__|____4____|________|_____|_______|________|__|
|
||||
// 2 |____|_2_|____|____5____|___1____|__3__|___4___|________|__|
|
||||
// 3 |____|___|_2__|_________|________|_____|___4___|___1____|3_|
|
||||
|
||||
|
||||
$Plot1 =& $Plotarea->addNew('line', array(&$Datasets[0]));
|
||||
$Plot2 =& $Plotarea->addNew('line', array(&$Datasets[1]));
|
||||
$Plot3 =& $Plotarea->addNew('line', array(&$Datasets[2]));
|
||||
|
||||
$Plot1->setLineColor('red');
|
||||
$Plot2->setLineColor('blue');
|
||||
$Plot3->setLineColor('green');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
51
includes/pear/Image/docs/examples/color_chart.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Not a real usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Color chart of named colors
|
||||
*
|
||||
* Other:
|
||||
* Using canvass "outside" Image_Graph
|
||||
*
|
||||
* $Id: color_chart.php,v 1.2 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
$file = file('./data/colors.txt');
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
require_once 'Image/Graph/Color.php';
|
||||
require_once 'Image/Graph/Constants.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('gd', array('width' => 600, 'height' => 1200));
|
||||
|
||||
$i = 0;
|
||||
$cols = 10;
|
||||
$Width = ($Canvas->getWidth() / $cols);
|
||||
$rows = count($file) / $cols;
|
||||
$rows = floor($rows) + ($rows > floor($rows) ? 1 : 0);
|
||||
$Height = ($Canvas->getHeight() / $rows);
|
||||
while (list($id, $color) = each($file)) {
|
||||
$color = trim($color);
|
||||
$x = ($i % $cols) * $Width + $Width / 2;
|
||||
$y = floor($i / $cols) * $Height;
|
||||
$Canvas->setLineColor('black');
|
||||
$Canvas->setFillColor($color);
|
||||
$Canvas->rectangle($x - $Width / 4, $y, $x + $Width / 4, $y + $Height / 3);
|
||||
$Canvas->write($x, $y + $Height / 3 + 3, $color, IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_TOP);
|
||||
|
||||
$rgbColor = Image_Graph_Color::color2RGB($color);
|
||||
$rgbs = 'RGB: ';
|
||||
unset($rgbColor[3]);
|
||||
while (list($id, $rgb) = each($rgbColor)) {
|
||||
$rgbs .= ($rgb < 0x10 ? '0' : '') . dechex($rgb);
|
||||
}
|
||||
$Canvas->write($x, $y + $Height / 3 + 13, $rgbs, IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_TOP);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$Canvas->done();
|
||||
?>
|
116
includes/pear/Image/docs/examples/customize.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Customizing axis and legends
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: customize.php,v 1.4 2005/09/08 19:02:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(450, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Stacked Bar Chart with defined axis properties', 12)),
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$MarkerX =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', null, IMAGE_GRAPH_AXIS_X);
|
||||
$MarkerX->setFillColor('blue@0.3');
|
||||
$MarkerX->setLineColor('blue@0.3');
|
||||
$MarkerX->setLowerBound(7);
|
||||
$MarkerX->setUpperBound(8);
|
||||
|
||||
$MarkerY =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$MarkerY->setFillColor('green@0.3');
|
||||
$MarkerY->setLineColor('green@0.3');
|
||||
$MarkerY->setLowerBound(5.2);
|
||||
$MarkerY->setUpperBound(9.3);
|
||||
|
||||
$MarkerY =& $Plotarea->addNew('Image_Graph_Axis_Marker_Line', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$MarkerY->setLineColor('red');
|
||||
$MarkerY->setValue(14.4);
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot1 =& $Plotarea->add(
|
||||
Image_Graph::factory('bar',
|
||||
array(
|
||||
$Dataset = array(
|
||||
Image_Graph::factory('random', array(8, 1, 10, false)),
|
||||
Image_Graph::factory('random', array(8, 1, 10, false)),
|
||||
Image_Graph::factory('random', array(8, 1, 10, false))
|
||||
),
|
||||
'stacked'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$Dataset[0]->setName('Dataset one');
|
||||
$Dataset[1]->setName('Numero duo');
|
||||
$Dataset[2]->setName('En-to-tre');
|
||||
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.1', 0);
|
||||
$FillArray->addColor('red@0.1', 1);
|
||||
$FillArray->addColor('yellow@0.1', 2);
|
||||
$Plot1->setFillStyle($FillArray);
|
||||
|
||||
// Show arrow heads on the axis
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
$AxisY->addMark(5);
|
||||
$AxisY->addMark(7);
|
||||
|
||||
$AxisY->setFontSize(7);
|
||||
|
||||
$AxisY->addMark(10.8, 17.5);
|
||||
$AxisY->setFillColor('red@0.7');
|
||||
$AxisY->setLabelInterval(array(1, 5, 9, 12, 13, 14, 19, 21));
|
||||
$AxisY->setTickOptions(-3, 2);
|
||||
$AxisY->setLabelInterval('auto', 2);
|
||||
$AxisY->setTickOptions(-1, 1, 2);
|
||||
|
||||
$AxisY->setLabelOptions(
|
||||
array(
|
||||
'showtext' => true,
|
||||
'font' => array(
|
||||
'size' => 3,
|
||||
'color' => 'red'
|
||||
)
|
||||
), 2
|
||||
);
|
||||
$AxisY->setLabelOption('showoffset', true, 1);
|
||||
|
||||
$AxisX->showArrow();
|
||||
|
||||
$Legend =& $Plotarea->addNew('legend');
|
||||
$Legend->setFillColor('white@0.7');
|
||||
$Legend->setFontSize(8);
|
||||
$Legend->showShadow();
|
||||
|
||||
$Plot1->setLineColor('black@0.1');
|
||||
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
140
includes/pear/Image/docs/examples/data/colors.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
aliceblue
|
||||
antiquewhite
|
||||
aqua
|
||||
aquamarine
|
||||
azure
|
||||
beige
|
||||
bisque
|
||||
black
|
||||
blanchedalmond
|
||||
blue
|
||||
blueviolet
|
||||
brown
|
||||
burlywood
|
||||
cadetblue
|
||||
chartreuse
|
||||
chocolate
|
||||
coral
|
||||
cornflowerblue
|
||||
cornsilk
|
||||
crimson
|
||||
cyan
|
||||
darkblue
|
||||
darkcyan
|
||||
darkgoldenrod
|
||||
darkgray
|
||||
darkgreen
|
||||
darkkhaki
|
||||
darkmagenta
|
||||
darkolivegreen
|
||||
darkorange
|
||||
darkorchid
|
||||
darkred
|
||||
darksalmon
|
||||
darkseagreen
|
||||
darkslateblue
|
||||
darkslategray
|
||||
darkturquoise
|
||||
darkviolet
|
||||
deeppink
|
||||
deepskyblue
|
||||
dimgray
|
||||
dodgerblue
|
||||
firebrick
|
||||
floralwhite
|
||||
forestgreen
|
||||
fuchsia
|
||||
gainsboro
|
||||
ghostwhite
|
||||
gold
|
||||
goldenrod
|
||||
gray
|
||||
green
|
||||
greenyellow
|
||||
honeydew
|
||||
hotpink
|
||||
indianred
|
||||
indigo
|
||||
ivory
|
||||
khaki
|
||||
lavender
|
||||
lavenderblush
|
||||
lawngreen
|
||||
lemonchiffon
|
||||
lightblue
|
||||
lightcoral
|
||||
lightcyan
|
||||
lightgoldenrodyellow
|
||||
lightgreen
|
||||
lightgrey
|
||||
lightpink
|
||||
lightsalmon
|
||||
lightseagreen
|
||||
lightskyblue
|
||||
lightslategray
|
||||
lightsteelblue
|
||||
lightyellow
|
||||
lime
|
||||
limegreen
|
||||
linen
|
||||
magenta
|
||||
maroon
|
||||
mediumaquamarine
|
||||
mediumblue
|
||||
mediumorchid
|
||||
mediumpurple
|
||||
mediumseagreen
|
||||
mediumslateblue
|
||||
mediumspringgreen
|
||||
mediumturquoise
|
||||
mediumvioletred
|
||||
midnightblue
|
||||
mintcream
|
||||
mistyrose
|
||||
moccasin
|
||||
navajowhite
|
||||
navy
|
||||
oldlace
|
||||
olive
|
||||
olivedrab
|
||||
orange
|
||||
orangered
|
||||
orchid
|
||||
palegoldenrod
|
||||
palegreen
|
||||
paleturquoise
|
||||
palevioletred
|
||||
papayawhip
|
||||
peachpuff
|
||||
peru
|
||||
pink
|
||||
plum
|
||||
powderblue
|
||||
purple
|
||||
red
|
||||
rosybrown
|
||||
royalblue
|
||||
saddlebrown
|
||||
salmon
|
||||
sandybrown
|
||||
seagreen
|
||||
seashell
|
||||
sienna
|
||||
silver
|
||||
skyblue
|
||||
slateblue
|
||||
slategray
|
||||
snow
|
||||
springgreen
|
||||
steelblue
|
||||
tan
|
||||
teal
|
||||
thistle
|
||||
tomato
|
||||
turquoise
|
||||
violet
|
||||
wheat
|
||||
white
|
||||
whitesmoke
|
||||
yellow
|
||||
yellowgreen
|
99
includes/pear/Image/docs/examples/datapreprocessor.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Datapreprocessing usage and idea
|
||||
*
|
||||
* Other:
|
||||
* Matrix layout
|
||||
*
|
||||
* $Id: datapreprocessor.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
include('Image/Graph.php');
|
||||
|
||||
function foo($value) {
|
||||
return '-' . chr($value+63) . '-';
|
||||
}
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('Image_Graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('Image_Graph_Title', array('DataPreprocessor Example', 11)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Charts = array('bar', 'line', 'Image_Graph_Plot_Smoothed_Line', 'Image_Graph_Plot_Area');
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Plotarea =& $Matrix->getEntry($i, $j);
|
||||
|
||||
$Chart = $Charts[($i*2+$j)];
|
||||
|
||||
$GridY =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$GridY->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')));
|
||||
|
||||
$Var = "Plot$i$j";
|
||||
$Dataset =& Image_Graph::factory('Image_Graph_Dataset_Random', array(8, 10, 100, $Chart == 'Image_Graph_Plot_Area'));
|
||||
$$Var =& $Plotarea->addNew($Chart, array(&$Dataset));
|
||||
}
|
||||
}
|
||||
$Plotarea =& $Matrix->getEntry(0, 0);
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_RomanNumerals'));
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_NumberText'));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 1);
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setDataPreprocessor(
|
||||
Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
|
||||
array(
|
||||
array(
|
||||
1 => '30 Jul',
|
||||
2 => '31 Jul',
|
||||
3 => '1 Aug',
|
||||
4 => '2 Aug',
|
||||
5 => '3 Aug',
|
||||
6 => '4 Aug',
|
||||
7 => '5 Aug',
|
||||
8 => '6 Aug'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '+ %0.1f%%'));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 0);
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'foo'));
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Currency', 'US$'));
|
||||
|
||||
// just for looks
|
||||
$Plot00->setFillColor('red@0.2');
|
||||
|
||||
$Plot11->setFillColor('blue@0.2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
100
includes/pear/Image/docs/examples/double_category_axis.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* PDF canvas
|
||||
*
|
||||
* Other:
|
||||
* Datapreprocessor, Axis markers
|
||||
*
|
||||
* $Id: double_category_axis.php,v 1.2 2005/10/05 20:51:18 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('ttf_font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Testing Category Axis', 10)),
|
||||
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'Image_Graph_Axis_Category')),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
//$DS =& Image_Graph::factory('dataset');
|
||||
//$DS->addPoint('Apache', 'Open Source');
|
||||
//$DS->addPoint('BSD', 'Open Source');
|
||||
//$DS->addPoint('Linux', 'Open Source');
|
||||
//$DS->addPoint('Microsoft', 'Proprietary');
|
||||
//$DS->addPoint('Micro', 'Proprietary');
|
||||
//$DS->addPoint('Minisoft', 'Proprie');
|
||||
//$DS->addPoint('Millisoft', 'Prop');
|
||||
//
|
||||
//$DS2 =& Image_Graph::factory('dataset');
|
||||
//$DS->addPoint('Apache', 'Open Source');
|
||||
//$DS->addPoint('BSD', 'Open Source');
|
||||
//$DS->addPoint('Linux', 'Open Source');
|
||||
//$DS->addPoint('Microsoft', 'Proprietary');
|
||||
//$DS->addPoint('Micro', 'Proprietary');
|
||||
//$DS->addPoint('Minisoft', 'Proprie');
|
||||
//$DS->addPoint('Miniority', 'Proprias');
|
||||
//
|
||||
//$Plot =& $Plotarea->addNew('scatter', $DS);
|
||||
//$Marker =& Image_Graph::factory('Image_Graph_Marker_Plus');
|
||||
//$Marker->setFillColor('red');
|
||||
//$Marker->setLineColor('black');
|
||||
//$Plot->setMarker($Marker);
|
||||
//
|
||||
//$Plot2 =& $Plotarea->addNew('scatter', $DS2);
|
||||
//$Marker =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||
//$Marker->setFillColor('blue');
|
||||
//$Marker->setLineColor('black');
|
||||
//$Plot2->setMarker($Marker);
|
||||
//
|
||||
//$Graph->done();
|
||||
|
||||
$DS =& Image_Graph::factory('dataset');
|
||||
$DS->addPoint('Germany', 'England');
|
||||
$DS->addPoint('Denmark', 'France');
|
||||
$DS->addPoint('Sweden', 'Denmark');
|
||||
$DS->addPoint('England', 'France');
|
||||
$DS->addPoint('Norway', 'Finland');
|
||||
$DS->addPoint('Denmark', 'Finland');
|
||||
$DS->addPoint('Iceland', 'Germany');
|
||||
$DS->addPoint('Norway', 'France');
|
||||
|
||||
$DS2 =& Image_Graph::factory('dataset');
|
||||
$DS2->addPoint('Sweden', 'France');
|
||||
$DS2->addPoint('Austria', 'Germany');
|
||||
$DS2->addPoint('Norway', 'Holland');
|
||||
$DS2->addPoint('Denmark', 'Germany');
|
||||
$DS2->addPoint('Sweden', 'Holland');
|
||||
$DS2->addPoint('Iceland', 'Denmark');
|
||||
|
||||
$Plot =& $Plotarea->addNew('scatter', $DS);
|
||||
$Marker =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||
$Marker->setFillColor('blue');
|
||||
$Marker->setLineColor('black');
|
||||
$Plot->setMarker($Marker);
|
||||
|
||||
$Plot2 =& $Plotarea->addNew('scatter', $DS2);
|
||||
$Marker2 =& Image_Graph::factory('Image_Graph_Marker_Plus');
|
||||
$Marker2->setFillColor('yellow');
|
||||
$Marker2->setLineColor('black');
|
||||
$Plot2->setMarker($Marker2);
|
||||
|
||||
$Graph->done();
|
||||
?>
|
53
includes/pear/Image/docs/examples/driver_filepdf.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* PDF canvas
|
||||
*
|
||||
* Other:
|
||||
* Datapreprocessor, Axis markers
|
||||
*
|
||||
* $Id: driver_filepdf.php,v 1.1 2005/10/05 20:51:18 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('File_PDF', array('page' => 'A4'));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
// // setup the plotarea, legend and their layout
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Simple Line Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
88
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
// link the legend with the plotares
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create a random dataset for sake of simplicity
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
// create the plot as line chart using the dataset
|
||||
$Plot =& $Plotarea->addNew('line', array(&$Dataset));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('red');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
198
includes/pear/Image/docs/examples/driver_pdf.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* PDF canvas
|
||||
*
|
||||
* Other:
|
||||
* Datapreprocessor, Axis markers
|
||||
*
|
||||
* $Id: driver_pdf.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('pdflib', array('page' => 'A3', 'align' => 'center', 'width' => 600, 'height' => 400));
|
||||
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 15 pixels
|
||||
$Font->setSize(15);
|
||||
// add a title using the created font
|
||||
|
||||
$Dataset_SmoothedLine =& Image_Graph::factory('dataset');
|
||||
$Dataset_SmoothedLine->addPoint('DK', 6);
|
||||
$Dataset_SmoothedLine->addPoint('UK', 8);
|
||||
$Dataset_SmoothedLine->addPoint('PO', 2);
|
||||
$Dataset_SmoothedLine->addPoint('NL', 4);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Layout and Legend Sample', &$Font)),
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::factory('title', array('This is the Y Axis', &$_Image_Graph_verticalFont)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea_BarAndLine = Image_Graph::factory('plotarea'),
|
||||
Image_Graph::factory('title', array('This is the X Axis', &$_Image_Graph_font)),
|
||||
95
|
||||
),
|
||||
5
|
||||
),
|
||||
$Legend_BarAndLine = Image_Graph::factory('legend'),
|
||||
95
|
||||
),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea_SmoothedLine = Image_Graph::factory('plotarea'),
|
||||
$Legend_SmoothedLine = Image_Graph::factory('legend'),
|
||||
80
|
||||
),
|
||||
$Plotarea_Radar = Image_Graph::factory('Image_Graph_Plotarea_Radar')
|
||||
),
|
||||
65
|
||||
),
|
||||
9
|
||||
)
|
||||
);
|
||||
|
||||
$Legend_BarAndLine->setPlotarea($Plotarea_BarAndLine);
|
||||
$Legend_SmoothedLine->setPlotarea($Plotarea_SmoothedLine);
|
||||
|
||||
// create a Y grid
|
||||
$Grid_Radar =& $Plotarea_Radar->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid_Radar->setLineColor('lightgrey');
|
||||
|
||||
// create a Y grid
|
||||
$Grid_BarAndLine =& $Plotarea_BarAndLine->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
// that is light gray in color
|
||||
$Grid_BarAndLine->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')));
|
||||
|
||||
// create a Y grid
|
||||
$Grid_SmoothedLine =& $Plotarea_SmoothedLine->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid_SmoothedLine->setLineColor('lightgrey');
|
||||
|
||||
// create the 1st dataset
|
||||
//$Dataset_SmoothedLine =& new Image_RandomDataset(4, 2, 15, true);
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot_SmoothedLine =& $Plotarea_SmoothedLine->addNew('Image_Graph_Plot_Smoothed_Line', $Dataset_SmoothedLine);
|
||||
$Plot_SmoothedLine->setLineColor('orange');
|
||||
|
||||
// create a 3rd dataset
|
||||
$Dataset_BarChart =& Image_Graph::factory('random', array(8, 10, 120, false));
|
||||
// create the 3rd plot as line chart using the 2nd dataset
|
||||
$Plot_BarChart =& $Plotarea_BarAndLine->addNew('bar', $Dataset_BarChart);
|
||||
// set the fill style of the barchart to the almost transparent BlueAlpha
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot_BarChart->setFillStyle($FillArray);
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'red'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'blue'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'yellow'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'green'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'purple'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'orange'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'black'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'brown'));
|
||||
|
||||
// create the 2nd dataset
|
||||
$Dataset_LineMarker =& Image_Graph::factory('random', array(8, 20, 100, false));
|
||||
// create the 2nd plot as line chart using the 2nd dataset
|
||||
$Plot_LineMarker =& $Plotarea_BarAndLine->addNew('line', $Dataset_LineMarker);
|
||||
|
||||
$Marker =& Image_Graph::factory('Image_Graph_Marker_Array');
|
||||
$CrossMarker =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||
$CircleMarker =& Image_Graph::factory('Image_Graph_Marker_Circle');
|
||||
$Marker->add($CrossMarker);
|
||||
$Marker->add($CircleMarker);
|
||||
$Plot_LineMarker->setMarker($Marker);
|
||||
// Create a red line
|
||||
$CrossMarker->setLineColor('red');
|
||||
// Create a blue line
|
||||
$CircleMarker->setLineColor('blue');
|
||||
|
||||
// Show arrow heads on the axis
|
||||
$AxisX =& $Plotarea_BarAndLine->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisY =& $Plotarea_BarAndLine->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisX->showArrow();
|
||||
$AxisY->showArrow();
|
||||
|
||||
// create an data label array for formatting label data based on an array
|
||||
$ArrayData =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
|
||||
array(
|
||||
array(
|
||||
1=>'A Point',
|
||||
2=>'Another',
|
||||
6=>'Yet another'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// use the data label array on the X axis
|
||||
$AxisX->setDataPreprocessor($ArrayData);
|
||||
$AxisFontX =& $Graph->addNew('Image_Graph_Font_Vertical');
|
||||
$AxisX->setFont($AxisFontX);
|
||||
|
||||
$Legend_BarAndLine->setFillColor('white');
|
||||
$Legend_SmoothedLine->setFillColor('white');
|
||||
|
||||
$Font2 =& $Graph->addNew('font', 'Verdana');
|
||||
$Font2->setSize(8);
|
||||
$Legend_BarAndLine->setFont($Font2);
|
||||
$Legend_SmoothedLine->setFont($Font2);
|
||||
|
||||
$Plot_SmoothedLine->setTitle('Oil');
|
||||
$Plot_LineMarker->setTitle('Data Set 1');
|
||||
$Plot_BarChart->setTitle('Data Set 2');
|
||||
|
||||
// create the dataset
|
||||
$Dataset_Radar1 =& Image_Graph::factory('random', array(8, 1, 5));
|
||||
$Dataset_Radar2 =& Image_Graph::factory('random', array(8, 1, 5));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot_Radar1 =& $Plotarea_Radar->addNew('Image_Graph_Plot_Radar', $Dataset_Radar1);
|
||||
$Plot_Radar2 =& $Plotarea_Radar->addNew('Image_Graph_Plot_Radar', $Dataset_Radar2);
|
||||
|
||||
//$Dataset_Radar1->setMaximumY(7);
|
||||
|
||||
$DataPreprocessor =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
|
||||
array(
|
||||
array(
|
||||
'Irrelevance',
|
||||
'Partly',
|
||||
'Regular',
|
||||
'Relevance',
|
||||
'Something',
|
||||
'Everything',
|
||||
'Nothing',
|
||||
'Irregular'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$AxisX =& $Plotarea_Radar->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setDataPreprocessor($DataPreprocessor);
|
||||
|
||||
$AverageMarker =& Image_Graph::factory('Image_Graph_Marker_Average');
|
||||
$Plot_SmoothedLine->setMarker($AverageMarker);
|
||||
$AverageMarker->setLineColor('purple');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot_Radar1->setFillColor('yellow@0.2');
|
||||
$Plot_Radar2->setFillColor('green@0.2');
|
||||
// output the Graph
|
||||
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
72
includes/pear/Image/docs/examples/driver_png_svg.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate switching between canvass
|
||||
*
|
||||
* Other:
|
||||
* PNG and SVG canvas usage
|
||||
*
|
||||
* $Id: driver_png_svg.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
// create a new GD canvas
|
||||
$Canvas =& Image_Canvas::factory('gd',
|
||||
array(
|
||||
'filename' => './images/modify.jpg',
|
||||
'left' => 400,
|
||||
'top' => 100,
|
||||
'width' => 500,
|
||||
'height' => 500,
|
||||
'transparent' => true
|
||||
)
|
||||
);
|
||||
|
||||
// create the graph using the GD canvas
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
// create a simple graph
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
$Plot =& $Plotarea->addNew('area', $Dataset);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
$Graph->addNew('title', array('Simple Area Chart Sample', 12));
|
||||
|
||||
// output the graph using the GD canvas
|
||||
$Graph->done(array('filename' => './canvassample.png'));
|
||||
|
||||
// create a new SVG canvas
|
||||
$Canvas =& Image_Canvas::factory('svg',
|
||||
array(
|
||||
'width' => 600,
|
||||
'height' => 400
|
||||
)
|
||||
);
|
||||
// make the graph use this now instead
|
||||
$Graph->setCanvas($Canvas);
|
||||
|
||||
// 're'-output the graph, but not using the SVG canvas
|
||||
$Graph->done(array('filename' => './canvassample.svg'));
|
||||
?>
|
57
includes/pear/Image/docs/examples/driver_swf01.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate SWF canvas
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: driver_swf01.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('swf', array('width' => 600, 'height' => 400));
|
||||
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(11);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Simple Area Chart Sample', &$Font)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
|
||||
$Plot =& $Plotarea->addNew('area', $Dataset);
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
197
includes/pear/Image/docs/examples/driver_swf02.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate SWF canvas
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: driver_swf02.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('swf', array('width' => 600, 'height' => 400));
|
||||
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 15 pixels
|
||||
$Font->setSize(15);
|
||||
// add a title using the created font
|
||||
|
||||
$Dataset_SmoothedLine =& Image_Graph::factory('dataset');
|
||||
$Dataset_SmoothedLine->addPoint('DK', 6);
|
||||
$Dataset_SmoothedLine->addPoint('UK', 8);
|
||||
$Dataset_SmoothedLine->addPoint('PO', 2);
|
||||
$Dataset_SmoothedLine->addPoint('NL', 4);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Layout and Legend Sample', &$Font)),
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::factory('title', array('This is the Y Axis', &$_Image_Graph_verticalFont)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea_BarAndLine = Image_Graph::factory('plotarea'),
|
||||
Image_Graph::factory('title', array('This is the X Axis', &$_Image_Graph_font)),
|
||||
95
|
||||
),
|
||||
5
|
||||
),
|
||||
$Legend_BarAndLine = Image_Graph::factory('legend'),
|
||||
95
|
||||
),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea_SmoothedLine = Image_Graph::factory('plotarea'),
|
||||
$Legend_SmoothedLine = Image_Graph::factory('legend'),
|
||||
80
|
||||
),
|
||||
$Plotarea_Radar = Image_Graph::factory('Image_Graph_Plotarea_Radar')
|
||||
),
|
||||
65
|
||||
),
|
||||
9
|
||||
)
|
||||
);
|
||||
|
||||
$Legend_BarAndLine->setPlotarea($Plotarea_BarAndLine);
|
||||
$Legend_SmoothedLine->setPlotarea($Plotarea_SmoothedLine);
|
||||
|
||||
// create a Y grid
|
||||
$Grid_Radar =& $Plotarea_Radar->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid_Radar->setLineColor('lightgrey');
|
||||
|
||||
// create a Y grid
|
||||
$Grid_BarAndLine =& $Plotarea_BarAndLine->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
// that is light gray in color
|
||||
$Grid_BarAndLine->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')));
|
||||
|
||||
// create a Y grid
|
||||
$Grid_SmoothedLine =& $Plotarea_SmoothedLine->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid_SmoothedLine->setLineColor('lightgrey');
|
||||
|
||||
// create the 1st dataset
|
||||
//$Dataset_SmoothedLine =& new Image_RandomDataset(4, 2, 15, true);
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot_SmoothedLine =& $Plotarea_SmoothedLine->addNew('Image_Graph_Plot_Smoothed_Line', $Dataset_SmoothedLine);
|
||||
$Plot_SmoothedLine->setLineColor('orange');
|
||||
|
||||
// create a 3rd dataset
|
||||
$Dataset_BarChart =& Image_Graph::factory('random', array(8, 10, 120, false));
|
||||
// create the 3rd plot as line chart using the 2nd dataset
|
||||
$Plot_BarChart =& $Plotarea_BarAndLine->addNew('bar', $Dataset_BarChart);
|
||||
// set the fill style of the barchart to the almost transparent BlueAlpha
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot_BarChart->setFillStyle($FillArray);
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', 'red'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'blue'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'yellow'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', 'green'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'purple'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'orange'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'black'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'brown'));
|
||||
|
||||
// create the 2nd dataset
|
||||
$Dataset_LineMarker =& Image_Graph::factory('random', array(8, 20, 100, false));
|
||||
// create the 2nd plot as line chart using the 2nd dataset
|
||||
$Plot_LineMarker =& $Plotarea_BarAndLine->addNew('line', $Dataset_LineMarker);
|
||||
|
||||
$Marker =& Image_Graph::factory('Image_Graph_Marker_Array');
|
||||
$CrossMarker =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||
$CircleMarker =& Image_Graph::factory('Image_Graph_Marker_Circle');
|
||||
$Marker->add($CrossMarker);
|
||||
$Marker->add($CircleMarker);
|
||||
$Plot_LineMarker->setMarker($Marker);
|
||||
// Create a red line
|
||||
$CrossMarker->setLineColor('red');
|
||||
// Create a blue line
|
||||
$CircleMarker->setLineColor('blue');
|
||||
|
||||
// Show arrow heads on the axis
|
||||
$AxisX =& $Plotarea_BarAndLine->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisY =& $Plotarea_BarAndLine->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisX->showArrow();
|
||||
$AxisY->showArrow();
|
||||
|
||||
// create an data label array for formatting label data based on an array
|
||||
$ArrayData =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
|
||||
array(
|
||||
array(
|
||||
1=>'A Point',
|
||||
2=>'Another',
|
||||
6=>'Yet another'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// use the data label array on the X axis
|
||||
$AxisX->setDataPreprocessor($ArrayData);
|
||||
$AxisFontX =& $Graph->addNew('Image_Graph_Font_Vertical');
|
||||
$AxisX->setFont($AxisFontX);
|
||||
|
||||
$Legend_BarAndLine->setFillColor('white');
|
||||
$Legend_SmoothedLine->setFillColor('white');
|
||||
|
||||
$Font2 =& $Graph->addNew('font', 'Verdana');
|
||||
$Font2->setSize(8);
|
||||
$Legend_BarAndLine->setFont($Font2);
|
||||
$Legend_SmoothedLine->setFont($Font2);
|
||||
|
||||
$Plot_SmoothedLine->setTitle('Oil');
|
||||
$Plot_LineMarker->setTitle('Data Set 1');
|
||||
$Plot_BarChart->setTitle('Data Set 2');
|
||||
|
||||
// create the dataset
|
||||
$Dataset_Radar1 =& Image_Graph::factory('random', array(8, 1, 5));
|
||||
$Dataset_Radar2 =& Image_Graph::factory('random', array(8, 1, 5));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot_Radar1 =& $Plotarea_Radar->addNew('Image_Graph_Plot_Radar', $Dataset_Radar1);
|
||||
$Plot_Radar2 =& $Plotarea_Radar->addNew('Image_Graph_Plot_Radar', $Dataset_Radar2);
|
||||
|
||||
//$Dataset_Radar1->setMaximumY(7);
|
||||
|
||||
$DataPreprocessor =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
|
||||
array(
|
||||
array(
|
||||
'Irrelevance',
|
||||
'Partly',
|
||||
'Regular',
|
||||
'Relevance',
|
||||
'Something',
|
||||
'Everything',
|
||||
'Nothing',
|
||||
'Irregular'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$AxisX =& $Plotarea_Radar->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setDataPreprocessor($DataPreprocessor);
|
||||
|
||||
//$Plot_Radar1->setMarker(new Image_CrossMarker(), 'Marker');
|
||||
//$Plot_Radar1->setLineStyle($YELLOW);
|
||||
|
||||
$AverageMarker =& Image_Graph::factory('Image_Graph_Marker_Average');
|
||||
$Plot_SmoothedLine->setMarker($AverageMarker);
|
||||
$AverageMarker->setLineColor('purple');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot_Radar1->setFillColor('yellow@0.2');
|
||||
$Plot_Radar2->setFillColor('green@0.2');
|
||||
// output the Graph
|
||||
|
||||
$Graph->done();
|
||||
?>
|
53
includes/pear/Image/docs/examples/driver_swf03.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate SWF canvas
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: driver_swf03.php,v 1.3 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('swf', array('width' => 600, 'height' => 400));
|
||||
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(11);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Simple Line Chart Sample', &$Font)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('line', $Dataset);
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('red');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
313
includes/pear/Image/docs/examples/frontpage_sample.php
Normal file
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Drivers usage
|
||||
*
|
||||
* Other:
|
||||
* Grids, Axis markers, Secondary Y-axis, Datapreprocessor, Multiple plotareas,
|
||||
* Axis titles
|
||||
*
|
||||
* $Id: frontpage_sample.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
// create a new GD canvas
|
||||
$Canvas =& Image_Canvas::factory('gd',
|
||||
array(
|
||||
'width' => 600,
|
||||
'height' => 400
|
||||
)
|
||||
);
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Image_Graph Demonstration', 12)),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::vertical(
|
||||
$Plotarea_Weather = Image_Graph::factory('plotarea'),
|
||||
$Legend_Weather = Image_Graph::factory('legend'),
|
||||
85
|
||||
),
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory(
|
||||
'title',
|
||||
array('Demonstration of Mathematical Functions', 10)
|
||||
),
|
||||
$Plotarea_SinCos = Image_Graph::factory('plotarea', 'axis'),
|
||||
5
|
||||
),
|
||||
$Legend_SinCos = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
$Plotarea_Car = Image_Graph::factory('plotarea'),
|
||||
50
|
||||
),
|
||||
60
|
||||
),
|
||||
5)
|
||||
);
|
||||
$Legend_Weather->setPlotarea($Plotarea_Weather);
|
||||
$Legend_Weather->setFontSize(7);
|
||||
|
||||
$Legend_SinCos->setPlotarea($Plotarea_SinCos);
|
||||
$Legend_SinCos->setFontSize(8);
|
||||
|
||||
$GridY_Weather =& $Plotarea_Weather->addNew(
|
||||
'line_grid',
|
||||
null,
|
||||
IMAGE_GRAPH_AXIS_Y
|
||||
);
|
||||
$GridY_Weather->setLineColor('gray@0.1');
|
||||
|
||||
$Marker_AverageSpan =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Axis_Marker_Area',
|
||||
IMAGE_GRAPH_AXIS_Y
|
||||
);
|
||||
$Marker_AverageSpan->setFillColor('green@0.2');
|
||||
$Marker_AverageSpan->setLowerBound(3.8);
|
||||
$Marker_AverageSpan->setUpperBound(11.4);
|
||||
|
||||
$Marker_Average =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Axis_Marker_Line',
|
||||
IMAGE_GRAPH_AXIS_Y
|
||||
);
|
||||
$Marker_Average->setLineColor('blue@0.4');
|
||||
$Marker_Average->setValue(7.7);
|
||||
|
||||
$Dataset_Rainfall =& Image_Graph::factory('dataset');
|
||||
$Dataset_Rainfall->addPoint('Jan', 60);
|
||||
$Dataset_Rainfall->addPoint('Feb', 41);
|
||||
$Dataset_Rainfall->addPoint('Mar', 48);
|
||||
$Dataset_Rainfall->addPoint('Apr', 42);
|
||||
$Dataset_Rainfall->addPoint('May', 50);
|
||||
$Dataset_Rainfall->addPoint('Jun', 55);
|
||||
$Dataset_Rainfall->addPoint('Jul', 67);
|
||||
$Dataset_Rainfall->addPoint('Aug', 65);
|
||||
$Dataset_Rainfall->addPoint('Sep', 72);
|
||||
$Dataset_Rainfall->addPoint('Oct', 77);
|
||||
$Dataset_Rainfall->addPoint('Nov', 80);
|
||||
$Dataset_Rainfall->addPoint('Dec', 68);
|
||||
$Plot_Rainfall =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'bar',
|
||||
array(&$Dataset_Rainfall),
|
||||
IMAGE_GRAPH_AXIS_Y_SECONDARY
|
||||
);
|
||||
$Plot_Rainfall->setLineColor('gray');
|
||||
$Plot_Rainfall->setFillColor('yellow@0.1');
|
||||
$Plot_Rainfall->setTitle('Average rainfall');
|
||||
|
||||
$Dataset_TempAvg =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempAvg->addPoint('Jan', 0.2);
|
||||
$Dataset_TempAvg->addPoint('Feb', 0.1);
|
||||
$Dataset_TempAvg->addPoint('Mar', 2.3);
|
||||
$Dataset_TempAvg->addPoint('Apr', 5.8);
|
||||
$Dataset_TempAvg->addPoint('May', 10.8);
|
||||
$Dataset_TempAvg->addPoint('Jun', 14.1);
|
||||
$Dataset_TempAvg->addPoint('Jul', 16.2);
|
||||
$Dataset_TempAvg->addPoint('Aug', 15.9);
|
||||
$Dataset_TempAvg->addPoint('Sep', 12.1);
|
||||
$Dataset_TempAvg->addPoint('Oct', 8.7);
|
||||
$Dataset_TempAvg->addPoint('Nov', 4.4);
|
||||
$Dataset_TempAvg->addPoint('Dec', 1.8);
|
||||
$Plot_TempAvg =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Plot_Smoothed_Line',
|
||||
array(&$Dataset_TempAvg)
|
||||
);
|
||||
$Plot_TempAvg->setLineColor('blue');
|
||||
$Plot_TempAvg->setTitle('Average temperature');
|
||||
|
||||
$Dataset_TempMin =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempMin->addPoint('Jan', -2.7);
|
||||
$Dataset_TempMin->addPoint('Feb', -2.8);
|
||||
$Dataset_TempMin->addPoint('Mar', -0.9);
|
||||
$Dataset_TempMin->addPoint('Apr', 1.2);
|
||||
$Dataset_TempMin->addPoint('May', 5.5);
|
||||
$Dataset_TempMin->addPoint('Jun', 9.2);
|
||||
$Dataset_TempMin->addPoint('Jul', 11.3);
|
||||
$Dataset_TempMin->addPoint('Aug', 11.1);
|
||||
$Dataset_TempMin->addPoint('Sep', 7.8);
|
||||
$Dataset_TempMin->addPoint('Oct', 5.0);
|
||||
$Dataset_TempMin->addPoint('Nov', 1.5);
|
||||
$Dataset_TempMin->addPoint('Dec', -0.9);
|
||||
$Plot_TempMin =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Plot_Smoothed_Line',
|
||||
array(&$Dataset_TempMin)
|
||||
);
|
||||
$Plot_TempMin->setLineColor('teal');
|
||||
$Plot_TempMin->setTitle('Minimum temperature');
|
||||
|
||||
$Dataset_TempMax =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempMax->addPoint('Jan', 2.4);
|
||||
$Dataset_TempMax->addPoint('Feb', 2.5);
|
||||
$Dataset_TempMax->addPoint('Mar', 5.4);
|
||||
$Dataset_TempMax->addPoint('Apr', 10.5);
|
||||
$Dataset_TempMax->addPoint('May', 15.8);
|
||||
$Dataset_TempMax->addPoint('Jun', 18.9);
|
||||
$Dataset_TempMax->addPoint('Jul', 21.2);
|
||||
$Dataset_TempMax->addPoint('Aug', 20.8);
|
||||
$Dataset_TempMax->addPoint('Sep', 16.3);
|
||||
$Dataset_TempMax->addPoint('Oct', 11.8);
|
||||
$Dataset_TempMax->addPoint('Nov', 6.9);
|
||||
$Dataset_TempMax->addPoint('Dec', 4.1);
|
||||
$Plot_TempMax =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Plot_Smoothed_Line',
|
||||
array(&$Dataset_TempMax)
|
||||
);
|
||||
$Plot_TempMax->setLineColor('red');
|
||||
$Plot_TempMax->setTitle('Maximum temperature');
|
||||
|
||||
$DataPreprocessor_MM =&
|
||||
Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d mm');
|
||||
$DataPreprocessor_DegC =&
|
||||
Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d C');
|
||||
|
||||
$Marker_Rainfall =&
|
||||
$Plot_Rainfall->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
$Marker_Rainfall->setDataPreprocessor($DataPreprocessor_MM);
|
||||
$Marker_Rainfall->setFontSize(7);
|
||||
$PointingMarker_Rainfall =&
|
||||
$Plot_Rainfall->addNew(
|
||||
'Image_Graph_Marker_Pointing_Angular',
|
||||
array(20, &$Marker_Rainfall)
|
||||
);
|
||||
$Plot_Rainfall->setMarker($PointingMarker_Rainfall);
|
||||
|
||||
$AxisY_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY_Weather->showLabel(IMAGE_GRAPH_LABEL_ZERO);
|
||||
$AxisY_Weather->setDataPreprocessor($DataPreprocessor_DegC);
|
||||
$AxisY_Weather->setTitle(
|
||||
'Temperature',
|
||||
array('vertical' => true, 'angle' => 90)
|
||||
);
|
||||
|
||||
$AxisYsecondary_Weather =&
|
||||
$Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$AxisYsecondary_Weather->setDataPreprocessor($DataPreprocessor_MM);
|
||||
$AxisYsecondary_Weather->setTitle(
|
||||
'Rainfall',
|
||||
array('vertical' => true, 'angle' => 270)
|
||||
);
|
||||
|
||||
$GridX_SinCos =&
|
||||
$Plotarea_SinCos->addNew('line_grid', null, IMAGE_GRAPH_AXIS_X);
|
||||
$GridY_SinCos =&
|
||||
$Plotarea_SinCos->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$Dataset_Sin =&
|
||||
Image_Graph::factory(
|
||||
'Image_Graph_Dataset_Function',
|
||||
array(-2*pi(), 2*pi(), 'sin', 50)
|
||||
);
|
||||
$Dataset_Cos =&
|
||||
Image_Graph::factory(
|
||||
'Image_Graph_Dataset_Function',
|
||||
array(-2*pi(), 2*pi(), 'cos', 50)
|
||||
);
|
||||
$Plot_Sin =& $Plotarea_SinCos->addNew('line', $Dataset_Sin);
|
||||
$Plot_Cos =& $Plotarea_SinCos->addNew('line', $Dataset_Cos);
|
||||
$Plot_Sin->setLineColor('red');
|
||||
$Plot_Cos->setLineColor('blue');
|
||||
$Plot_Sin->setTitle('sin(x)');
|
||||
$Plot_Cos->setTitle('cos(x)');
|
||||
$AxisX_SinCos =& $Plotarea_SinCos->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX_SinCos->setLabelInterval(array(-6, -4, -2, 2, 4, 6));
|
||||
$AxisY_SinCos =& $Plotarea_SinCos->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY_SinCos->forceMinimum(-1.1);
|
||||
$AxisY_SinCos->forceMaximum(1.1);
|
||||
$AxisY_SinCos->setLabelInterval(array(-1, -0.5, 0.5, 1));
|
||||
|
||||
function carLabel($value) {
|
||||
return 2000+$value;
|
||||
}
|
||||
|
||||
$DataPreprocessor_Car =&
|
||||
Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'carLabel');
|
||||
|
||||
$GridX_Car =& $Plotarea_Car->addNew('line_grid', null, IMAGE_GRAPH_AXIS_X);
|
||||
$GridY_Car =& $Plotarea_Car->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$GridX_Car->setLineColor('gray@0.2');
|
||||
$GridY_Car->setLineColor('gray@0.2');
|
||||
$Dataset_Car =& Image_Graph::factory('random', array(10, 10, 100, true));
|
||||
$Fill_Car =&
|
||||
Image_Graph::factory('Image_Graph_Fill_Image', './images/audi-tt-coupe.jpg');
|
||||
$Plotarea_Car->setFillStyle($Fill_Car);
|
||||
$Plot_Car =&
|
||||
$Plotarea_Car->addNew('Image_Graph_Plot_Smoothed_Area', $Dataset_Car);
|
||||
$Plot_Car->setLineColor('gray');
|
||||
$Plot_Car->setFillColor('white@0.7');
|
||||
|
||||
$AxisX_Car =& $Plotarea_Car->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX_Car->setDataPreprocessor($DataPreprocessor_Car);
|
||||
$AxisX_Car->setFontSize(6);
|
||||
$AxisY_Car =& $Plotarea_Car->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY_Car->forceMaximum(100);
|
||||
|
||||
// output the graph using the GD canvas
|
||||
$Graph->done(array('filename' => './output/frontpage_sample.png'));
|
||||
|
||||
// create a new SVG canvas
|
||||
$Canvas =& Image_Canvas::factory('svg',
|
||||
array(
|
||||
'width' => 600,
|
||||
'height' => 400
|
||||
)
|
||||
);
|
||||
// make the graph use this now instead
|
||||
$Graph->setCanvas($Canvas);
|
||||
|
||||
// 're'-output the graph, but not using the SVG canvas
|
||||
$Graph->done(array('filename' => './output/frontpage_sample.svg'));
|
||||
|
||||
/*
|
||||
// create a new PDF canvas
|
||||
$Canvas =& Image_Canvas::factory('pdflib',
|
||||
array(
|
||||
'page' => 'A4',
|
||||
'align' => 'center',
|
||||
'orientation' => 'landscape',
|
||||
'width' => 600,
|
||||
'height' => 400
|
||||
)
|
||||
);
|
||||
// make the graph use this now instead
|
||||
$Graph->setCanvas($Canvas);
|
||||
|
||||
// 're'-output the graph, but not using the PDF canvas
|
||||
$Graph->done(array('filename' => './output/frontpage_sample.pdf'));
|
||||
|
||||
// create a new SWF canvas
|
||||
$Canvas =& Image_Canvas::factory('swf',
|
||||
array(
|
||||
'width' => 600,
|
||||
'height' => 400
|
||||
)
|
||||
);
|
||||
// make the graph use this now instead
|
||||
$Graph->setCanvas($Canvas);
|
||||
|
||||
// 're'-output the graph, but not using the SWF canvas
|
||||
$Graph->done(array('filename' => './output/frontpage_sample.swf'));
|
||||
*/
|
||||
?>
|
80
includes/pear/Image/docs/examples/gradient_fill_area.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate gradient fillings
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: gradient_fill_area.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Gradient filled smoothed area chart', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
85
|
||||
),
|
||||
8
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the 1st dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 40, 100, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('smooth_area', array(&$Dataset));
|
||||
// create a vertical gradient fill using red and yellow, ie bottom of graph
|
||||
// will be yellow and the 'higher' the value the more red it will be, ie a 'fire' effect
|
||||
$Plot->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'green', 'lightyellow')));
|
||||
$Plot->setTitle('Inside scope');
|
||||
|
||||
// create the 2nd dataset
|
||||
$Dataset2 =& Image_Graph::factory('random', array(10, 50, 70, true));
|
||||
// create the 2nd plot as smoothed area chart using the 2nd dataset
|
||||
$Plot2 =& $Plotarea->addNew('smooth_area', array(&$Dataset2));
|
||||
// create a vertical gradient fill using red and yellow, ie bottom of graph
|
||||
// will be yellow and the 'higher' the value the more red it will be, ie a 'fire' effect
|
||||
$Plot2->setFillColor('white@0.4');
|
||||
$Plot2->setTitle('Outside scope');
|
||||
|
||||
$Graph->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'steelblue', 'lightcyan')));
|
||||
$Graph->setBorderColor('black');
|
||||
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_MAX);
|
||||
// create a pin-point marker type
|
||||
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
|
||||
// and use the marker on the 1st plot
|
||||
$Plot->setMarker($PointingMarker);
|
||||
// format value marker labels as percentage values
|
||||
$Marker->setDataPreProcessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
|
||||
$Marker->setFontSize(7);
|
||||
|
||||
$AxisY =& $Plotarea->getAxis('y');
|
||||
$AxisY->forceMinimum(30);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
106
includes/pear/Image/docs/examples/gradient_pie.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate pie & donut plots
|
||||
*
|
||||
* Other:
|
||||
* Radial gradient fillings
|
||||
*
|
||||
* $Id: gradient_pie.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph = & Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Gradient Filled Donut/Pie Chart', 12)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
60
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
$Legend->setAlignment(IMAGE_GRAPH_ALIGN_VERTICAL);
|
||||
|
||||
// create the dataset
|
||||
$Dataset = & Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint('Beef', rand(1, 10), 'beef');
|
||||
$Dataset->addPoint('Pork', rand(1, 10), 'pork');
|
||||
$Dataset->addPoint('Poultry', rand(1, 10), 'poultry');
|
||||
$Dataset->addPoint('Camels', rand(1, 10), 'camels');
|
||||
$Dataset->addPoint('Other', rand(1, 10), 'other');
|
||||
|
||||
// create the dataset
|
||||
$Dataset2 = & Image_Graph::factory('dataset');
|
||||
$Dataset2->addPoint('Beer', rand(1, 10), 'beer');
|
||||
$Dataset2->addPoint('Wine', rand(1, 10), 'wine');
|
||||
$Dataset2->addPoint('Alcohol', rand(1, 10), 'alcohol');
|
||||
$Dataset2->addPoint('Coffee', rand(1, 10), 'coffee');
|
||||
$Dataset2->addPoint('Milk', rand(1, 10), 'milk');
|
||||
$Dataset2->addPoint('Water', rand(1, 10), 'water');
|
||||
|
||||
// create the plot as pie chart using the dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Pie', array(array(&$Dataset, &$Dataset2)));
|
||||
$Plotarea->hideAxis();
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL);
|
||||
// fill it with white
|
||||
$Marker->setFillColor('white');
|
||||
// and use black border
|
||||
$Marker->setBorderColor('black');
|
||||
// and format it using a data preprocessor
|
||||
$Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
|
||||
$Marker->setFontSize(7);
|
||||
|
||||
// create a pin-point marker type
|
||||
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
|
||||
// and use the marker on the plot
|
||||
$Plot->setMarker($PointingMarker);
|
||||
// format value marker labels as percentage values
|
||||
$Plot->Radius = 2;
|
||||
|
||||
// create a fillstyle for the plot
|
||||
$FillArray = & Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot->setFillStyle($FillArray);
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'), 'beef');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'blue'), 'pork');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'yellow'), 'poultry');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red'), 'camels');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'), 'other');
|
||||
|
||||
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'dimgray', 'white'), 'beer');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'sandybrown', 'white'), 'wine');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'sienna', 'white'), 'alcohol');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'powderblue', 'white'), 'coffee');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'purple', 'white'), 'milk');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'thistle', 'white'), 'water');
|
||||
|
||||
$Plot->explode(20, 'Beer');
|
||||
|
||||
$Plot->setLineColor('lightgrey');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
77
includes/pear/Image/docs/examples/gradient_step.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate gradient fillings
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: gradient_step.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png',
|
||||
array(
|
||||
'width' => 400,
|
||||
'height' => 200
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Gradient Filled Step Chart', 11)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
Image_Graph::factory('title', array('Anybody recognize?', array('size' => 7, 'color' => 'gray@0.6', 'angle' => 270))),
|
||||
98
|
||||
),
|
||||
5)
|
||||
);
|
||||
|
||||
$Grid =& $Plotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid->setLineColor('white@0.4');
|
||||
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint(1, 20);
|
||||
$Dataset->addPoint(2, 10);
|
||||
$Dataset->addPoint(3, 35);
|
||||
$Dataset->addPoint(4, 5);
|
||||
$Dataset->addPoint(5, 18);
|
||||
$Dataset->addPoint(6, 33);
|
||||
$Plot =& $Plotarea->addNew('step', array(&$Dataset));
|
||||
|
||||
$Fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'darkgreen', 'white'));
|
||||
$Plot->setFillStyle($Fill);
|
||||
|
||||
$Fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'yellow', 'darkred'));
|
||||
$Plotarea->setFillStyle($Fill);
|
||||
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->forceMaximum(40);
|
||||
$AxisY->setLabelInterval(10);
|
||||
|
||||
$Graph->setBackgroundColor('green@0.2');
|
||||
$Graph->setBorderColor('black');
|
||||
$Graph->setPadding(10);
|
||||
|
||||
$Plot->setBorderColor('black');
|
||||
|
||||
// output the graph
|
||||
$Graph->done();
|
||||
?>
|
127
includes/pear/Image/docs/examples/horizontal.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Displaying labels and titles on horizontal and vertical plots
|
||||
*
|
||||
* Other:
|
||||
* Datapreprocessor, Axis markers
|
||||
*
|
||||
* $Id: horizontal.php,v 1.2 2005/10/05 20:56:38 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include_once 'Image/Graph.php';
|
||||
include_once 'Image/Canvas.php';
|
||||
|
||||
|
||||
$Dataset =& Image_Graph::factory('dataset',
|
||||
array(
|
||||
array(
|
||||
'A' => 10,
|
||||
'B' => 9,
|
||||
'C' => 4,
|
||||
'D' => 6,
|
||||
'E' => 5,
|
||||
'F' => 9,
|
||||
'G' => 11,
|
||||
'H' => 8
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$Dataset2 =& Image_Graph::factory('dataset',
|
||||
array(
|
||||
array(
|
||||
'A' => 121,
|
||||
'B' => 134,
|
||||
'C' => 192,
|
||||
'D' => 213,
|
||||
'E' => 123,
|
||||
'F' => 167,
|
||||
'G' => 153,
|
||||
'H' => 149
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 800, 'height' => 400));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', &$Canvas);
|
||||
|
||||
$Graph->setFont(Image_Graph::factory('font', array('Courier New')));
|
||||
$Graph->setFontSize(8);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Vertical & Horizontal Plots', 11)),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Plotarea2 = Image_Graph::factory('plotarea', array('category', 'axis', 'horizontal'))
|
||||
),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
7
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
$GridY =& $Plotarea->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
$Plot =& $Plotarea->addNew('step', &$Dataset);
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
$Marker =& Image_Graph::factory('value_marker', IMAGE_GRAPH_VALUE_Y);
|
||||
$Marker->setFontSize(7);
|
||||
$Plot->setMarker($Marker);
|
||||
|
||||
$Plot12 =& $Plotarea->addNew('line', &$Dataset2, IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$Plot12->setLineColor('red');
|
||||
|
||||
$Plot->setTitle('Primary axis');
|
||||
$Plot12->setTitle('Secondary axis');
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setTitle('X Data', array('size' => 10));
|
||||
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setTitle('Y Data', array('size' => 10));
|
||||
|
||||
$AxisY2 =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$AxisY2->setTitle('Y2 Data', array('size' => 10));
|
||||
|
||||
$Plotarea->setFillColor('gray@0.2');
|
||||
|
||||
$GridY =& $Plotarea2->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
$Plot2 =& $Plotarea2->addNew('step', &$Dataset);
|
||||
$Plot2->setFillColor('blue@0.2');
|
||||
$Marker2 =& Image_Graph::factory('value_marker', IMAGE_GRAPH_VALUE_Y);
|
||||
$Marker2->setFontSize(7);
|
||||
$Plot2->setMarker($Marker2);
|
||||
|
||||
$Plot22 =& $Plotarea2->addNew('line', &$Dataset2, IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$Plot22->setLineColor('red');
|
||||
|
||||
$Plot2->setTitle('Primary axis');
|
||||
$Plot22->setTitle('Secondary axis');
|
||||
|
||||
$AxisX =& $Plotarea2->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setTitle('X Data', array('size' => 10));
|
||||
|
||||
$AxisY =& $Plotarea2->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setTitle('Y Data', array('size' => 10));
|
||||
|
||||
$AxisY2 =& $Plotarea2->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$AxisY2->setTitle('Y2 Data', array('size' => 10));
|
||||
$Plotarea2->setFillColor('gray@0.2');
|
||||
|
||||
$Graph->done();
|
||||
?>
|
108
includes/pear/Image/docs/examples/html_image_map.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Negative values
|
||||
* (more a test really)
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: html_image_map.php,v 1.2 2005/08/23 21:01:45 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 400, 'height' => 300, 'usemap' => true));
|
||||
|
||||
// This is how you get the ImageMap object, fx. to save map to file (using toHtml())
|
||||
$Imagemap = $Canvas->getImageMap();
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset2 =& Image_Graph::factory('dataset');
|
||||
$Dataset3 =& Image_Graph::factory('dataset');
|
||||
|
||||
$months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
|
||||
|
||||
foreach($months as $month) {
|
||||
|
||||
$Dataset->addPoint(
|
||||
$month,
|
||||
rand(0, 10),
|
||||
array(
|
||||
'url' => 'http://pear.php.net/?month=' . $month,
|
||||
'alt' => $month,
|
||||
'target' => '_blank'
|
||||
)
|
||||
);
|
||||
|
||||
$Dataset2->addPoint(
|
||||
$month,
|
||||
rand(11, 16),
|
||||
array(
|
||||
'url' => 'http://pear.veggerby.dk/' . $month . '/',
|
||||
'alt' => 'Downloads for ' . $month,
|
||||
'target' => '_blank'
|
||||
)
|
||||
);
|
||||
|
||||
$Dataset3->addPoint(
|
||||
$month,
|
||||
rand(-1, -10),
|
||||
array(
|
||||
'url' => 'http://pear.veggerby.dk/' . $month . '/',
|
||||
'alt' => $month . ' 2005',
|
||||
'target' => '_blank',
|
||||
'htmltags' => array(
|
||||
'onMouseOver' => 'alert("Hello, World!");'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$Plot =& $Plotarea->addNew('bar', array(&$Dataset));
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
$Plot2 =& $Plotarea->addNew('line', array(&$Dataset2));
|
||||
$Plot2->setLineColor('red');
|
||||
|
||||
$Plot3 =& $Plotarea->addNew('area', array(&$Dataset3));
|
||||
$Plot3->setFillColor('yellow@0.2');
|
||||
|
||||
// output the Graph
|
||||
$output = $Graph->done(
|
||||
array(
|
||||
'tohtml' => true,
|
||||
'border' => 0,
|
||||
'filename' => 'imagemap.png',
|
||||
'filepath' => './',
|
||||
'urlpath' => ''
|
||||
)
|
||||
);
|
||||
|
||||
print $output . '<pre>' . htmlspecialchars($output) . '</pre>';
|
||||
?>
|
85
includes/pear/Image/docs/examples/image_fill.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate image filling
|
||||
*
|
||||
* Other:
|
||||
* Datapreprocessor, Marker
|
||||
*
|
||||
* $Id: image_fill.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 8 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Image Filling / Data Preprocessing', 11)),
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
8
|
||||
)
|
||||
);
|
||||
|
||||
// create a Y grid
|
||||
$GridY =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
// that is light gray in color
|
||||
$GridY->setFillColor('lightgrey');
|
||||
|
||||
// create the 1st dataset
|
||||
$Dataset1 =& Image_Graph::factory('random', array(8, 70, 100, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot1 =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Area', array(&$Dataset1));
|
||||
// create a vertical gradient fill using red and yellow, ie bottom of graph
|
||||
// will be yellow and the "higher" the value the more red it will be, ie a "fire" effect
|
||||
$Plot1->setFillStyle(Image_Graph::factory('Image_Graph_Fill_Image', './images/mountain.jpg'));
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot1->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_MAX);
|
||||
// fill it with white
|
||||
$Marker->setFillColor('white');
|
||||
// and use black border
|
||||
$Marker->setBorderColor('black');
|
||||
// create a pin-point marker type
|
||||
$PointingMarker =& $Plot1->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
|
||||
// and use the marker on the 1st plot
|
||||
$Plot1->setMarker($PointingMarker);
|
||||
// format value marker labels as percentage values
|
||||
$Marker->setDataPreProcessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
|
||||
|
||||
// create the 2nd dataset
|
||||
$Dataset2 =& Image_Graph::factory('random', array(8, 30, 80, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot2 =& $Plotarea->addNew('bar', array(&$Dataset2));
|
||||
// create a vertical gradient fill using red and yellow, ie bottom of graph
|
||||
// will be yellow and the 'higher' the value the more red it will be, ie a 'fire' effect
|
||||
$Plot2->setFillColor('orange@0.6');
|
||||
|
||||
// Show arrow heads on the axis
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisX->showArrow();
|
||||
$AxisY->showArrow();
|
||||
|
||||
$AxisX->setDataPreProcessor(Image_Graph::factory('Image_Graph_DataPreprocessor_RomanNumerals'));
|
||||
$AxisY->setDataPreProcessor(Image_Graph::factory('Image_Graph_DataPreprocessor_NumberText'));
|
||||
$AxisY->forceMinimum(10);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
BIN
includes/pear/Image/docs/examples/imagemap.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
includes/pear/Image/docs/examples/images/audi-tt-coupe.jpg
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
includes/pear/Image/docs/examples/images/audi.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
includes/pear/Image/docs/examples/images/bmw.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
includes/pear/Image/docs/examples/images/coins.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
includes/pear/Image/docs/examples/images/mercedes.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
includes/pear/Image/docs/examples/images/modify.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
includes/pear/Image/docs/examples/images/mountain.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
includes/pear/Image/docs/examples/images/porsche.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
1
includes/pear/Image/docs/examples/index.html
Normal file
49
includes/pear/Image/docs/examples/layout_matrix.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate Matrix layout
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: layout_matrix.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Matrix Layout', 10)),
|
||||
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(3, 3)),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 9; $i++) {
|
||||
$Dataset =& Image_Graph::factory('random', array(5, 2, 15, false));
|
||||
$Plotarea =& $Matrix->getEntry($i % 3, floor($i / 3));
|
||||
$Plotarea->addNew('line_grid', false, IMAGE_GRAPH_AXIS_X);
|
||||
$Plotarea->addNew('line_grid', false, IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', $Dataset);
|
||||
$Plot->setLineColor('red');
|
||||
$Plot->setTitle("x^2");
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
78
includes/pear/Image/docs/examples/line_break.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate data break in line plots
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: line_break.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(10);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// setup the plotarea, legend and their layout
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Data \'Break\' Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::vertical(
|
||||
$Plotarea1 = Image_Graph::factory('plotarea'),
|
||||
$Plotarea2 = Image_Graph::factory('plotarea'),
|
||||
50
|
||||
),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
88
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
// link the legend with the plotares
|
||||
$Legend->setPlotarea($Plotarea1);
|
||||
$Legend->setPlotarea($Plotarea2);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint('Jan', 10);
|
||||
$Dataset->addPoint('Feb', 12);
|
||||
$Dataset->addPoint('Mar', 3);
|
||||
$Dataset->addPoint('Apr', null);
|
||||
$Dataset->addPoint('May', 4);
|
||||
$Dataset->addPoint('Jun', 10);
|
||||
$Dataset->addPoint('Jul', null);
|
||||
$Dataset->addPoint('Aug', null);
|
||||
$Dataset->addPoint('Sep', 9);
|
||||
$Dataset->addPoint('Oct', 10);
|
||||
$Dataset->addPoint('Nov', 4);
|
||||
$Dataset->addPoint('Dec', 14);
|
||||
|
||||
// create the line plot
|
||||
$Plot1 =& $Plotarea1->addNew('line', array(&$Dataset));
|
||||
// set line color
|
||||
$Plot1->setLineColor('red');
|
||||
|
||||
// create the line plot
|
||||
$Plot2 =& $Plotarea2->addNew('smooth_line', array(&$Dataset));
|
||||
// set line color
|
||||
$Plot2->setLineColor('blue');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
104
includes/pear/Image/docs/examples/log_axis.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate logarithmic axis
|
||||
*
|
||||
* Other:
|
||||
* Matrix layout, Axis titles
|
||||
*
|
||||
* $Id: log_axis.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 400, 'antialias' => true));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 15 pixels
|
||||
$Font->setSize(8);
|
||||
// add a title using the created font
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Axis['X'][($i*2+$j)] = 'axis' . ($i % 2 == 0 ? '' : '_log');
|
||||
$Axis['Y'][($i*2+$j)] = 'axis' . ($j % 2 == 0 ? '' : '_log');
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$Plotarea[$i] =& Image_Graph::factory('plotarea', array($Axis['X'][$i], $Axis['Y'][$i]));
|
||||
}
|
||||
|
||||
$Graph->setFont($Font);
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Logarithmic Axis', 11)),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Normal Y-Axis', array('size' => 10, 'angle' => 90))),
|
||||
Image_Graph::factory('title', array('Logarithmic Y-Axis', array('size' => 10, 'angle' => 90)))
|
||||
),
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Normal X-Axis', 10)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea[0],
|
||||
$Plotarea[1]
|
||||
),
|
||||
7
|
||||
),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('Image_Graph_Title', array('Logarithmic X-Axis', 10)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea[2],
|
||||
$Plotarea[3]
|
||||
),
|
||||
7
|
||||
)
|
||||
),
|
||||
4
|
||||
),
|
||||
$Legend = Image_Graph::factory('Image_Graph_Legend'),
|
||||
92
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea[0]);
|
||||
|
||||
$Dataset = Image_Graph::factory('dataset');
|
||||
$i = 1;
|
||||
while ($i <= 10) {
|
||||
$Dataset->addPoint($i, $i*$i);
|
||||
$i++;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$Plotarea[$i]->addNew('line_grid', false, IMAGE_GRAPH_AXIS_X);
|
||||
$Plotarea[$i]->addNew('line_grid', false, IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
if ($i % 2 == 1) {
|
||||
$Axis =& $Plotarea[$i]->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$Axis->setLabelInterval(array(1, 2, 3, 5, 10, 20, 30, 50, 100));
|
||||
}
|
||||
|
||||
|
||||
$Plot =& $Plotarea[$i]->addNew('line', array(&$Dataset));
|
||||
$Plot->setLineColor('red');
|
||||
$Plot->setTitle("x^2");
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
106
includes/pear/Image/docs/examples/log_axis_intersect.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate logarithmic axis
|
||||
*
|
||||
* Other:
|
||||
* Matrix layout, Axis titles
|
||||
*
|
||||
* $Id: log_axis_intersect.php,v 1.1 2005/09/30 18:59:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 400, 'antialias' => true));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 15 pixels
|
||||
$Font->setSize(8);
|
||||
// add a title using the created font
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$Axis['X'][($i*2+$j)] = 'axis' . ($i % 2 == 0 ? '' : '_log');
|
||||
$Axis['Y'][($i*2+$j)] = 'axis' . ($j % 2 == 0 ? '' : '_log');
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$Plotarea[$i] =& Image_Graph::factory('plotarea', array($Axis['X'][$i], $Axis['Y'][$i]));
|
||||
}
|
||||
|
||||
$Graph->setFont($Font);
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Logarithmic Axis', 11)),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Normal Y-Axis', array('size' => 10, 'angle' => 90))),
|
||||
Image_Graph::factory('title', array('Logarithmic Y-Axis', array('size' => 10, 'angle' => 90)))
|
||||
),
|
||||
Image_Graph::horizontal(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Normal X-Axis', 10)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea[0],
|
||||
$Plotarea[1]
|
||||
),
|
||||
7
|
||||
),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('Image_Graph_Title', array('Logarithmic X-Axis', 10)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea[2],
|
||||
$Plotarea[3]
|
||||
),
|
||||
7
|
||||
)
|
||||
),
|
||||
4
|
||||
),
|
||||
$Legend = Image_Graph::factory('Image_Graph_Legend'),
|
||||
92
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea[0]);
|
||||
|
||||
$Dataset = Image_Graph::factory('dataset');
|
||||
$i = 1;
|
||||
while ($i <= 10) {
|
||||
$Dataset->addPoint($i, $i*$i);
|
||||
$i++;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$Plotarea[$i]->addNew('line_grid', false, IMAGE_GRAPH_AXIS_X);
|
||||
$Plotarea[$i]->addNew('line_grid', false, IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
if ($i % 2 == 1) {
|
||||
$Axis =& $Plotarea[$i]->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$Axis->setLabelInterval(array(1, 2, 3, 5, 10, 20, 30, 50, 100));
|
||||
}
|
||||
|
||||
$AxisX =& $Plotarea[$i]->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setAxisIntersection('max');
|
||||
|
||||
$Plot =& $Plotarea[$i]->addNew('line', array(&$Dataset));
|
||||
$Plot->setLineColor('red');
|
||||
$Plot->setTitle("x^2");
|
||||
}
|
||||
|
||||
$Graph->done();
|
||||
?>
|
194
includes/pear/Image/docs/examples/logo_graph.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Graph used in logo
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: logo_graph.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
// create a new GD canvas
|
||||
$Canvas =& Image_Canvas::factory('png',
|
||||
array(
|
||||
'width' => 600,
|
||||
'height' => 400
|
||||
)
|
||||
);
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Weather Conditions', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea_Weather = Image_Graph::factory('plotarea'),
|
||||
$Legend_Weather = Image_Graph::factory('legend'),
|
||||
85
|
||||
),
|
||||
7)
|
||||
);
|
||||
$Legend_Weather->setPlotarea($Plotarea_Weather);
|
||||
$Legend_Weather->setFontSize(7);
|
||||
|
||||
/* $GridY_Weather =& $Plotarea_Weather->addNew(
|
||||
'line_grid',
|
||||
null,
|
||||
IMAGE_GRAPH_AXIS_Y
|
||||
);
|
||||
$GridY_Weather->setLineColor('gray@0.1');
|
||||
|
||||
$Marker_AverageSpan =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Axis_Marker_Area',
|
||||
IMAGE_GRAPH_AXIS_Y
|
||||
);
|
||||
$Marker_AverageSpan->setFillColor('green@0.2');
|
||||
$Marker_AverageSpan->setLowerBound(3.8);
|
||||
$Marker_AverageSpan->setUpperBound(11.4);
|
||||
|
||||
$Marker_Average =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Axis_Marker_Line',
|
||||
IMAGE_GRAPH_AXIS_Y
|
||||
);
|
||||
$Marker_Average->setLineColor('blue@0.4');
|
||||
$Marker_Average->setValue(7.7);*/
|
||||
|
||||
$Dataset_Rainfall =& Image_Graph::factory('dataset');
|
||||
$Dataset_Rainfall->addPoint('Jan', 60);
|
||||
$Dataset_Rainfall->addPoint('Feb', 41);
|
||||
$Dataset_Rainfall->addPoint('Mar', 48);
|
||||
$Dataset_Rainfall->addPoint('Apr', 42);
|
||||
$Dataset_Rainfall->addPoint('May', 50);
|
||||
$Dataset_Rainfall->addPoint('Jun', 55);
|
||||
$Dataset_Rainfall->addPoint('Jul', 67);
|
||||
$Dataset_Rainfall->addPoint('Aug', 65);
|
||||
$Dataset_Rainfall->addPoint('Sep', 72);
|
||||
$Dataset_Rainfall->addPoint('Oct', 77);
|
||||
$Dataset_Rainfall->addPoint('Nov', 80);
|
||||
$Dataset_Rainfall->addPoint('Dec', 68);
|
||||
$Plot_Rainfall =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'bar',
|
||||
array(&$Dataset_Rainfall),
|
||||
IMAGE_GRAPH_AXIS_Y_SECONDARY
|
||||
);
|
||||
$Plot_Rainfall->setLineColor('gray');
|
||||
$Plot_Rainfall->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', '#7AB025')));
|
||||
$Plot_Rainfall->setTitle('Average rainfall');
|
||||
|
||||
$Dataset_TempAvg =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempAvg->addPoint('Jan', 0.2);
|
||||
$Dataset_TempAvg->addPoint('Feb', 0.1);
|
||||
$Dataset_TempAvg->addPoint('Mar', 2.3);
|
||||
$Dataset_TempAvg->addPoint('Apr', 5.8);
|
||||
$Dataset_TempAvg->addPoint('May', 10.8);
|
||||
$Dataset_TempAvg->addPoint('Jun', 14.1);
|
||||
$Dataset_TempAvg->addPoint('Jul', 16.2);
|
||||
$Dataset_TempAvg->addPoint('Aug', 15.9);
|
||||
$Dataset_TempAvg->addPoint('Sep', 12.1);
|
||||
$Dataset_TempAvg->addPoint('Oct', 8.7);
|
||||
$Dataset_TempAvg->addPoint('Nov', 4.4);
|
||||
$Dataset_TempAvg->addPoint('Dec', 1.8);
|
||||
$Plot_TempAvg =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Plot_Smoothed_Line',
|
||||
array(&$Dataset_TempAvg)
|
||||
);
|
||||
$Plot_TempAvg->setLineColor('#7AB025');
|
||||
$Plot_TempAvg->setTitle('Average temperature');
|
||||
|
||||
$Dataset_TempMin =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempMin->addPoint('Jan', -2.7);
|
||||
$Dataset_TempMin->addPoint('Feb', -2.8);
|
||||
$Dataset_TempMin->addPoint('Mar', -0.9);
|
||||
$Dataset_TempMin->addPoint('Apr', 1.2);
|
||||
$Dataset_TempMin->addPoint('May', 5.5);
|
||||
$Dataset_TempMin->addPoint('Jun', 9.2);
|
||||
$Dataset_TempMin->addPoint('Jul', 11.3);
|
||||
$Dataset_TempMin->addPoint('Aug', 11.1);
|
||||
$Dataset_TempMin->addPoint('Sep', 7.8);
|
||||
$Dataset_TempMin->addPoint('Oct', 5.0);
|
||||
$Dataset_TempMin->addPoint('Nov', 1.5);
|
||||
$Dataset_TempMin->addPoint('Dec', -0.9);
|
||||
$Plot_TempMin =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Plot_Smoothed_Line',
|
||||
array(&$Dataset_TempMin)
|
||||
);
|
||||
$Plot_TempMin->setLineColor('gray');
|
||||
$Plot_TempMin->setTitle('Minimum temperature');
|
||||
|
||||
$Dataset_TempMax =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempMax->addPoint('Jan', 2.4);
|
||||
$Dataset_TempMax->addPoint('Feb', 2.5);
|
||||
$Dataset_TempMax->addPoint('Mar', 5.4);
|
||||
$Dataset_TempMax->addPoint('Apr', 10.5);
|
||||
$Dataset_TempMax->addPoint('May', 15.8);
|
||||
$Dataset_TempMax->addPoint('Jun', 18.9);
|
||||
$Dataset_TempMax->addPoint('Jul', 21.2);
|
||||
$Dataset_TempMax->addPoint('Aug', 20.8);
|
||||
$Dataset_TempMax->addPoint('Sep', 16.3);
|
||||
$Dataset_TempMax->addPoint('Oct', 11.8);
|
||||
$Dataset_TempMax->addPoint('Nov', 6.9);
|
||||
$Dataset_TempMax->addPoint('Dec', 4.1);
|
||||
$Plot_TempMax =&
|
||||
$Plotarea_Weather->addNew(
|
||||
'Image_Graph_Plot_Smoothed_Line',
|
||||
array(&$Dataset_TempMax)
|
||||
);
|
||||
$Plot_TempMax->setLineColor('black');
|
||||
$Plot_TempMax->setTitle('Maximum temperature');
|
||||
|
||||
$DataPreprocessor_MM =&
|
||||
Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d mm');
|
||||
$DataPreprocessor_DegC =&
|
||||
Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d C');
|
||||
|
||||
$Marker_Rainfall =&
|
||||
$Plot_Rainfall->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
$Marker_Rainfall->setDataPreprocessor($DataPreprocessor_MM);
|
||||
$Marker_Rainfall->setFontSize(7);
|
||||
$PointingMarker_Rainfall =&
|
||||
$Plot_Rainfall->addNew(
|
||||
'Image_Graph_Marker_Pointing_Angular',
|
||||
array(20, &$Marker_Rainfall)
|
||||
);
|
||||
$Plot_Rainfall->setMarker($PointingMarker_Rainfall);
|
||||
|
||||
$AxisY_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY_Weather->showLabel(IMAGE_GRAPH_LABEL_ZERO);
|
||||
$AxisY_Weather->setDataPreprocessor($DataPreprocessor_DegC);
|
||||
$AxisY_Weather->setTitle('Temperature', array('angle' => 90, 'size' => 10));
|
||||
$AxisY_Weather->forceMinimum(-4);
|
||||
|
||||
$AxisYsecondary_Weather =&
|
||||
$Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$AxisYsecondary_Weather->setDataPreprocessor($DataPreprocessor_MM);
|
||||
$AxisYsecondary_Weather->setTitle('Rainfall', array('angle' => 270, 'size' => 10));
|
||||
|
||||
$AxisX_Weather =&
|
||||
$Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX_Weather->setAxisIntersection('min');
|
||||
|
||||
//$Graph->setBackgroundColor('#F7F9F9');
|
||||
// output the graph using the GD canvas
|
||||
$Graph->done();
|
||||
?>
|
42
includes/pear/Image/docs/examples/manual_labels.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate how to manually set axis labels
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: manual_labels.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(500, 200));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Plotarea =& $Graph->addNew('plotarea');
|
||||
|
||||
$Dataset =& Image_Graph::factory('random', array(8, 1, 10));
|
||||
$Plot =& $Plotarea->addNew('line', array(&$Dataset));
|
||||
|
||||
$LineStyle =& Image_Graph::factory('Image_Graph_Line_Dashed', array('red', 'transparent'));
|
||||
//$Plot->setLineColor('red');
|
||||
$Plot->setLineStyle($LineStyle);
|
||||
|
||||
$AxisY =& $Plotarea->getAxis('y');
|
||||
$AxisY->setLabelInterval(array(2, 4, 9));
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
197
includes/pear/Image/docs/examples/misc01.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate "semi-real" graph
|
||||
*
|
||||
* Other:
|
||||
* One legend for many plotareas, Plotarea customizations, Fillarray usage,
|
||||
* Datapreprocessor, Axis customizations
|
||||
*
|
||||
* $Id: misc01.php,v 1.6 2005/10/05 20:51:18 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('Image_Graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Dataset_SmoothedLine =& Image_Graph::factory('dataset');
|
||||
$Dataset_SmoothedLine->addPoint('DK', 6);
|
||||
$Dataset_SmoothedLine->addPoint('UK', 8);
|
||||
$Dataset_SmoothedLine->addPoint('PO', 2);
|
||||
$Dataset_SmoothedLine->addPoint('NL', 4);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('A Sample Demonstrating Many-a-thing', 15)),
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea_BarAndLine = Image_Graph::factory('plotarea'),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea_SmoothedLine = Image_Graph::factory('plotarea'),
|
||||
$Plotarea_Radar = Image_Graph::factory('Image_Graph_Plotarea_Radar')
|
||||
),
|
||||
65
|
||||
),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
9
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea_BarAndLine);
|
||||
$Legend->setPlotarea($Plotarea_SmoothedLine);
|
||||
$Legend->setPlotarea($Plotarea_Radar);
|
||||
|
||||
// $Plotarea_SmoothedLine->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'lightred', 'brown')));
|
||||
$Plotarea_SmoothedLine->setBorderColor('black');
|
||||
$Plotarea_SmoothedLine->showShadow();
|
||||
$Plotarea_SmoothedLine->setPadding(15);
|
||||
$Plotarea_SmoothedLine->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'brown')));
|
||||
|
||||
// create a Y grid
|
||||
$Grid_Radar =& $Plotarea_Radar->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid_Radar->setLineColor('lightgrey');
|
||||
|
||||
// create a Y grid
|
||||
$Grid_BarAndLine =& $Plotarea_BarAndLine->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
// that is light gray in color
|
||||
$Grid_BarAndLine->setFillColor('blue@0.3');
|
||||
|
||||
// create a Y grid
|
||||
$Grid_SmoothedLine =& $Plotarea_SmoothedLine->addNew('line_grid', false, IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid_SmoothedLine->setLineColor('gray');
|
||||
$Grid_SmoothedLine =& $Plotarea_SmoothedLine->addNew('line_grid', false, IMAGE_GRAPH_AXIS_X);
|
||||
$Grid_SmoothedLine->setLineColor('gray');
|
||||
|
||||
// create the 1st dataset
|
||||
//$Dataset_SmoothedLine =& new Image_RandomDataset(4, 2, 15, true);
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot_SmoothedLine =& $Plotarea_SmoothedLine->addNew('Image_Graph_Plot_Smoothed_Line', $Dataset_SmoothedLine);
|
||||
$Plot_SmoothedLine->setLineColor('orange');
|
||||
|
||||
// create a 3rd dataset
|
||||
$Dataset_BarChart =& Image_Graph::factory('random', array(7, 10, 120, false));
|
||||
// create the 3rd plot as line chart using the 2nd dataset
|
||||
$Plot_BarChart =& $Plotarea_BarAndLine->addNew('bar', array(&$Dataset_BarChart));
|
||||
// set the fill style of the barchart to the almost transparent BlueAlpha
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot_BarChart->setFillStyle($FillArray);
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'red'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', 'blue'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'orange', 'white'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'green', 'white'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'purple'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR, 'white', 'brown'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR, 'white', 'black'));
|
||||
|
||||
// create the 2nd dataset
|
||||
$Dataset_LineMarker =& Image_Graph::factory('random', array(7, 20, 100, false));
|
||||
// create the 2nd plot as line chart using the 2nd dataset
|
||||
$Plot_LineMarker =& $Plotarea_BarAndLine->addNew('line', array(&$Dataset_LineMarker));
|
||||
|
||||
$LineStyle =& Image_Graph::factory('Image_Graph_Line_Dotted', array('black', 'transparent'));
|
||||
$Plot_LineMarker->setLineStyle($LineStyle);
|
||||
|
||||
$Marker =& Image_Graph::factory('Image_Graph_Marker_Array');
|
||||
$CrossMarker =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||
$PlusMarker =& Image_Graph::factory('Image_Graph_Marker_Plus');
|
||||
$StarMarker =& Image_Graph::factory('Image_Graph_Marker_Star');
|
||||
$Marker->add($CrossMarker);
|
||||
$Marker->add($PlusMarker);
|
||||
$Marker->add($StarMarker);
|
||||
$Plot_LineMarker->setMarker($Marker);
|
||||
|
||||
$CrossMarker->setLineColor('black');
|
||||
$CrossMarker->setFillColor('green');
|
||||
$PlusMarker->setLineColor('black');
|
||||
$PlusMarker->setFillColor('red');
|
||||
$StarMarker->setLineColor('black@0.4');
|
||||
$StarMarker->setFillColor('yellow');
|
||||
|
||||
// Show arrow heads on the axis
|
||||
$AxisX =& $Plotarea_BarAndLine->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisY =& $Plotarea_BarAndLine->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
$AxisY->setLabelInterval(5, 2);
|
||||
$AxisY->setTickOptions(-1, 1, 2);
|
||||
|
||||
// create an data label array for formatting label data based on an array
|
||||
$ArrayData =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
|
||||
array(
|
||||
array(
|
||||
1=>'A Point',
|
||||
2=>'Another',
|
||||
6=>'Yet another'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// use the data label array on the X axis
|
||||
$AxisX->setDataPreprocessor($ArrayData);
|
||||
$AxisX->setFontAngle('vertical');
|
||||
$AxisX->setTitle('Very obvious', array('angle' => 0, 'size' => 10));
|
||||
|
||||
$Plotarea_BarAndLine->setAxisPadding(array('left' => 20, 'right' => 20));
|
||||
|
||||
$Plot_SmoothedLine->setTitle('Oil');
|
||||
$Plot_LineMarker->setTitle('Clearly not a good day');
|
||||
$Plot_BarChart->setTitle('Buy or Sell');
|
||||
|
||||
// create the dataset
|
||||
$Dataset_Radar1 =& Image_Graph::factory('random', array(8, 1, 5));
|
||||
$Dataset_Radar2 =& Image_Graph::factory('random', array(8, 1, 5));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot_Radar1 =& $Plotarea_Radar->addNew('Image_Graph_Plot_Radar', array(&$Dataset_Radar1));
|
||||
$Plot_Radar1->setTitle('Obscurity');
|
||||
$Plot_Radar2 =& $Plotarea_Radar->addNew('Image_Graph_Plot_Radar', array(&$Dataset_Radar2));
|
||||
$Plot_Radar2->setTitle('Clarity');
|
||||
|
||||
//$Dataset_Radar1->setMaximumY(7);
|
||||
|
||||
$DataPreprocessor =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
|
||||
array(
|
||||
array(
|
||||
1 => 'Irrelevance',
|
||||
2 => 'Regular',
|
||||
3 => 'Partly',
|
||||
4 => 'Relevance',
|
||||
5 => 'Something',
|
||||
6 => 'Everything',
|
||||
7 => 'Nothing',
|
||||
8 => 'Irregular'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$AxisX =& $Plotarea_Radar->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setDataPreprocessor($DataPreprocessor);
|
||||
|
||||
//$Plot_Radar1->setMarker(new Image_CrossMarker(), 'Marker');
|
||||
//$Plot_Radar1->setLineStyle($YELLOW);
|
||||
|
||||
$AverageMarker =& Image_Graph::factory('Image_Graph_Marker_Average');
|
||||
$Plot_SmoothedLine->setMarker($AverageMarker);
|
||||
$AverageMarker->setLineColor('purple');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot_Radar1->setFillColor('yellow@0.2');
|
||||
$Plot_Radar2->setFillColor('green@0.2');
|
||||
// output the Graph
|
||||
|
||||
$Graph->done();
|
||||
?>
|
117
includes/pear/Image/docs/examples/misc02.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate a plot
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: misc02.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
function XtoYear($Value)
|
||||
{
|
||||
return floor($Value+2000);
|
||||
}
|
||||
|
||||
function salaries($Value)
|
||||
{
|
||||
// I wish!
|
||||
return exp($Value)+1000;
|
||||
}
|
||||
|
||||
// create the graph as a 500 x 300 image
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 300));
|
||||
$Graph->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'lightsteelblue', 'papayawhip')));
|
||||
|
||||
// create a random dataset to use for demonstrational purposes
|
||||
$DataSet =& Image_Graph::factory('function', array(1, 9, 'salaries', 8));
|
||||
|
||||
$DataSet2 =& Image_Graph::factory('dataset');
|
||||
$DataSet2->addPoint('CEO', 10);
|
||||
$DataSet2->addPoint('TAP', 32);
|
||||
$DataSet2->addPoint('TBF', 13);
|
||||
$DataSet2->addPoint('ABC', 19);
|
||||
$DataSet2->addPoint('QED', 26);
|
||||
|
||||
// create and set the plot font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
$Font->setSize(7);
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// add a plot area in a vertical layout to display a title on top
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Annual income', 11)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea2 = Image_Graph::factory('plotarea'),
|
||||
$Legend2 = Image_Graph::factory('legend'),
|
||||
90
|
||||
)
|
||||
),
|
||||
5
|
||||
),
|
||||
5
|
||||
);
|
||||
|
||||
$Legend2->setPlotarea($Plotarea2);
|
||||
|
||||
// create a bar grid and fill it with a gradient fill white->lightgray
|
||||
$Grid =& $Plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid->setFillColor('gray@0.2');
|
||||
|
||||
$Plotarea->setFillColor('gray@0.2');
|
||||
|
||||
// add a line plot to the plotarea based on the function dataset
|
||||
$Plot =& $Plotarea->addNew('line', array(&$DataSet));
|
||||
|
||||
// add coins-icon as marker
|
||||
$Plot->setMarker(Image_Graph::factory('Image_Graph_Marker_Icon', './images/coins.png'));
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
// make x-axis start at 0
|
||||
$AxisX->forceMinimum(0);
|
||||
|
||||
// make x-axis end at 9
|
||||
$AxisX->forceMaximum(9);
|
||||
|
||||
// show axis arrows
|
||||
$AxisY->showArrow();
|
||||
|
||||
// make y-axis have a maximum at 9.500
|
||||
$AxisY->forceMaximum(9500);
|
||||
|
||||
// create a datapreprocessor to map X-values to years
|
||||
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'XtoYear'));
|
||||
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Currency', "US$"));
|
||||
|
||||
$Plot2 =& $Plotarea2->addNew('pie', array(&$DataSet2));
|
||||
$Plotarea2->hideAxis();
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red'));
|
||||
$Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'blue'));
|
||||
$Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'yellow'));
|
||||
$Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'));
|
||||
$Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'));
|
||||
$Plot2->setFillStyle($Fill);
|
||||
|
||||
$Marker2 =& $Graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
|
||||
$Plot2->setMarker($Marker2);
|
||||
$Marker2->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.0f%%'));
|
||||
|
||||
$Plot2->explode(20, 'TBF');
|
||||
|
||||
// output the graph
|
||||
$Graph->done();
|
||||
?>
|
78
includes/pear/Image/docs/examples/misc03.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate radial gradient fillings
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: misc03.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 7 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Meat Export', 12)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
70
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the 1st dataset
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
$Dataset1->addPoint('Beef', rand(1, 10));
|
||||
$Dataset1->addPoint('Pork', rand(1, 10));
|
||||
$Dataset1->addPoint('Poultry', rand(1, 10));
|
||||
$Dataset1->addPoint('Camels', rand(1, 10));
|
||||
$Dataset1->addPoint('Other', rand(1, 10));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('pie', array(&$Dataset1));
|
||||
$Plotarea->hideAxis();
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL);
|
||||
// create a pin-point marker type
|
||||
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
|
||||
// and use the marker on the 1st plot
|
||||
$Plot->setMarker($PointingMarker);
|
||||
// format value marker labels as percentage values
|
||||
$Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
|
||||
|
||||
$Plot->Radius = 2;
|
||||
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot->setFillStyle($FillArray);
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'blue'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'yellow'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'));
|
||||
|
||||
$Plot->explode(5);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
35
includes/pear/Image/docs/examples/misc04.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Somebody liked it :)
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: misc04.php,v 1.2 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(500, 300));
|
||||
|
||||
$Plotarea =& $Graph->addNew('plotarea');
|
||||
|
||||
$Dataset =& Image_Graph::factory('Image_Graph_Dataset_Random', array(20, 10, 100, true));
|
||||
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Image', './images/audi-tt-coupe.jpg');
|
||||
$Plotarea->setFillStyle($Fill);
|
||||
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Area', $Dataset);
|
||||
|
||||
$Plot->setFillColor('white@0.4');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
146
includes/pear/Image/docs/examples/misc05.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate a "semi-real" graph
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: misc05.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
$Font->setSize(9);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Weather Conditions by Month', 12)),
|
||||
Image_Graph::factory('title', array('Location: <20>rhus, Denmark', 8)),
|
||||
80
|
||||
),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea_Weather = Image_Graph::factory('plotarea'),
|
||||
$Legend_Weather = Image_Graph::factory('legend'),
|
||||
85
|
||||
),
|
||||
9)
|
||||
);
|
||||
$Legend_Weather->setPlotarea($Plotarea_Weather);
|
||||
|
||||
$GridY_Weather =& $Plotarea_Weather->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$GridY_Weather->setLineColor('gray@0.1');
|
||||
|
||||
$Dataset_TempAvg =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempAvg->addPoint('Jan', 0.2);
|
||||
$Dataset_TempAvg->addPoint('Feb', 0.1);
|
||||
$Dataset_TempAvg->addPoint('Mar', 2.3);
|
||||
$Dataset_TempAvg->addPoint('Apr', 5.8);
|
||||
$Dataset_TempAvg->addPoint('May', 10.8);
|
||||
$Dataset_TempAvg->addPoint('Jun', 14.1);
|
||||
$Dataset_TempAvg->addPoint('Jul', 16.2);
|
||||
$Dataset_TempAvg->addPoint('Aug', 15.9);
|
||||
$Dataset_TempAvg->addPoint('Sep', 12.1);
|
||||
$Dataset_TempAvg->addPoint('Oct', 8.7);
|
||||
$Dataset_TempAvg->addPoint('Nov', 4.4);
|
||||
$Dataset_TempAvg->addPoint('Dec', 1.8);
|
||||
$Plot_TempAvg =& $Plotarea_Weather->addNew('smooth_line', array(&$Dataset_TempAvg));
|
||||
$Plot_TempAvg->setLineColor('blue');
|
||||
$Plot_TempAvg->setTitle('Average temperature');
|
||||
|
||||
$Dataset_TempMin =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempMin->addPoint('Jan', -2.7);
|
||||
$Dataset_TempMin->addPoint('Feb', -2.8);
|
||||
$Dataset_TempMin->addPoint('Mar', -0.9);
|
||||
$Dataset_TempMin->addPoint('Apr', 1.2);
|
||||
$Dataset_TempMin->addPoint('May', 5.5);
|
||||
$Dataset_TempMin->addPoint('Jun', 9.2);
|
||||
$Dataset_TempMin->addPoint('Jul', 11.3);
|
||||
$Dataset_TempMin->addPoint('Aug', 11.1);
|
||||
$Dataset_TempMin->addPoint('Sep', 7.8);
|
||||
$Dataset_TempMin->addPoint('Oct', 5.0);
|
||||
$Dataset_TempMin->addPoint('Nov', 1.5);
|
||||
$Dataset_TempMin->addPoint('Dec', -0.9);
|
||||
$Plot_TempMin =& $Plotarea_Weather->addNew('smooth_line', array(&$Dataset_TempMin));
|
||||
$Plot_TempMin->setLineColor('teal');
|
||||
$Plot_TempMin->setTitle('Minimum temperature');
|
||||
|
||||
$Dataset_TempMax =& Image_Graph::factory('dataset');
|
||||
$Dataset_TempMax->addPoint('Jan', 2.4);
|
||||
$Dataset_TempMax->addPoint('Feb', 2.5);
|
||||
$Dataset_TempMax->addPoint('Mar', 5.4);
|
||||
$Dataset_TempMax->addPoint('Apr', 10.5);
|
||||
$Dataset_TempMax->addPoint('May', 15.8);
|
||||
$Dataset_TempMax->addPoint('Jun', 18.9);
|
||||
$Dataset_TempMax->addPoint('Jul', 21.2);
|
||||
$Dataset_TempMax->addPoint('Aug', 20.8);
|
||||
$Dataset_TempMax->addPoint('Sep', 16.3);
|
||||
$Dataset_TempMax->addPoint('Oct', 11.8);
|
||||
$Dataset_TempMax->addPoint('Nov', 6.9);
|
||||
$Dataset_TempMax->addPoint('Dec', 4.1);
|
||||
$Plot_TempMax =& $Plotarea_Weather->addNew('smooth_line', array(&$Dataset_TempMax));
|
||||
$Plot_TempMax->setLineColor('red');
|
||||
$Plot_TempMax->setTitle('Maximum temperature');
|
||||
|
||||
$Marker_AverageSpan =& $Plotarea_Weather->addNew('Image_Graph_Axis_Marker_Area', IMAGE_GRAPH_AXIS_Y);
|
||||
$Marker_AverageSpan->setFillColor('green@0.2');
|
||||
$Marker_AverageSpan->setLowerBound(3.8);
|
||||
$Marker_AverageSpan->setUpperBound(11.4);
|
||||
|
||||
$Marker_Average =& $Plotarea_Weather->addNew('Image_Graph_Axis_Marker_Line', IMAGE_GRAPH_AXIS_Y);
|
||||
$Marker_Average->setLineColor('blue@0.4');
|
||||
$Marker_Average->setValue(7.7);
|
||||
|
||||
$Dataset_Rainfall =& Image_Graph::factory('dataset');
|
||||
$Dataset_Rainfall->addPoint('Jan', 60);
|
||||
$Dataset_Rainfall->addPoint('Feb', 41);
|
||||
$Dataset_Rainfall->addPoint('Mar', 48);
|
||||
$Dataset_Rainfall->addPoint('Apr', 42);
|
||||
$Dataset_Rainfall->addPoint('May', 50);
|
||||
$Dataset_Rainfall->addPoint('Jun', 55);
|
||||
$Dataset_Rainfall->addPoint('Jul', 67);
|
||||
$Dataset_Rainfall->addPoint('Aug', 65);
|
||||
$Dataset_Rainfall->addPoint('Sep', 72);
|
||||
$Dataset_Rainfall->addPoint('Oct', 77);
|
||||
$Dataset_Rainfall->addPoint('Nov', 80);
|
||||
$Dataset_Rainfall->addPoint('Dec', 68);
|
||||
$Plot_Rainfall =& $Plotarea_Weather->addNew('bar', array(&$Dataset_Rainfall), IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$Plot_Rainfall->setLineColor('gray');
|
||||
$Plot_Rainfall->setFillColor('blue@0.1');
|
||||
$Plot_Rainfall->setTitle('Average rainfall');
|
||||
|
||||
$DataPreprocessor_MM =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d mm');
|
||||
$DataPreprocessor_DegC =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d C');
|
||||
|
||||
$Marker_Rainfall =& $Plot_Rainfall->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
$Marker_Rainfall->setDataPreprocessor($DataPreprocessor_MM);
|
||||
$PointingMarker_Rainfall =& $Plot_Rainfall->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker_Rainfall));
|
||||
$Plot_Rainfall->setMarker($PointingMarker_Rainfall);
|
||||
|
||||
$AxisX_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX_Weather->setAxisIntersection('min');
|
||||
|
||||
$AxisY_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY_Weather->showLabel(IMAGE_GRAPH_LABEL_ZERO);
|
||||
$AxisY_Weather->setDataPreprocessor($DataPreprocessor_DegC);
|
||||
$AxisY_Weather->setTitle('Temperature', 'vertical');
|
||||
|
||||
$AxisYsecondary_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$AxisYsecondary_Weather->setDataPreprocessor($DataPreprocessor_MM);
|
||||
$AxisYsecondary_Weather->setTitle('Rainfall', 'vertical2');
|
||||
|
||||
// output the graph
|
||||
$Graph->done();
|
||||
?>
|
132
includes/pear/Image/docs/examples/misc06.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* "Semi-real" plot
|
||||
*
|
||||
* Other:
|
||||
* Gradient filling, Icon markers (and marker array), Datapreprocessor
|
||||
*
|
||||
* $Id: misc06.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Arial =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 8 pixels
|
||||
$Arial->setSize(8);
|
||||
// set default font color to white
|
||||
$Arial->setColor('white');
|
||||
|
||||
// make the entire graph use this font
|
||||
$Graph->setFont($Arial);
|
||||
|
||||
// create the graph layout
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('German Car Popularity', 11)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
7
|
||||
)
|
||||
);
|
||||
|
||||
// associate the legend with the plotarea
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// make the graph have a gradient filled background
|
||||
$Graph->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'green', 'lightblue')));
|
||||
// and a black border
|
||||
$Graph->setBorderColor('black');
|
||||
|
||||
// create and populate the dataset for 'popularity'
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint('Audi', 100);
|
||||
$Dataset->addPoint('Mercedes', 41);
|
||||
$Dataset->addPoint('Porsche', 78);
|
||||
$Dataset->addPoint('BMW', 12);
|
||||
|
||||
// create and populate the dataset for 'defects / 1000 units'
|
||||
$Dataset2 =& Image_Graph::factory('dataset');
|
||||
$Dataset2->addPoint('Audi', 10);
|
||||
$Dataset2->addPoint('Mercedes', 17);
|
||||
$Dataset2->addPoint('Porsche', 12);
|
||||
$Dataset2->addPoint('BMW', 21);
|
||||
|
||||
// add a line grid
|
||||
$GridY =& $Plotarea->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
// make it have a slightly transparent white color
|
||||
$GridY->setLineColor('white@0.8');
|
||||
|
||||
// create the plot as bar chart using the 'popularity' dataset
|
||||
$Plot =& $Plotarea->addNew('bar', array(&$Dataset));
|
||||
// set the plot title (for legends)
|
||||
$Plot->setTitle('Popularity');
|
||||
|
||||
// create a fill array to make the bars have individual fill's
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'orange'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'blue'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'yellow'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'red'));
|
||||
|
||||
// make the 'popularity' plot use this fillarray
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
// create a marker array and populate it with icon markers
|
||||
$Marker =& $Graph->addNew('Image_Graph_Marker_Array');
|
||||
$Marker->addNew('icon_marker', './images/audi.png');
|
||||
$Marker->addNew('icon_marker', './images/mercedes.png');
|
||||
$Marker->addNew('icon_marker', './images/porsche.png');
|
||||
$Marker->addNew('icon_marker', './images/bmw.png');
|
||||
|
||||
// make the plot use the marker array
|
||||
$Plot->setMarker($Marker);
|
||||
|
||||
// create the 2nd plot ('defects / 1000 units') as a line plot and associate
|
||||
// it with the secondary y-axis (implicitly this creates a y-axis of the class
|
||||
// Image_Graph_Axis)
|
||||
$Plot2 =& $Plotarea->addNew('line', array(&$Dataset2), IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
// set the plot title
|
||||
$Plot2->setTitle('Defects');
|
||||
// and line style
|
||||
$Plot2->setLineColor('gray@0.8');
|
||||
|
||||
// create a value marker to display the actual y-values
|
||||
$Marker =& $Graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
|
||||
// and make the line plot use this
|
||||
$Plot2->setMarker($Marker);
|
||||
// make the marker print using font-size 7
|
||||
$Marker->setFontSize(7);
|
||||
// ... in blue
|
||||
$Marker->setFontColor('blue');
|
||||
|
||||
// get the y-axis
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
// and create a datapreprocessor to make the labels print out as percentage valuexs
|
||||
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.0f%%'));
|
||||
// force a maximum on the y-axis to 105
|
||||
$AxisY->forceMaximum(105);
|
||||
// set the axis title and make it display vertically ('vertical' = down->up)
|
||||
$AxisY->setTitle('Popularity', 'vertical');
|
||||
|
||||
// get the secondary y-axis
|
||||
$AxisYsec =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
// set the axis title and make it display vertically ('vertical2' = up->down)
|
||||
$AxisYsec->setTitle('Defects / 1000 units', 'vertical2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
|
||||
?>
|
82
includes/pear/Image/docs/examples/multiple_plots.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate multiple plots
|
||||
*
|
||||
* Other:
|
||||
* Title alignments, Multi-line axis labels, Markers
|
||||
*
|
||||
* $Id: multiple_plots.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::vertical(
|
||||
$Title = Image_Graph::factory('title', array('Multiple Plots', 11)),
|
||||
$SubTitle = Image_Graph::factory('title', array('This is a demonstration of title alignment', 7)),
|
||||
90
|
||||
),
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
8
|
||||
)
|
||||
);
|
||||
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
|
||||
$SubTitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
|
||||
|
||||
$Grid =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')));
|
||||
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Area', Image_Graph::factory('random', array(10, 20, 100, true)));
|
||||
$Plot->setFillColor('red@0.2');
|
||||
|
||||
$Plot =& $Plotarea->addNew('line', Image_Graph::factory('random', array(10, 20, 100, true)));
|
||||
$Plot->setLineColor('blue@0.2');
|
||||
$CircleMarker =& Image_Graph::factory('Image_Graph_Marker_Circle');
|
||||
$Plot->setMarker($CircleMarker);
|
||||
$CircleMarker->setFillColor('white@0.4');
|
||||
|
||||
$Plot =& $Plotarea->addNew('bar', Image_Graph::factory('random', array(10, 2, 40, true)));
|
||||
$Plot->setFillColor('green@0.2');
|
||||
$Marker =& Image_Graph::factory('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
$Plot->setMarker($Marker);
|
||||
$Marker->setFillColor('white');
|
||||
$Marker->setBorderColor('black');
|
||||
|
||||
$AxisY = $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->showArrow();
|
||||
|
||||
$Array = array(
|
||||
"Jan-Feb\n2004",
|
||||
"Mar-Apr\n2004",
|
||||
"May-Jun\n2004",
|
||||
"Jul-Aug\n2004",
|
||||
"Sep-Oct\n2004",
|
||||
"Nov-Dev\n2004",
|
||||
"Jan-Feb\n2005",
|
||||
"Mar-Apr\n2005",
|
||||
"May-Jun\n2005",
|
||||
"Jul-Aug\n2005"
|
||||
);
|
||||
$AxisX = $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Array', array($Array)));
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
72
includes/pear/Image/docs/examples/negative_values.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Negative values
|
||||
* (more a test really)
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: negative_values.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 400, 'height' => 300, 'antialias' => true));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint('Jan', 1);
|
||||
$Dataset->addPoint('Feb', 2);
|
||||
$Dataset->addPoint('Mar', -2);
|
||||
$Dataset->addPoint('Apr', 4);
|
||||
$Dataset->addPoint('May', 3);
|
||||
$Dataset->addPoint('Jun', 6);
|
||||
$Dataset->addPoint('Jul', -1);
|
||||
$Dataset->addPoint('Aug', -3);
|
||||
$Dataset->addPoint('Sep', 2);
|
||||
$Dataset->addPoint('Oct', 3);
|
||||
$Dataset->addPoint('Nov', 1);
|
||||
$Dataset->addPoint('Dec', 4);
|
||||
|
||||
$Dataset2 =& Image_Graph::factory('dataset');
|
||||
$Dataset2->addPoint('Jan', 3);
|
||||
$Dataset2->addPoint('Feb', 4);
|
||||
$Dataset2->addPoint('Mar', 1);
|
||||
$Dataset2->addPoint('Apr', -2);
|
||||
$Dataset2->addPoint('May', 3);
|
||||
$Dataset2->addPoint('Jul', 1);
|
||||
|
||||
$Plot =& $Plotarea->addNew('area', array(&$Dataset));
|
||||
$Plot->setFillColor('red@0.2');
|
||||
|
||||
$Plot2 =& $Plotarea->addNew('bar', array(&$Dataset2));
|
||||
$Plot2->setFillColor('blue@0.2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
BIN
includes/pear/Image/docs/examples/pear-icon.png
Normal file
After Width: | Height: | Size: 927 B |
231
includes/pear/Image/docs/examples/plot_all.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show all plot types
|
||||
*
|
||||
* Other:
|
||||
* Matrix layout, Axis customization
|
||||
*
|
||||
* $Id: plot_all.php,v 1.3 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
$Graph =& Image_Graph::factory('graph', array(800, 800));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Arial');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(6);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Matrix =& $Graph->addNew('Image_Graph_Layout_Matrix', array(5, 4));
|
||||
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Dataset2 =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Dataset3 =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 0);
|
||||
$Plot =& $Plotarea->addNew('line', array(&$Dataset));
|
||||
$Plot->setLineColor('red');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Line', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 1);
|
||||
$Plot =& $Plotarea->addNew('area', array(&$Dataset));
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Area', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 2);
|
||||
$Plot =& $Plotarea->addNew('bar', array(&$Dataset));
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('green@0.2');
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 3);
|
||||
$Plot =& $Plotarea->addNew('smooth_line', array(&$Dataset));
|
||||
$Plot->setLineColor('orange');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Line', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 0);
|
||||
$Plot =& $Plotarea->addNew('smooth_area', array(&$Dataset));
|
||||
$Plot->setLineColor('purple@0.4');
|
||||
$Plot->setFillColor('purple@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Area', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 1);
|
||||
$Plot =& $Plotarea->addNew('pie', array(&$Dataset));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.2');
|
||||
$Fill->addColor('blue@0.2');
|
||||
$Fill->addColor('green@0.2');
|
||||
$Fill->addColor('yellow@0.2');
|
||||
$Fill->addColor('orange@0.2');
|
||||
$Fill->addColor('purple@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plotarea->hideAxis();
|
||||
$Plot->explode(10, 1);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Pie', array('size' => 7)));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 2);
|
||||
$Plot =& $Plotarea->addNew('step', array(&$Dataset));
|
||||
$Plot->setLineColor('yellow@0.5');
|
||||
$Plot->setFillColor('yellow@0.3');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Step', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 3);
|
||||
$Plot =& $Plotarea->addNew('impulse', array(&$Dataset));
|
||||
$Plot->setLineColor('blue');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Impulse', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(2, 0);
|
||||
$Plot =& $Plotarea->addNew('scatter', array(&$Dataset));
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Circle');
|
||||
$Marker->setSize(4);
|
||||
$Marker->setLineColor('green@0.4');
|
||||
$Marker->setFillColor('green@0.2');
|
||||
$Plot->setMarker($Marker);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Dot', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Graph->addNew('Image_Graph_Plotarea_Radar');
|
||||
$Matrix->setEntry(2, 1, $Plotarea);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Radar', array(&$Dataset));
|
||||
$Plot->setLineColor('orange@0.4');
|
||||
$Plot->setFillColor('orange@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Radar', array('size' => 7)));
|
||||
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
$base = mktime(0, 0, 0, 11, 1, 2004);
|
||||
$open = rand(20, 100);
|
||||
//for ($i = 0; $i < 61; $i++) {
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$span = rand(-25, 25);
|
||||
$close = ($open + $span < 0 ? $open - $span : $open + $span);
|
||||
$min = max(1, min($close, $open) - rand(1, 20));
|
||||
$max = max($close, $open) + rand(1, 20);
|
||||
$date = $base + $i * 86400;
|
||||
$Dataset1->addPoint(date('d-M', $date), array('min' => $min, 'open' => $open, 'close' => $close, 'max' => $max));
|
||||
$open = $close;
|
||||
}
|
||||
$Plotarea =& $Matrix->getEntry(2, 2);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_CandleStick', array(&$Dataset1));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.4', 'red');
|
||||
$Fill->addColor('green@0.4', 'green');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Axis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$Axis->setLabelInterval(3);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_CandleStick', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(2, 3);
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 40; $i++) {
|
||||
$v1 = rand(5, 15);
|
||||
$v2 = $v1 + rand(10, 20);
|
||||
$Dataset1->addPoint($i, array('low' => $v1, 'high' => $v2));
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Band', array($Dataset1));
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('teal@0.2');
|
||||
$Axis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$Axis->setLabelInterval(5);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Band', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(3, 0);
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$data = array();
|
||||
$min = rand(1, 10);
|
||||
$max = rand(15, 30);
|
||||
for ($j = 0; $j < 20; $j++) {
|
||||
$data[] = rand($min, $max);
|
||||
}
|
||||
$Dataset1->addPoint($i, $data);
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_BoxWhisker', array($Dataset1));
|
||||
$Plot->setWhiskerSize(3);
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red', 'min');
|
||||
$Fill->addColor('green', 'max');
|
||||
$Fill->addColor('orange@0.2', 'quartile1');
|
||||
$Fill->addColor('blue@0.2', 'median');
|
||||
$Fill->addColor('orange@0.2', 'quartile3');
|
||||
$Fill->addColor('yellow@0.1', 'box');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Line =& Image_Graph::factory('Image_Graph_Line_Solid', 'black@0.6');
|
||||
$Line->setThickness(1);
|
||||
$Plot->setLineStyle($Line);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_BoxWhisker', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Graph->addNew('Image_Graph_Plotarea_Radar');
|
||||
$Matrix->setEntry(3, 1, $Plotarea);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Radar', array(&$Dataset));
|
||||
$Plot->setLineColor('red@0.4');
|
||||
$Plot->setFillColor('red@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Radar', array('size' => 7)));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 0);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Bar', array(array(&$Dataset, &$Dataset2)));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.2');
|
||||
$Fill->addColor('blue@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(2, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar (normal)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 1);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Area', array(array(&$Dataset, &$Dataset2, &$Dataset3), 'stacked'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('khaki@0.2');
|
||||
$Fill->addColor('indianred@0.2');
|
||||
$Fill->addColor('gold@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Area (stacked)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 2);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Bar', array(array(&$Dataset, &$Dataset2), 'stacked'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('maroon@0.5');
|
||||
$Fill->addColor('peru@0.5');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar (stacked)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 3);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Step', array(array(&$Dataset, &$Dataset2, &$Dataset3), 'stacked100pct'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('orange@0.2');
|
||||
$Fill->addColor('yellow@0.2');
|
||||
$Fill->addColor('lightgrey@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plotarea->setAxisPadding(-1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Step (stacked 100%)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Graph->done();
|
||||
?>
|
247
includes/pear/Image/docs/examples/plot_all_horizontal.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show all plot types (horizontal)
|
||||
*
|
||||
* Other:
|
||||
* Matrix layout, Axis customization
|
||||
*
|
||||
* $Id: plot_all_horizontal.php,v 1.2 2005/09/08 19:02:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
$Graph =& Image_Graph::factory('graph', array(800, 800));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Arial');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(6);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Matrix =& $Graph->addNew('Image_Graph_Layout_Matrix', array(5, 4, false));
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
for ($j = 0; $j < 4; $j++) {
|
||||
$Matrix->setEntry(
|
||||
$i, $j,
|
||||
Image_Graph::factory(
|
||||
'plotarea',
|
||||
array(
|
||||
'Image_Graph_Axis_Category',
|
||||
'Image_Graph_Axis',
|
||||
'horizontal'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Dataset2 =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Dataset3 =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 0);
|
||||
$Plot =& $Plotarea->addNew('line', array(&$Dataset));
|
||||
$Plot->setLineColor('red');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Line', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 1);
|
||||
$Plot =& $Plotarea->addNew('area', array(&$Dataset));
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Area', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 2);
|
||||
$Plot =& $Plotarea->addNew('bar', array(&$Dataset));
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('green@0.2');
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 3);
|
||||
$Plot =& $Plotarea->addNew('smooth_line', array(&$Dataset));
|
||||
$Plot->setLineColor('orange');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Line', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 0);
|
||||
$Plot =& $Plotarea->addNew('smooth_area', array(&$Dataset));
|
||||
$Plot->setLineColor('purple@0.4');
|
||||
$Plot->setFillColor('purple@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Area', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 1);
|
||||
$Plot =& $Plotarea->addNew('pie', array(&$Dataset));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.2');
|
||||
$Fill->addColor('blue@0.2');
|
||||
$Fill->addColor('green@0.2');
|
||||
$Fill->addColor('yellow@0.2');
|
||||
$Fill->addColor('orange@0.2');
|
||||
$Fill->addColor('purple@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plotarea->hideAxis();
|
||||
$Plot->explode(10, 1);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Pie', array('size' => 7)));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 2);
|
||||
$Plot =& $Plotarea->addNew('step', array(&$Dataset));
|
||||
$Plot->setLineColor('yellow@0.5');
|
||||
$Plot->setFillColor('yellow@0.3');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Step', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 3);
|
||||
$Plot =& $Plotarea->addNew('impulse', array(&$Dataset));
|
||||
$Plot->setLineColor('blue');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Impulse', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(2, 0);
|
||||
$Plot =& $Plotarea->addNew('scatter', array(&$Dataset));
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Circle');
|
||||
$Marker->setSize(4);
|
||||
$Marker->setLineColor('green@0.4');
|
||||
$Marker->setFillColor('green@0.2');
|
||||
$Plot->setMarker($Marker);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Dot', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Graph->addNew('Image_Graph_Plotarea_Radar');
|
||||
$Matrix->setEntry(2, 1, $Plotarea);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Radar', array(&$Dataset));
|
||||
$Plot->setLineColor('orange@0.4');
|
||||
$Plot->setFillColor('orange@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Radar', array('size' => 7)));
|
||||
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
$base = mktime(0, 0, 0, 11, 1, 2004);
|
||||
$open = rand(20, 100);
|
||||
//for ($i = 0; $i < 61; $i++) {
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$span = rand(-25, 25);
|
||||
$close = ($open + $span < 0 ? $open - $span : $open + $span);
|
||||
$min = max(1, min($close, $open) - rand(1, 20));
|
||||
$max = max($close, $open) + rand(1, 20);
|
||||
$date = $base + $i * 86400;
|
||||
$Dataset1->addPoint(date('d-M', $date), array('min' => $min, 'open' => $open, 'close' => $close, 'max' => $max));
|
||||
$open = $close;
|
||||
}
|
||||
$Plotarea =& $Matrix->getEntry(2, 2);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_CandleStick', array(&$Dataset1));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.4', 'red');
|
||||
$Fill->addColor('green@0.4', 'green');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Axis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$Axis->setLabelInterval(3);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_CandleStick', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(2, 3);
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 40; $i++) {
|
||||
$v1 = rand(5, 15);
|
||||
$v2 = $v1 + rand(10, 20);
|
||||
$Dataset1->addPoint($i, array('low' => $v1, 'high' => $v2));
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Band', array($Dataset1));
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('teal@0.2');
|
||||
$Axis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$Axis->setLabelInterval(5);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Band', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(3, 0);
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$data = array();
|
||||
$min = rand(1, 10);
|
||||
$max = rand(15, 30);
|
||||
for ($j = 0; $j < 20; $j++) {
|
||||
$data[] = rand($min, $max);
|
||||
}
|
||||
$Dataset1->addPoint($i, $data);
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_BoxWhisker', array($Dataset1));
|
||||
$Plot->setWhiskerSize(3);
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red', 'min');
|
||||
$Fill->addColor('green', 'max');
|
||||
$Fill->addColor('orange@0.2', 'quartile1');
|
||||
$Fill->addColor('blue@0.2', 'median');
|
||||
$Fill->addColor('orange@0.2', 'quartile3');
|
||||
$Fill->addColor('yellow@0.1', 'box');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Line =& Image_Graph::factory('Image_Graph_Line_Solid', 'black@0.6');
|
||||
$Line->setThickness(1);
|
||||
$Plot->setLineStyle($Line);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_BoxWhisker', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Graph->addNew('Image_Graph_Plotarea_Radar');
|
||||
$Matrix->setEntry(3, 1, $Plotarea);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Radar', array(&$Dataset));
|
||||
$Plot->setLineColor('red@0.4');
|
||||
$Plot->setFillColor('red@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Radar', array('size' => 7)));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 0);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Bar', array(array(&$Dataset, &$Dataset2)));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.2');
|
||||
$Fill->addColor('blue@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(2, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar (normal)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 1);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Area', array(array(&$Dataset, &$Dataset2, &$Dataset3), 'stacked'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('khaki@0.2');
|
||||
$Fill->addColor('indianred@0.2');
|
||||
$Fill->addColor('gold@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Area (stacked)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 2);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Bar', array(array(&$Dataset, &$Dataset2), 'stacked'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('maroon@0.5');
|
||||
$Fill->addColor('peru@0.5');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar (stacked)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 3);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Step', array(array(&$Dataset, &$Dataset2, &$Dataset3), 'stacked100pct'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('orange@0.2');
|
||||
$Fill->addColor('yellow@0.2');
|
||||
$Fill->addColor('lightgrey@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plotarea->setAxisPadding(-1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Step (stacked 100%)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Graph->done();
|
||||
?>
|
250
includes/pear/Image/docs/examples/plot_all_horizontal_invert.php
Normal file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show all plot types (horizontal, axis inverted)
|
||||
*
|
||||
* Other:
|
||||
* Matrix layout, Axis customization
|
||||
*
|
||||
* $Id: plot_all_horizontal_invert.php,v 1.1 2005/09/08 19:02:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
$Graph =& Image_Graph::factory('graph', array(800, 800));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Arial');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(6);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Matrix =& $Graph->addNew('Image_Graph_Layout_Matrix', array(5, 4, false));
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
for ($j = 0; $j < 4; $j++) {
|
||||
$Plotarea =& Image_Graph::factory(
|
||||
'plotarea',
|
||||
array(
|
||||
'Image_Graph_Axis_Category',
|
||||
'Image_Graph_Axis',
|
||||
'horizontal'
|
||||
)
|
||||
);
|
||||
$AxisX =& $Plotarea->getAxis('x');
|
||||
$AxisX->setInverted(true);
|
||||
$AxisY =& $Plotarea->getAxis('y');
|
||||
$AxisY->setInverted(true);
|
||||
|
||||
$Matrix->setEntry($i, $j, $Plotarea);
|
||||
}
|
||||
}
|
||||
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Dataset2 =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Dataset3 =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 0);
|
||||
$Plot =& $Plotarea->addNew('line', array(&$Dataset));
|
||||
$Plot->setLineColor('red');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Line', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 1);
|
||||
$Plot =& $Plotarea->addNew('area', array(&$Dataset));
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Area', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 2);
|
||||
$Plot =& $Plotarea->addNew('bar', array(&$Dataset));
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('green@0.2');
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(0, 3);
|
||||
$Plot =& $Plotarea->addNew('smooth_line', array(&$Dataset));
|
||||
$Plot->setLineColor('orange');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Line', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 0);
|
||||
$Plot =& $Plotarea->addNew('smooth_area', array(&$Dataset));
|
||||
$Plot->setLineColor('purple@0.4');
|
||||
$Plot->setFillColor('purple@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Area', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 1);
|
||||
$Plot =& $Plotarea->addNew('pie', array(&$Dataset));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.2');
|
||||
$Fill->addColor('blue@0.2');
|
||||
$Fill->addColor('green@0.2');
|
||||
$Fill->addColor('yellow@0.2');
|
||||
$Fill->addColor('orange@0.2');
|
||||
$Fill->addColor('purple@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setLineColor('gray');
|
||||
$Plotarea->hideAxis();
|
||||
$Plot->explode(10, 1);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Pie', array('size' => 7)));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 2);
|
||||
$Plot =& $Plotarea->addNew('step', array(&$Dataset));
|
||||
$Plot->setLineColor('yellow@0.5');
|
||||
$Plot->setFillColor('yellow@0.3');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Step', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(1, 3);
|
||||
$Plot =& $Plotarea->addNew('impulse', array(&$Dataset));
|
||||
$Plot->setLineColor('blue');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Impulse', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(2, 0);
|
||||
$Plot =& $Plotarea->addNew('scatter', array(&$Dataset));
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Circle');
|
||||
$Marker->setSize(4);
|
||||
$Marker->setLineColor('green@0.4');
|
||||
$Marker->setFillColor('green@0.2');
|
||||
$Plot->setMarker($Marker);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Dot', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Graph->addNew('Image_Graph_Plotarea_Radar');
|
||||
$Matrix->setEntry(2, 1, $Plotarea);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Radar', array(&$Dataset));
|
||||
$Plot->setLineColor('orange@0.4');
|
||||
$Plot->setFillColor('orange@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Radar', array('size' => 7)));
|
||||
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
$base = mktime(0, 0, 0, 11, 1, 2004);
|
||||
$open = rand(20, 100);
|
||||
//for ($i = 0; $i < 61; $i++) {
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$span = rand(-25, 25);
|
||||
$close = ($open + $span < 0 ? $open - $span : $open + $span);
|
||||
$min = max(1, min($close, $open) - rand(1, 20));
|
||||
$max = max($close, $open) + rand(1, 20);
|
||||
$date = $base + $i * 86400;
|
||||
$Dataset1->addPoint(date('d-M', $date), array('min' => $min, 'open' => $open, 'close' => $close, 'max' => $max));
|
||||
$open = $close;
|
||||
}
|
||||
$Plotarea =& $Matrix->getEntry(2, 2);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_CandleStick', array(&$Dataset1));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.4', 'red');
|
||||
$Fill->addColor('green@0.4', 'green');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Axis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$Axis->setLabelInterval(3);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_CandleStick', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(2, 3);
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 40; $i++) {
|
||||
$v1 = rand(5, 15);
|
||||
$v2 = $v1 + rand(10, 20);
|
||||
$Dataset1->addPoint($i, array('low' => $v1, 'high' => $v2));
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Band', array($Dataset1));
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('teal@0.2');
|
||||
$Axis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$Axis->setLabelInterval(5);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Band', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(3, 0);
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$data = array();
|
||||
$min = rand(1, 10);
|
||||
$max = rand(15, 30);
|
||||
for ($j = 0; $j < 20; $j++) {
|
||||
$data[] = rand($min, $max);
|
||||
}
|
||||
$Dataset1->addPoint($i, $data);
|
||||
}
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_BoxWhisker', array($Dataset1));
|
||||
$Plot->setWhiskerSize(3);
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red', 'min');
|
||||
$Fill->addColor('green', 'max');
|
||||
$Fill->addColor('orange@0.2', 'quartile1');
|
||||
$Fill->addColor('blue@0.2', 'median');
|
||||
$Fill->addColor('orange@0.2', 'quartile3');
|
||||
$Fill->addColor('yellow@0.1', 'box');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Line =& Image_Graph::factory('Image_Graph_Line_Solid', 'black@0.6');
|
||||
$Line->setThickness(1);
|
||||
$Plot->setLineStyle($Line);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_BoxWhisker', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Graph->addNew('Image_Graph_Plotarea_Radar');
|
||||
$Matrix->setEntry(3, 1, $Plotarea);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Radar', array(&$Dataset));
|
||||
$Plot->setLineColor('red@0.4');
|
||||
$Plot->setFillColor('red@0.2');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Smoothed_Radar', array('size' => 7)));
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 0);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Bar', array(array(&$Dataset, &$Dataset2)));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.2');
|
||||
$Fill->addColor('blue@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(2, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar (normal)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 1);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Area', array(array(&$Dataset, &$Dataset2, &$Dataset3), 'stacked'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('khaki@0.2');
|
||||
$Fill->addColor('indianred@0.2');
|
||||
$Fill->addColor('gold@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Area (stacked)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 2);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Bar', array(array(&$Dataset, &$Dataset2), 'stacked'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('maroon@0.5');
|
||||
$Fill->addColor('peru@0.5');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setSpacing(2);
|
||||
$Plotarea->setAxisPadding(1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Bar (stacked)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Plotarea =& $Matrix->getEntry(4, 3);
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Step', array(array(&$Dataset, &$Dataset2, &$Dataset3), 'stacked100pct'));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('orange@0.2');
|
||||
$Fill->addColor('yellow@0.2');
|
||||
$Fill->addColor('lightgrey@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plotarea->setAxisPadding(-1, 'left');
|
||||
$Plotarea->addNew('title', array('Image_Graph_Plot_Step (stacked 100%)', array('size' => 7)));
|
||||
$Plotarea->setAxisPadding(10, 'top');
|
||||
|
||||
$Graph->done();
|
||||
?>
|
57
includes/pear/Image/docs/examples/plot_area.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show area chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_area.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Simple Area Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
|
||||
$Plot =& $Plotarea->addNew('area', array(&$Dataset));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
55
includes/pear/Image/docs/examples/plot_area_smooth.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show smoothed area chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_area_smooth.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Smoothed Area Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Area', array(&$Dataset));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
64
includes/pear/Image/docs/examples/plot_area_stack.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show stacked area chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_area_stack.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Stacked Area Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Datasets =
|
||||
array(
|
||||
Image_Graph::factory('random', array(10, 2, 15, true)),
|
||||
Image_Graph::factory('random', array(10, 2, 15, true)),
|
||||
Image_Graph::factory('random', array(10, 2, 15, true))
|
||||
);
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Area', array($Datasets, 'stacked'));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
62
includes/pear/Image/docs/examples/plot_band.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show band chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_band.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Band Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 40; $i++) {
|
||||
$v1 = rand(5, 15);
|
||||
$v2 = $v1 + rand(10, 20);
|
||||
$Dataset->addPoint($i, array('low' => $v1, 'high' => $v2));
|
||||
}
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Band', $Dataset);
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
$Axis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$Axis->setLabelInterval(5);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
55
includes/pear/Image/docs/examples/plot_bar.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show bar chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_bar.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Bar Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('bar', array(&$Dataset));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
80
includes/pear/Image/docs/examples/plot_bar_horizontal.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Vertical and Horizontal Plots
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_bar_horizontal.php,v 1.1 2005/09/08 19:02:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Vertical and Horizontal Bar Chart', 12)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea1 = Image_Graph::factory('plotarea'),
|
||||
$Plotarea2 = Image_Graph::factory('plotarea', array('category', 'axis', 'horizontal')),
|
||||
50
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Dataset[0] =& Image_Graph::factory('dataset');
|
||||
$Dataset[1] =& Image_Graph::factory('dataset');
|
||||
$Dataset[2] =& Image_Graph::factory('dataset');
|
||||
|
||||
$Dataset[0]->addPoint('A', 1);
|
||||
$Dataset[0]->addPoint('B', 4);
|
||||
$Dataset[0]->addPoint('C', -1);
|
||||
$Dataset[0]->addPoint('D', 2);
|
||||
$Dataset[0]->addPoint('E', 1);
|
||||
$Dataset[0]->addPoint('F', 2);
|
||||
$Dataset[0]->addPoint('G', 3);
|
||||
|
||||
$Dataset[1]->addPoint('A', 2);
|
||||
$Dataset[1]->addPoint('B', -3);
|
||||
$Dataset[1]->addPoint('C', -2);
|
||||
$Dataset[1]->addPoint('D', 3);
|
||||
$Dataset[1]->addPoint('E', 3);
|
||||
$Dataset[1]->addPoint('F', 2);
|
||||
$Dataset[1]->addPoint('G', -1);
|
||||
|
||||
$Dataset[2]->addPoint('A', -1);
|
||||
$Dataset[2]->addPoint('B', 2);
|
||||
$Dataset[2]->addPoint('C', 1);
|
||||
$Dataset[2]->addPoint('D', 3);
|
||||
$Dataset[2]->addPoint('E', -1);
|
||||
$Dataset[2]->addPoint('F', 2);
|
||||
$Dataset[2]->addPoint('G', 3);
|
||||
|
||||
$Plot1 =& $Plotarea1->addNew('bar', array(&$Dataset, 'stacked'));
|
||||
$Plot2 =& $Plotarea2->addNew('bar', array(&$Dataset, 'stacked'));
|
||||
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
$Plot1->setFillStyle($FillArray);
|
||||
$Plot2->setFillStyle($FillArray);
|
||||
|
||||
$Graph->done();
|
||||
?>
|
72
includes/pear/Image/docs/examples/plot_bar_multiple.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show bar chart with multiple datasets, side-by-side
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_bar_multiple.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Multiple Bar Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Datasets =
|
||||
array(
|
||||
Image_Graph::factory('random', array(5, 2, 15, false)),
|
||||
Image_Graph::factory('random', array(5, 2, 15, false)),
|
||||
Image_Graph::factory('random', array(5, 2, 15, false))
|
||||
);
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('bar', array($Datasets));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
// create a pin-point marker type
|
||||
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
|
||||
// and use the marker on the 1st plot
|
||||
$Plot->setMarker($PointingMarker);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
73
includes/pear/Image/docs/examples/plot_bar_stacked.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show stacked bar chart
|
||||
*
|
||||
* Other:
|
||||
* Data selector
|
||||
* Fill style array (no ID) working in sync with legend
|
||||
*
|
||||
* $Id: plot_bar_stacked.php,v 1.4 2005/08/24 16:02:48 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Stacked Bar Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
|
||||
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('bar', array($Datasets, 'stacked'));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// create a fill array
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
// and use the marker on the 1st plot
|
||||
$Plot->setMarker($Marker);
|
||||
|
||||
$Plot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
83
includes/pear/Image/docs/examples/plot_bar_stacked100pct.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show stacked bar chart 100%
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_bar_stacked100pct.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
include_once('Image/Graph.php');
|
||||
include_once('Image/Graph/Marker/Value.php');
|
||||
|
||||
class myValueMarker extends Image_Graph_Marker_Value {
|
||||
|
||||
function getDisplayValue($Values) {
|
||||
return "\{$Values[Y]}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Stacked Bar 100% Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
for ($j = 0; $j<4; $j++) {
|
||||
$DX =& Image_Graph::factory('dataset');
|
||||
$Datasets[$j] =& $DX;
|
||||
for ($i = 0; $i<10; $i++)
|
||||
$DX->addPoint($i, rand(2, 15), $j);
|
||||
}
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('bar', array($Datasets, 'stacked100pct'));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// create a fill array
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
$FillArray->addColor('red@0.2');
|
||||
$FillArray->addColor('gray@0.2');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->add(new myValueMarker(IMAGE_GRAPH_VALUE_Y));
|
||||
// and use the marker on the 1st plot
|
||||
$Plot->setMarker($Marker);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show stacked bar chart
|
||||
*
|
||||
* Other:
|
||||
* Data selector
|
||||
* Fill style array (no ID) working in sync with legend
|
||||
*
|
||||
* $Id: plot_bar_stacked_horizontal.php,v 1.1 2005/09/08 19:02:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Stacked Bar Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea',
|
||||
array(
|
||||
'category',
|
||||
'axis',
|
||||
'horizontal'
|
||||
)
|
||||
),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
|
||||
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('bar', array($Datasets, 'stacked'));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// create a fill array
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
// and use the marker on the 1st plot
|
||||
$Plot->setMarker($Marker);
|
||||
|
||||
$Plot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Stacked bar charts with negative values
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_bar_stacked_negative.php,v 1.3 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Negative Stacked Bar Chart', 10)),
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Dataset[0] =& Image_Graph::factory('dataset');
|
||||
$Dataset[1] =& Image_Graph::factory('dataset');
|
||||
$Dataset[2] =& Image_Graph::factory('dataset');
|
||||
|
||||
$Dataset[0]->addPoint('A', 1);
|
||||
$Dataset[0]->addPoint('B', 4);
|
||||
$Dataset[0]->addPoint('C', -1);
|
||||
$Dataset[0]->addPoint('D', 2);
|
||||
$Dataset[0]->addPoint('E', 1);
|
||||
$Dataset[0]->addPoint('F', 2);
|
||||
$Dataset[0]->addPoint('G', 3);
|
||||
|
||||
$Dataset[1]->addPoint('A', 2);
|
||||
$Dataset[1]->addPoint('B', -3);
|
||||
$Dataset[1]->addPoint('C', -2);
|
||||
$Dataset[1]->addPoint('D', 3);
|
||||
$Dataset[1]->addPoint('E', 3);
|
||||
$Dataset[1]->addPoint('F', 2);
|
||||
$Dataset[1]->addPoint('G', -1);
|
||||
|
||||
$Dataset[2]->addPoint('A', -1);
|
||||
$Dataset[2]->addPoint('B', 2);
|
||||
$Dataset[2]->addPoint('C', 1);
|
||||
$Dataset[2]->addPoint('D', 3);
|
||||
$Dataset[2]->addPoint('E', -1);
|
||||
$Dataset[2]->addPoint('F', 2);
|
||||
$Dataset[2]->addPoint('G', 3);
|
||||
|
||||
$Plot =& $Plotarea->addNew('bar', array(&$Dataset, 'stacked'));
|
||||
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('green@0.2');
|
||||
$Plot->setFillStyle($FillArray);
|
||||
|
||||
$Graph->done();
|
||||
?>
|
64
includes/pear/Image/docs/examples/plot_boxwhisker.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show box & whisker chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_boxwhisker.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Box & Whisker Chart', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
$Plotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint('Security', array(10, 21, 12, 18, 12, 17, 14, 13));
|
||||
$Dataset->addPoint('Internal', array(3, 6, 1, 9, 12, 4, 3, 5, 6));
|
||||
$Dataset->addPoint('External', array(9, 10, 12, 15, 13, 12, 11, 17));
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_BoxWhisker', array(&$Dataset));
|
||||
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red', 'min');
|
||||
$Fill->addColor('green', 'max');
|
||||
$Fill->addColor('orange@0.2', 'quartile1');
|
||||
$Fill->addColor('blue@0.2', 'median');
|
||||
$Fill->addColor('orange@0.2', 'quartile3');
|
||||
$Fill->addColor('yellow@0.1', 'box');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Line =& Image_Graph::factory('Image_Graph_Line_Solid', 'black@0.6');
|
||||
$Line->setThickness(1);
|
||||
$Plot->setLineStyle($Line);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
84
includes/pear/Image/docs/examples/plot_candlestick.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show candlestick chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_candlestick.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
|
||||
// create the plotareas
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Candlestick Diagram', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
|
||||
$base = mktime(0, 0, 0, 11, 1, 2004);
|
||||
$open = rand(20, 100);
|
||||
//for ($i = 0; $i < 61; $i++) {
|
||||
for ($i = 0; $i < 60; $i++) {
|
||||
$span = rand(-25, 25);
|
||||
$close = ($open + $span < 0 ? $open - $span : $open + $span);
|
||||
$min = max(1, min($close, $open) - rand(1, 20));
|
||||
$max = max($close, $open) + rand(1, 20);
|
||||
$date = $base + $i * 86400;
|
||||
$Dataset->addPoint(date('d-M-y', $date), array('min' => $min, 'open' => $open, 'close' => $close, 'max' => $max));
|
||||
$open = $close;
|
||||
}
|
||||
|
||||
$Grid =& $Plotarea->addNew('line_grid', null, IMAGE_GRAPH_AXIS_X);
|
||||
$Grid->setLineColor('lightgray@0.1');
|
||||
$Grid =& $Plotarea->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$Grid->setLineColor('lightgray@0.1');
|
||||
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_CandleStick', array(&$Dataset));
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.4', 'red');
|
||||
$Fill->addColor('green@0.4', 'green');
|
||||
$Plot->setFillStyle($Fill);
|
||||
$Plot->setTitle('Image_Graph Daily');
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setFontAngle('vertical');
|
||||
$AxisX->setLabelInterval(5);
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setLabelInterval(20);
|
||||
$AxisY->setTitle('Stock Price', array('size' => 10, 'angle' => 90));
|
||||
|
||||
$Legend->setFontSize(10);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
51
includes/pear/Image/docs/examples/plot_impulse.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show impulse chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_impulse.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Impulse Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Plot_Impulse', array(&$Dataset));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('red');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
66
includes/pear/Image/docs/examples/plot_impulse_stacked.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show stacked impulse chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_impulse_stacked.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Stacked Impulse Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
$Datasets[] =& Image_Graph::factory('random', array(10, 2, 15, false));
|
||||
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('impulse', array($Datasets, 'stacked'));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// create a line array
|
||||
$LineArray =& Image_Graph::factory('Image_Graph_Line_Array');
|
||||
$LineArray->addColor('blue');
|
||||
$LineArray->addColor('orange');
|
||||
$LineArray->addColor('green');
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setLineStyle($LineArray);
|
||||
|
||||
$Plotarea->setFillColor('gray@0.2');
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
55
includes/pear/Image/docs/examples/plot_line.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show line chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_line.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(10);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// setup the plotarea, legend and their layout
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Simple Line Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
88
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
// link the legend with the plotares
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create a random dataset for sake of simplicity
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
// create the plot as line chart using the dataset
|
||||
$Plot =& $Plotarea->addNew('line', array(&$Dataset));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('red');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
51
includes/pear/Image/docs/examples/plot_line_smooth.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show smoothed line chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_line_smooth.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Smoothed Line Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Line', array(&$Dataset));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('red');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
75
includes/pear/Image/docs/examples/plot_map.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show map chart
|
||||
* (for copyright reasons the map is unfortunately not available in package)
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_map.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(600, 400));
|
||||
|
||||
// create the plotareas
|
||||
$Plotarea =& $Graph->addNew('Image_Graph_Plotarea_Map', 'europe');
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint('Denmark', 10);
|
||||
$Dataset->addPoint('Sweden', 5);
|
||||
$Dataset->addPoint('Iceland', 7);
|
||||
$Dataset->addPoint('Portugal', 2);
|
||||
$Dataset->addPoint('Sicily', 5);
|
||||
|
||||
$Dataset2 =& Image_Graph::factory('dataset');
|
||||
$Dataset2->addPoint('Finland', 0);
|
||||
$Dataset2->addPoint('Ukraine', 0);
|
||||
$Dataset2->addPoint('Cyprus', 0);
|
||||
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Dot', array(&$Dataset));
|
||||
$Marker =& $Plot->setMarker(Image_Graph::factory('Image_Graph_Marker_Bubble'));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// set a standard fill style
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Marker->setFillStyle($FillArray);
|
||||
$FillArray->addColor('green@0.2');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('red@0.2');
|
||||
$FillArray->addColor('orange@0.2');
|
||||
|
||||
$Plot2 =& $Plotarea->addNew('line', array(&$Dataset2));
|
||||
$Plot2->setLineColor('red');
|
||||
$Marker2 =& $Plot2->setMarker(Image_Graph::factory('Image_Graph_Marker_Circle'));
|
||||
$Marker2->setLineColor('blue');
|
||||
$Marker2->setFillColor('white');
|
||||
$Marker2->Size = 5;
|
||||
$ValueMarker =& Image_Graph::factory('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_X);
|
||||
$Marker2->setSecondaryMarker(Image_Graph::factory('Image_Graph_Marker_Pointing_Angular', array(40, &$ValueMarker)));
|
||||
|
||||
$ValueMarker->setFillColor('white');
|
||||
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
$Font->setSize(8);
|
||||
$Graph->setFont($Font);
|
||||
$Graph->addNew('title', array('Map Chart Sample', 12));
|
||||
|
||||
$Graph->setBorderColor('black');
|
||||
$Graph->showShadow();
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
121
includes/pear/Image/docs/examples/plot_odo.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate odo & donut plots
|
||||
*
|
||||
* Other:
|
||||
* Radial gradient fillings
|
||||
*
|
||||
* $Id: plot_odo.php,v 1.1 2005/08/30 21:25:24 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
// create the graph
|
||||
$driver=& Image_Canvas::factory('png',array('width'=>400,'height'=>300,'antialias' => 'native'));
|
||||
$Graph = & Image_Graph::factory('graph', $driver);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Odo Chart', 12)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
80
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
$Legend->setAlignment(IMAGE_GRAPH_ALIGN_HORIZONTAL);
|
||||
/***************************Arrows************************/
|
||||
$Arrows = & Image_Graph::factory('dataset');
|
||||
$Arrows->addPoint('ok', 200, 'OK');
|
||||
$Arrows->addPoint('std', 120, 'Std');
|
||||
$Arrows->addPoint('bad', 250, 'Bad');
|
||||
|
||||
|
||||
/**************************PARAMATERS for PLOT*******************/
|
||||
|
||||
// create the plot as odo chart using the dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Odo',$Arrows);
|
||||
$Plot->setRange(100, 300);
|
||||
$Plot->setAngles(135, 270);
|
||||
$Plot->setRadiusWidth(75);
|
||||
$Plot->setLineColor('gray');//for range and outline
|
||||
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
$Plot->setArrowMarker($Marker);
|
||||
|
||||
$Plotarea->hideAxis();
|
||||
/***************************Axis************************/
|
||||
// create a Y data value marker
|
||||
|
||||
$Marker->setFillColor('transparent');
|
||||
$Marker->setBorderColor('transparent');
|
||||
$Marker->setFontSize(7);
|
||||
$Marker->setFontColor('black');
|
||||
|
||||
// create a pin-point marker type
|
||||
$Plot->setTickLength(14);
|
||||
$Plot->setAxisTicks(5);
|
||||
/********************************color of arrows*************/
|
||||
$FillArray = & Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillArray->addColor('blue@0.6', 'OK');
|
||||
$FillArray->addColor('orange@0.6', 'Std');
|
||||
$FillArray->addColor('green@0.6', 'Bad');
|
||||
|
||||
// create a line array
|
||||
$LineArray =& Image_Graph::factory('Image_Graph_Line_Array');
|
||||
$LineArray->addColor('blue', 'OK');
|
||||
$LineArray->addColor('orange', 'Std');
|
||||
$LineArray->addColor('green', 'Bad');
|
||||
$Plot->setArrowLineStyle($LineArray);
|
||||
$Plot->setArrowFillStyle($FillArray);
|
||||
|
||||
/***************************MARKER OR ARROW************************/
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
|
||||
$Marker->setFillColor('black');
|
||||
$Marker->setBorderColor('blue');
|
||||
$Marker->setFontSize(7);
|
||||
$Marker->setFontColor('white');
|
||||
// create a pin-point marker type
|
||||
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
|
||||
// and use the marker on the plot
|
||||
$Plot->setMarker($PointingMarker);
|
||||
/**************************RANGE*******************/
|
||||
// create the dataset
|
||||
/*$Range[] = & Image_Graph::factory('dataset',array(array(100,140)));
|
||||
$Range[] = & Image_Graph::factory('dataset',array(array(150,260)));
|
||||
$Range[] = & Image_Graph::factory('dataset',array(array(270,290)));*/
|
||||
//print_r($Range);die();
|
||||
$Plot->addRangeMarker(100, 140);
|
||||
$Plot->addRangeMarker(150, 260);
|
||||
$Plot->addRangeMarker(270, 290);
|
||||
// create a fillstyle for the ranges
|
||||
$FillRangeArray = & Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$FillRangeArray->addColor('green@0.7');
|
||||
$FillRangeArray->addColor('yellow@0.7');
|
||||
$FillRangeArray->addColor('blue@0.7');
|
||||
/* $FillRangeArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'));
|
||||
$FillRangeArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'));
|
||||
$FillRangeArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red')); */
|
||||
$Plot->setRangeMarkerFillStyle($FillRangeArray);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
58
includes/pear/Image/docs/examples/plot_pie.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show pie chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_pie.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
// create the plotareas
|
||||
$Plotarea =& $Graph->addNew('plotarea');
|
||||
|
||||
$Plotarea->hideAxis();
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 10, 20, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Pie', $Dataset);
|
||||
|
||||
$Plot->Radius = 2;
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// set a standard fill style
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot->setFillStyle($FillArray);
|
||||
$FillArray->addColor('green@0.2');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('red@0.2');
|
||||
$FillArray->addColor('orange@0.2');
|
||||
|
||||
// add a title using the created font
|
||||
$Graph->addNew('title', array('Pie Chart Sample', 11));
|
||||
|
||||
$Plot->explode(10);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
80
includes/pear/Image/docs/examples/plot_pie_rotate.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate radial gradient fillings
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_pie_rotate.php,v 1.1 2005/09/30 18:59:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 7 pixels
|
||||
$Font->setSize(7);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Meat Export', 12)),
|
||||
Image_Graph::horizontal(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
70
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the 1st dataset
|
||||
$Dataset1 =& Image_Graph::factory('dataset');
|
||||
$Dataset1->addPoint('Beef', rand(1, 10));
|
||||
$Dataset1->addPoint('Pork', rand(1, 10));
|
||||
$Dataset1->addPoint('Poultry', rand(1, 10));
|
||||
$Dataset1->addPoint('Camels', rand(1, 10));
|
||||
$Dataset1->addPoint('Other', rand(1, 10));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('pie', array(&$Dataset1));
|
||||
$Plotarea->hideAxis();
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL);
|
||||
// create a pin-point marker type
|
||||
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
|
||||
// and use the marker on the 1st plot
|
||||
$Plot->setMarker($PointingMarker);
|
||||
// format value marker labels as percentage values
|
||||
$Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
|
||||
|
||||
$Plot->Radius = 2;
|
||||
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot->setFillStyle($FillArray);
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'green'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'blue'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'yellow'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'red'));
|
||||
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'white', 'orange'));
|
||||
|
||||
$Plot->explode(5);
|
||||
|
||||
$Plot->setStartingAngle(90);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
82
includes/pear/Image/docs/examples/plot_radar.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show radar chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_radar.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png',
|
||||
array(
|
||||
'width' => 400,
|
||||
'height' => 300,
|
||||
'antialias' => 'native'
|
||||
)
|
||||
);
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Spider/Radar Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('Image_Graph_Plotarea_Radar'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
$Plotarea->addNew('Image_Graph_Grid_Polar', IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
// create the dataset
|
||||
$DS1 =& Image_Graph::factory('dataset');
|
||||
$DS1->addPoint('Life', rand(1, 6));
|
||||
$DS1->addPoint('Universe', rand(1, 6));
|
||||
$DS1->addPoint('Everything', rand(1, 6));
|
||||
$DS1->addPoint('Something', rand(1, 6));
|
||||
$DS1->addPoint('Nothing', rand(1, 6));
|
||||
$DS1->addPoint('Irrelevevant', rand(1, 6));
|
||||
|
||||
$DS2 =& Image_Graph::factory('dataset');
|
||||
$DS2->addPoint('Life', rand(1, 6));
|
||||
$DS2->addPoint('Universe', rand(1, 6));
|
||||
$DS2->addPoint('Everything', rand(1, 6));
|
||||
$DS2->addPoint('Something', rand(1, 6));
|
||||
$DS2->addPoint('Nothing', rand(1, 6));
|
||||
$DS2->addPoint('Irrelevevant', rand(1, 6));
|
||||
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Radar', $DS1);
|
||||
$Plot2 =& $Plotarea->addNew('Image_Graph_Plot_Radar', $DS2);
|
||||
|
||||
|
||||
// set a standard fill style
|
||||
$Plot->setLineColor('blue@0.4');
|
||||
$Plot->setFillColor('blue@0.2');
|
||||
|
||||
$Plot2->setLineColor('red@0.4');
|
||||
$Plot2->setFillColor('red@0.2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
78
includes/pear/Image/docs/examples/plot_radar_smooth.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show smoothed radar chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_radar_smooth.php,v 1.3 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Smoothed Radar Chart Sample', 11)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('Image_Graph_Plotarea_Radar'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
$Plotarea->addNew('Image_Graph_Grid_Polar', IMAGE_GRAPH_AXIS_Y);
|
||||
|
||||
// create the dataset
|
||||
$DS1 =& Image_Graph::factory('dataset');
|
||||
$DS2 =& Image_Graph::factory('dataset');
|
||||
for ($i = 0; $i < 360; $i += 10) {
|
||||
$DS1->addPoint($i, rand(3, 6));
|
||||
if ($i % 30 == 0) {
|
||||
$DS2->addPoint($i, rand(2, 4));
|
||||
}
|
||||
}
|
||||
|
||||
$Plot1 =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Radar', $DS1);
|
||||
$Plot2 =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Radar', $DS2);
|
||||
|
||||
// set a standard fill style
|
||||
$Plot1->setLineColor('blue@0.4');
|
||||
$Plot1->setFillColor('blue@0.2');
|
||||
// set a standard fill style
|
||||
$Plot2->setLineColor('green@0.4');
|
||||
$Plot2->setFillColor('green@0.2');
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setLabelInterval(3);
|
||||
$AxisX->setLineColor('lightgrey');
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setLineColor('lightgrey');
|
||||
|
||||
// create a Y data value marker
|
||||
$Marker =& $Plot2->addNew('Image_Graph_Marker_Circle');
|
||||
$Marker->setSize(5);
|
||||
$Marker->setFillColor('gray@0.2');
|
||||
$Plot2->setMarker($Marker);
|
||||
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
65
includes/pear/Image/docs/examples/plot_scatter.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show dot/scatter chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_scatter.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Dot Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset1 =& Image_Graph::factory('random', array(10, 2, 9, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot1 =& $Plotarea->addNew('Image_Graph_Plot_Dot', array(&$Dataset1));
|
||||
$Marker1 =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||
$Marker1->setFillColor('blue');
|
||||
$Marker1->setLineColor('black');
|
||||
// set a line color
|
||||
$Plot1->setMarker($Marker1);
|
||||
$Plot1->setTitle('Introvert');
|
||||
|
||||
// create the dataset
|
||||
$Dataset2 =& Image_Graph::factory('random', array(10, 10, 15, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot2 =& $Plotarea->addNew('Image_Graph_Plot_Dot', array(&$Dataset2));
|
||||
$Marker2 =& Image_Graph::factory('Image_Graph_Marker_Plus');
|
||||
$Marker2->setFillColor('green');
|
||||
$Marker2->setLineColor('black');
|
||||
// set a line color
|
||||
$Plot2->setMarker($Marker2);
|
||||
$Plot2->setTitle('Extrovert');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
60
includes/pear/Image/docs/examples/plot_scatter_linefit.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show dot/scatter chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_scatter_linefit.php,v 1.1 2005/09/14 20:27:25 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Dot Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset1 =& Image_Graph::factory('random', array(10, 10, 50, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot1 =& $Plotarea->addNew('Image_Graph_Plot_Dot', array(&$Dataset1));
|
||||
$Marker1 =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||
$Marker1->setFillColor('blue');
|
||||
$Marker1->setLineColor('black');
|
||||
// set a line color
|
||||
$Plot1->setMarker($Marker1);
|
||||
$Plot1->setTitle('Introvert');
|
||||
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot2 =& $Plotarea->addNew('Image_Graph_Plot_Fit_Line', array(&$Dataset1));
|
||||
// set a line color
|
||||
$Plot2->setLineColor('blue');
|
||||
$Plot2->setTitle('Extrovert');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
60
includes/pear/Image/docs/examples/plot_step.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show step chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: plot_step.php,v 1.3 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Step Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create the dataset
|
||||
$Dataset[] =& Image_Graph::factory('random', array(10, 2, 5, false));
|
||||
$Dataset[] =& Image_Graph::factory('random', array(10, 2, 5, false));
|
||||
$Dataset[] =& Image_Graph::factory('random', array(10, 2, 5, false));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Step', array($Dataset, 'stacked'));
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
$Fill =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Fill->addColor('red@0.2');
|
||||
$Fill->addColor('blue@0.2');
|
||||
$Fill->addColor('green@0.2');
|
||||
$Plot->setFillStyle($Fill);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
85
includes/pear/Image/docs/examples/secondary_axis.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate secondary y-axis usage
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: secondary_axis.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
require_once 'Image/Canvas.php';
|
||||
|
||||
$Canvas =& Image_Canvas::factory('png', array('width' => 400, 'height' => 300, 'antialias' => 'native'));
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', $Canvas);
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
// create the plotarea layout
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Primary & Secondary Axis', 11)),
|
||||
Image_Graph::vertical(
|
||||
$Plotarea = Image_Graph::factory('plotarea'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
|
||||
// make the legend use the plotarea (or implicitly it's plots)
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
// create a grid and assign it to the secondary Y axis
|
||||
$GridY2 =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$GridY2->setFillStyle(
|
||||
Image_Graph::factory(
|
||||
'gradient',
|
||||
array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')
|
||||
)
|
||||
);
|
||||
|
||||
// create a line plot using a random dataset
|
||||
$Dataset1 =& Image_Graph::factory('random', array(8, 10, 100, true));
|
||||
$Plot1 =& $Plotarea->addNew('line', array(&$Dataset1));
|
||||
$Plot1->setLineColor('red');
|
||||
|
||||
// create an area plot using a random dataset
|
||||
$Dataset2 =& Image_Graph::factory('random', array(8, 1, 10, true));
|
||||
$Plot2 =& $Plotarea->addNew(
|
||||
'Image_Graph_Plot_Area',
|
||||
$Dataset2,
|
||||
IMAGE_GRAPH_AXIS_Y_SECONDARY
|
||||
);
|
||||
|
||||
$Plot2->setLineColor('gray');
|
||||
$Plot2->setFillColor('blue@0.2');
|
||||
|
||||
// set the titles for the plots
|
||||
$Plot1->setTitle('Primary Axis');
|
||||
$Plot2->setTitle('Secondary Axis');
|
||||
|
||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||
$AxisX->setTitle('Oranges');
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setTitle('Apples', 'vertical');
|
||||
$AxisYsecondary =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
|
||||
$AxisYsecondary->setTitle('Pears', 'vertical2');
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
28
includes/pear/Image/docs/examples/simple.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Datapreprocessing usage and idea
|
||||
*
|
||||
* Other:
|
||||
* Matrix layout
|
||||
*
|
||||
* $Id: simple.php,v 1.1 2005/09/30 18:59:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
include 'Image/Graph.php';
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
$Plotarea =& $Graph->addNew('plotarea');
|
||||
$Dataset =& Image_Graph::factory('dataset');
|
||||
$Dataset->addPoint('Denmark', 10);
|
||||
$Dataset->addPoint('Norway', 3);
|
||||
$Dataset->addPoint('Sweden', 8);
|
||||
$Dataset->addPoint('Finland', 5);
|
||||
$Plot =& $Plotarea->addNew('bar', &$Dataset);
|
||||
$Graph->done();
|
||||
?>
|
40
includes/pear/Image/docs/examples/simple_graph.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate how to use simple graph
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: simple_graph.php,v 1.2 2005/07/28 12:05:14 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
include('Image/Graph/Simple.php');
|
||||
|
||||
$Data = array(
|
||||
'Dogs' => 3,
|
||||
'Cats' => 1,
|
||||
'Parrots' => 4,
|
||||
'Mice' => 5
|
||||
);
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph_Simple::factory(
|
||||
400,
|
||||
300,
|
||||
'Image_Graph_Plot_Smoothed_Area',
|
||||
$Data,
|
||||
'Simple Graph Example',
|
||||
'gray',
|
||||
'blue@0.2',
|
||||
'Verdana'
|
||||
);
|
||||
|
||||
// output the Graph
|
||||
$Graph->done();
|
||||
?>
|
53
includes/pear/Image/docs/examples/small_pie_plot.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Show pie chart
|
||||
*
|
||||
* Other:
|
||||
* None specific
|
||||
*
|
||||
* $Id: small_pie_plot.php,v 1.1 2005/09/30 18:59:17 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(80, 80));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
// create the plotareas
|
||||
$Plotarea =& $Graph->addNew('plotarea');
|
||||
|
||||
$Plotarea->hideAxis();
|
||||
|
||||
// create the dataset
|
||||
$Dataset =& Image_Graph::factory('random', array(10, 10, 20, true));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Pie', $Dataset);
|
||||
|
||||
$Plot->setDiameter(-1);
|
||||
$Plotarea->setPadding(0);
|
||||
|
||||
// set a line color
|
||||
$Plot->setLineColor('gray');
|
||||
|
||||
// set a standard fill style
|
||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||
$Plot->setFillStyle($FillArray);
|
||||
$FillArray->addColor('green@0.2');
|
||||
$FillArray->addColor('blue@0.2');
|
||||
$FillArray->addColor('yellow@0.2');
|
||||
$FillArray->addColor('red@0.2');
|
||||
$FillArray->addColor('orange@0.2');
|
||||
|
||||
$Graph->done();
|
||||
?>
|
62
includes/pear/Image/docs/examples/vector_function.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage example for Image_Graph.
|
||||
*
|
||||
* Main purpose:
|
||||
* Demonstrate vector function data
|
||||
*
|
||||
* Other:
|
||||
* Setting axis intersection
|
||||
*
|
||||
* $Id: vector_function.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
|
||||
*
|
||||
* @package Image_Graph
|
||||
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
|
||||
*/
|
||||
|
||||
require_once 'Image/Graph.php';
|
||||
|
||||
// create the graph
|
||||
$Graph =& Image_Graph::factory('graph', array(400, 300));
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', 'Verdana');
|
||||
// set the font size to 11 pixels
|
||||
$Font->setSize(8);
|
||||
|
||||
$Graph->setFont($Font);
|
||||
|
||||
|
||||
$Graph->add(
|
||||
Image_Graph::vertical(
|
||||
Image_Graph::factory('title', array('Vector Function Chart Sample', 12)),
|
||||
Image_Graph::vertical(
|
||||
// create the plotarea with a normal linear axis as x-axis!
|
||||
$Plotarea = Image_Graph::factory('plotarea', 'axis'),
|
||||
$Legend = Image_Graph::factory('legend'),
|
||||
90
|
||||
),
|
||||
5
|
||||
)
|
||||
);
|
||||
$Legend->setPlotarea($Plotarea);
|
||||
|
||||
function tcost($t) { return $t*cos($t); }
|
||||
function tsint($t) { return $t*sin($t); }
|
||||
|
||||
$GridX =& $Plotarea->addNew('line_grid', null, IMAGE_GRAPH_AXIS_X);
|
||||
$GridY =& $Plotarea->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y);
|
||||
$LineStyle =& Image_Graph::factory('Image_Graph_Line_Dashed', array('lightgrey', 'transparent'));
|
||||
$GridX->setLineStyle($LineStyle);
|
||||
$GridY->setLineStyle($LineStyle);
|
||||
|
||||
$Dataset =& Image_Graph::factory('vector', array(0, 20, 'tcost', 'tsint', 200));
|
||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||
$Plot =& $Plotarea->addNew('line', array(&$Dataset));
|
||||
$Plot->setLineColor('red');
|
||||
$Plot->setTitle('f(t) = { t*cos(t), t*sin(t) }');
|
||||
|
||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||
$AxisY->setAxisIntersection(0);
|
||||
|
||||
$Graph->done();
|
||||
?>
|