Version 1.9g

This commit is contained in:
nemunaire 2008-11-08 12:00:00 +01:00
commit 4c9814a99c
800 changed files with 237325 additions and 1949 deletions

View file

@ -0,0 +1,16 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../AntiSpam.class.php";
$object = new AntiSpam();
$object->setRand(5);
$object->save('example');
$object->draw();
?>

View file

@ -0,0 +1,22 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../AntiSpam.class.php";
$object = new AntiSpam();
if($object->check('example', $_GET['code'])) {
echo "Good value :-)";
} else {
echo "Bad value :-(";
}
?>
<ul>
<li><a href='AntiSpam.php'>Try again</a></li>
</ul>

View file

@ -0,0 +1,14 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
?>
<form action="AntiSpam-valid.php" method="get">
<img src="AntiSpam-image.php" style="vertical-align: middle"/>
<input type="text" name="code"/>
<input type="submit" value="Submit"/>
</form>

55
artichow/examples/all.php Normal file
View file

@ -0,0 +1,55 @@
<?php
function table($files, $re = NULL) {
echo "<table cellpadding='4'>";
foreach($files as $key => $file) {
if($key%2 == 0) {
echo "<tr>";
}
if($re === NULL or eregi($re, $file)) {
image($file);
}
if($key%2 == 1) {
echo "</tr>";
}
}
if($key%2 == 0) {
echo "</tr>";
}
echo "</table>";
}
function image($file) {
echo "<td>
<h3>".$file."</h3>
<a href='".$file."'><img src='".$file."' style='border: 0px'/></a>
</td>";
}
?>
<h2>Artichow examples</h2>
<?php
$glob = glob("*.php");
table($glob, "[a-z]+\-[0-9]{3}\.php");
?>
<h2>Artichow.org examples</h2>
<?php
$glob = glob("site/*.php");
table($glob);
?>
<h2>Artichow tutorials</h2>
<?php
$glob = glob("tutorials/*.php");
table($glob);
?>

View file

@ -0,0 +1,30 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../BarPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('The title');
$graph->border->setStyle(Line::DASHED);
$graph->border->setColor(new DarkGray);
$values = array(19, 42, 15, -25, 3);
$plot = new BarPlot($values);
$plot->setSize(1, 0.96);
$plot->setCenter(0.5, 0.52);
$plot->setBarColor(
new VeryLightPurple(25)
);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,37 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../BarPlot.class.php";
$graph = new Graph(400, 400);
$values = array(2, 6, 3, 2, 4);
$plot = new BarPlot($values);
$plot->setBarGradient(
new LinearGradient(
new LightBlue(25),
new VeryLightOrange(25),
90
)
);
$plot->setSpace(5, 5, NULL, NULL);
$plot->barShadow->setSize(4);
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
$plot->barShadow->setColor(new Color(180, 180, 180, 10));
$plot->barShadow->smooth(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,37 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../BarPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Two bars');
$values = array(12, 8, 13, 2, 4);
$group = new PlotGroup;
$group->setPadding(NULL, NULL, 35, NULL);
$plot = new BarPlot($values, 1, 2);
$plot->setBarColor(new LightBlue(25));
$plot->setBarSpace(5);
$group->add($plot);
$values = array(1, 7, 2, 10, 6);
$plot = new BarPlot($values, 2, 2);
$plot->setBarColor(new LightOrange(25));
$plot->setBarSpace(5);
$group->add($plot);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,36 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../BarPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Two bars with depth');
$group = new PlotGroup;
$group->setPadding(NULL, NULL, 35, NULL);
$group->setSpace(5, 5, NULL, NULL);
$group->grid->hide(TRUE);
$values = array(1, 7, 2, 10, 6, 3, 4, 7);
$plot = new BarPlot($values, 1, 1, 5);
$plot->setBarColor(new LightBlue(25));
$group->add($plot);
$values = array(12, 8, 13, 2, 4, 8, 4, 3);
$plot = new BarPlot($values, 1, 1, 0);
$plot->setBarColor(new LightRed(25));
$group->add($plot);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,59 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../BarPlot.class.php";
$graph = new Graph(400, 400);
// Set a title to the graph
$graph->title->set('The title');
// Change graph background color
$graph->setBackgroundColor(new Color(230, 230, 230));
$values = array(8, 2, 6, 1, 3, 5);
// Declare a new BarPlot
$plot = new BarPlot($values);
// Reduce padding around the plot
$plot->setPadding(NULL, NULL, NULL, 20);
// Reduce plot size and move it to the bottom of the graph
$plot->setSize(1, 0.96);
$plot->setCenter(0.5, 0.52);
// Set a background color to the plot
$plot->grid->setBackgroundColor(new White);
// Set a dashed grid
$plot->grid->setType(Line::DASHED);
$plot->label->set($values);
$plot->label->move(0, -10);
$plot->label->setColor(new DarkBlue);
// Set a shadow to the bars
$plot->barShadow->setSize(2);
// Bar size is at 60%
$plot->setBarSize(0.6);
// Change the color of the bars
$plot->setBarColor(
new Orange(15)
);
// Add the plot to the graph
$graph->add($plot);
// Draw the graph
$graph->draw();
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 B

View file

@ -0,0 +1,29 @@
<?php
require_once "../LinePlot.class.php";
$graph = new Graph(400, 400);
$x = array(1, 10, 3,-4, 1);
$plot = new LinePlot($x);
$plot->setSpace(6, 6, 10, 10);
$plot->hideLine(TRUE);
$plot->setFillColor(new Color(180, 180, 180, 75));
$plot->mark->setType(Mark::IMAGE);
$plot->mark->setImage(new FileImage("champignon.png"));
$plot->grid->setBackgroundColor(new Color(235, 235, 180, 60));
$plot->label->set($x);
$plot->label->move(0, -23);
$plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0));
$plot->label->border->setColor(new Color(20, 20, 20, 20));
$plot->label->setPadding(3, 1, 1, 0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,52 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
$graph = new Graph(400, 300);
$graph->setAntiAliasing(TRUE);
$x = array(
1, 2, 5, 0.5, 3, 8
);
$plot = new LinePlot($x);
$plot->setSpace(6, 6, 10, 10);
$plot->setXAxisZero(FALSE);
// Set a background gradient
$plot->setBackgroundGradient(
new LinearGradient(
new Color(210, 210, 210),
new Color(255, 255, 255),
0
)
);
// Change line color
$plot->setColor(new Color(0, 0, 150, 20));
// Set line background gradient
$plot->setFillGradient(
new LinearGradient(
new Color(150, 150, 210),
new Color(230, 230, 255),
90
)
);
// Change mark type
$plot->mark->setType(Mark::CIRCLE);
$plot->mark->border->show();
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,44 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
$graph = new Graph(400, 300);
$graph->setAntiAliasing(TRUE);
$x = array(
1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4
);
$plot = new LinePlot($x);
// Set a background gradient
$plot->setBackgroundGradient(
new LinearGradient(
new Color(210, 210, 210),
new Color(255, 255, 255),
0
)
);
// Set semi-transparent background gradient
$plot->setFillGradient(
new LinearGradient(
new Color(230, 150, 150, 20),
new Color(230, 230, 180, 50),
90
)
);
$plot->yAxis->setLabelPrecision(1);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,59 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
$graph = new Graph(400, 300);
$graph->setAntiAliasing(TRUE);
$x = array(
1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4
);
$plot = new LinePlot($x);
// Change component padding
$plot->setPadding(10, NULL, NULL, NULL);
// Change component space
$plot->setSpace(5, 5, 5, 5);
// Set a background color
$plot->setBackgroundColor(
new Color(230, 230, 230)
);
// Change grid background color
$plot->grid->setBackgroundColor(
new Color(235, 235, 180, 60)
);
// Hide grid
$plot->grid->hide(TRUE);
// Hide labels on Y axis
$plot->yAxis->label->hide(TRUE);
$plot->xAxis->label->setInterval(2);
$plot->label->set($x);
$plot->label->setFormat('%.1f');
$plot->label->setBackgroundColor(new Color(240, 240, 240, 15));
$plot->label->border->setColor(new Color(255, 0, 0, 15));
$plot->label->setPadding(5, 3, 1, 1);
$plot->xAxis->label->move(0, 5);
$plot->xAxis->label->setBackgroundColor(new Color(240, 240, 240, 15));
$plot->xAxis->label->border->setColor(new Color(0, 150, 0, 15));
$plot->xAxis->label->setPadding(5, 3, 1, 1);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,36 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
$graph = new Graph(400, 300);
$x = array(
-4, -5, -2, -8, -3, 1, 4, 9, 5, 6, 2
);
$plot = new LinePlot($x);
// Filled an area with a color
$plot->setFilledArea(7, 9, new DarkGreen(25));
// Filled the area with a gradient
$gradient = new LinearGradient(
new Yellow(25),
new Orange(25),
90
);
$plot->setFilledArea(1, 4, $gradient);
// Hide first label
$plot->xAxis->label->hideFirst(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,49 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
// Use cache
$graph = new Graph(400, 400, "Example-006", time() + 5);
$graph->setTiming(TRUE);
$graph->setAntiAliasing(TRUE);
$x = array();
for($i = 0; $i < 10; $i++) {
$x[] = mt_rand(0, 100);
}
$plot = new LinePlot($x);
$plot->setColor(
new Color(60, 60, 150)
);
$plot->setFillGradient(
new LinearGradient(
new Color(120, 175, 80, 47),
new Color(231, 172, 113, 30),
0
)
);
$plot->grid->setType(Line::DASHED);
$plot->setYMin(-5);
$plot->yAxis->setLabelNumber(8);
$plot->yAxis->setLabelPrecision(1);
$plot->xAxis->setNumberByTick('minor', 'major', 3);
$plot->setXAxisZero(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,67 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
// Return a random color
function color($a = NULL) {
return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
function formatLabel($value) {
return sprintf("%.2f", $value);
}
$graph = new Graph(450, 400);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Some lines");
$group = new PlotGroup;
$group->setXAxisZero(FALSE);
$group->setBackgroundColor(new Color(197, 180, 210, 80));
$group->setPadding(40, NULL, 50, NULL);
$group->axis->left->setLabelNumber(8);
$group->axis->left->setLabelPrecision(1);
$group->axis->left->setTickStyle(Tick::OUT);
$group->axis->bottom->setTickStyle(Tick::OUT);
// Display two lines
for($n = 0; $n < 2; $n++) {
$x = array();
for($i = 0; $i < 10; $i++) {
$x[] = (cos($i * M_PI / 5)) / ($n + 1);
}
$plot = new LinePlot($x);
$plot->setColor(color(10)); // Random line color
$plot->setFillColor(color(90)); // Random background color
$plot->label->set($x);
$plot->label->setBackgroundColor(new Color(220, 234, 230, 25));
$plot->label->setPadding(1, 0, 0, 0);
$plot->label->setCallbackFunction("formatLabel");
$plot->label->setInterval(2);
$group->add($plot);
$group->legend->add($plot, "Line #".($n + 1), Legend::LINE);
}
$group->legend->setSpace(12);
$group->legend->setBackgroundColor(new Color(255, 255, 255));
$group->setPadding(NULL, 100, NULL, NULL);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,34 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
// Use cache
$graph = new Graph(400, 400);
$graph->setAntiAliasing(TRUE);
$graph->border->setStyle(Line::DOTTED);
$graph->border->setColor(new Red);
$x = array();
for($i = 0; $i < 10; $i++) {
$x[] = mt_rand(20, 100);
}
$plot = new LinePlot($x);
$plot->setFilledArea(0, 1, new Red(40));
$plot->setFilledArea(1, 2, new LinearGradient(new Red(40), new Orange(40), 90));
$plot->setFilledArea(2, 4, new LinearGradient(new Orange(40), new Green(40), 90));
$plot->setFilledArea(4, 7, new LinearGradient(new Green(40), new Blue(40), 90));
$plot->setFilledArea(7, 8, new LinearGradient(new Blue(40), new Purple(40), 90));
$plot->setFilledArea(8, 9, new Purple(40));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,66 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
$graph = new Graph(400, 200);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup;
$group->setXAxisZero(FALSE);
$group->grid->setType(Line::DASHED);
$group->setBackgroundColor(new Color(197, 180, 210, 80));
$group->setPadding(40, NULL, 20, NULL);
$group->axis->left->setLabelNumber(8);
$group->axis->left->setLabelPrecision(1);
$group->axis->left->setTickStyle(Tick::IN);
$group->axis->left->label->move(-4, 0);
$group->axis->bottom->setTickStyle(Tick::OUT);
$group->axis->bottom->label->move(0, 4);
$x = array();
for($i = 0; $i < 15; $i++) {
$x[] = cos($i * M_PI / 5);
}
$plot = new LinePlot($x);
$plot->setColor(new Color(40, 40, 150, 10));
$plot->setFillColor(new Color(40, 40, 150, 90));
$group->add($plot);
$group->legend->add($plot, "Ligne #1", Legend::LINE);
$x = array();
for($i = 5; $i < 15; $i++) {
$x[] = (cos($i * M_PI / 5)) / 2;
}
$plot = new LinePlot($x);
$plot->setColor(new Color(120, 120, 30, 10));
$plot->setFillColor(new Color(120, 120, 30, 90));
$group->add($plot);
$group->legend->add($plot, "Ligne #2", Legend::LINE);
$group->legend->setTextFont(new Tuffy(8));
$group->legend->shadow->setSize(0);
$group->legend->setSpace(12);
$group->legend->setBackgroundColor(new Color(255, 255, 255));
$group->setPadding(NULL, 100, NULL, NULL);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,46 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../LinePlot.class.php";
$graph = new Graph(375, 200);
// Set title
$graph->title->set('Star marks');
$graph->title->setFont(new Tuffy(12));
$graph->title->setColor(new DarkRed);
$plot = new LinePlot(array(5, 3, 4, 7, 6, 5, 8, 4, 7));
// Change plot size and position
$plot->setSize(0.76, 1);
$plot->setCenter(0.38, 0.5);
$plot->setPadding(30, 15, 38, 25);
$plot->setColor(new Orange());
$plot->setFillColor(new LightOrange(80));
// Change grid style
$plot->grid->setType(Line::DASHED);
// Add customized marks
$plot->mark->setType(Mark::STAR);
$plot->mark->setFill(new MidRed);
$plot->mark->setSize(6);
// Change legend
$plot->legend->setPosition(1, 0.5);
$plot->legend->setAlign(Legend::LEFT);
$plot->legend->shadow->smooth(TRUE);
$plot->legend->add($plot, 'My line', Legend::MARK);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,23 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 3, -3);
$plot->setInterval(0.1);
$function = new MathFunction('cos');
$plot->add($function);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,36 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
// Set graph title
$graph->title->set('f(x) = x * x');
$graph->title->setBackgroundColor(new White(0));
$graph->title->setPadding(NULL, NULL, 10, 10);
$graph->title->move(0, -10);
$plot = new MathPlot(-3, 3, 10, -2);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
// Defines x²
function x2($x) {
return $x * $x;
}
$function = new MathFunction('x2');
$function->setColor(new Orange);
$plot->add($function);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,33 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 20, -1);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
$plot->yAxis->setLabelInterval(4);
$function = new MathFunction('exp');
$function->setColor(new DarkRed);
$function->mark->setType(Mark::SQUARE);
$function->mark->setSize(3);
$function->mark->setFill(new DarkBlue);
$plot->add($function, "f(x) = exp(x)", Legend::MARK);
$plot->legend->setPosition(0.4, 0.2);
$plot->legend->setPadding(3, 3, 3, 3, 3);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,39 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 10, -3);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
$function = new MathFunction('exp');
$function->setColor(new DarkRed);
$function->mark->setType(Mark::SQUARE);
$function->mark->setSize(3);
$function->mark->setFill(new DarkBlue);
$plot->add($function, "f(x) = exp(x)", Legend::MARK);
function x2($x) {
return - $x * $x;
}
$function = new MathFunction('x2');
$function->setColor(new DarkBlue);
$plot->add($function, "f(x) = - x * x");
$plot->legend->setPosition(0.4, 0.4);
$plot->legend->setPadding(3, 3, 3, 3, 3);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,34 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 2, -3);
$plot->setInterval(0.05);
$function = new MathFunction('sqrt', 0);
$plot->add($function, "sqrt(x)");
function x2($x) {
return - $x * $x;
}
$function = new MathFunction('sin', -2, 2);
$function->setColor(new DarkBlue);
$plot->add($function, "sin(x) (-2 < x < 2)");
$plot->legend->setPosition(0.98, 0.8);
$plot->legend->setTextFont(new Tuffy(8));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,26 @@
<?php
require_once "../Pattern.class.php";
require_once "../Graph.class.php";
$graph = new Graph(300, 200);
// Set title
$graph->title->set('Pattern 1');
$graph->title->move(100, 0);
$graph->title->setFont(new Tuffy(9));
$graph->title->setColor(new DarkRed);
$pattern = Pattern::get('BarDepth');
$pattern->setArgs(array(
'yForeground' => array(5, 3, 4, 7, 6, 5, 8, 4, 7, NULL, NULL),
'yBackground' => array(NULL, NULL, 4, 5, 6, 4, 2, 3, 7, 5, 4),
'legendForeground' => '2003',
'legendBackground' => '2004'
));
$group = $pattern->create();
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,24 @@
<?php
require_once "../Pattern.class.php";
require_once "../Graph.class.php";
$graph = new Graph(300, 200);
$graph->title->set('Customized pattern 1');
$graph->title->setFont(new Tuffy(12));
$pattern = Pattern::get('BarDepth');
$pattern->setArgs(array(
'yForeground' => array(5, 3, 4, 7, 6, 5, 8, 4, 7, NULL, NULL),
'yBackground' => array(NULL, NULL, 4, 5, 6, 4, 2, 3, 7, 5, 4),
'colorForeground' => new Color(230, 230, 230),
'colorBackground' => new Color(250, 90, 90)
));
$group = $pattern->create();
$group->legend->setPosition(0.5, 0.78);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,23 @@
<?php
require_once "../Pattern.class.php";
require_once "../Graph.class.php";
$graph = new Graph(400, 200);
// Set title
$graph->title->set('Pattern 2');
$graph->title->setFont(new Tuffy(12));
$graph->title->setColor(new DarkRed);
$pattern = Pattern::get('LightLine');
$pattern->setArgs(array(
'y' => array(5, 3, 4, 7, 6, 5, 8, 4, 7),
'legend' => 'John Doe'
));
$plot = $pattern->create();
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,40 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->title->set("Pie (example 1)");
$values = array(12, 5, 13, 18, 10, 6, 11);
$plot = new Pie($values, Pie::EARTH);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$plot->legend->shadow->setSize(0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,41 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 2)");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values, Pie::EARTH);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->explode(array(1 => 20, 4 => 26, 0 => 25));
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,42 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 3)");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values, Pie::AQUA);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(15);
$plot->explode(array(4 => 20, 0 => 30));
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,50 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setBackgroundGradient(
new LinearGradient(
new White,
new VeryLightGray,
0
)
);
$graph->title->set("Pie (example 4)");
$graph->shadow->setSize(7);
$graph->shadow->smooth(TRUE);
$graph->shadow->setPosition(Shadow::LEFT_BOTTOM);
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,47 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setBackgroundGradient(
new LinearGradient(
new VeryLightGray,
new White,
0
)
);
$graph->title->set("Pie (example 5) - Initial angle: 140°");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->setStartAngle(140);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,37 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setBackgroundGradient(
new LinearGradient(
new VeryLightGray,
new White,
0
)
);
$graph->title->set("Pie (example 6)");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values);
$plot->setCenter(0.5, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(5);
$plot->setBorderColor(new Black);
$plot->legend->hide(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,56 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 7)");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values, Pie::DARK);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(5);
$plot->setBorderColor(new White);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$plot->legend->shadow->setPosition(Shadow::RIGHT_TOP);
$plot->label->setPadding(2, 2, 2, 2);
$plot->label->border->setColor(new Red(60));
$plot->label->setFont(new Tuffy(7));
$plot->label->setBackgroundGradient(
new LinearGradient(
new Red(80),
new White(80),
0
)
);
$plot->setLabelPrecision(1);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,54 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 300);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 8)");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values, Pie::EARTH);
$plot->setSize(0.85, 0.60);
$plot->set3D(15);
$plot->setBorderColor(new LightGray);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->shadow->setSize(3);
$plot->legend->setModel(Legend::MODEL_BOTTOM);
$plot->legend->setPosition(NULL, 1.1);
$plot->label->setPadding(2, 2, 2, 2);
$plot->label->border->setColor(new Red(60));
$plot->label->setFont(new Tuffy(7));
$plot->label->setBackgroundGradient(
new LinearGradient(
new Red(80),
new White(80),
0
)
);
$plot->setLabelPrecision(1);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,49 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 9) - User defined colors");
$graph->title->border->show();
$graph->title->setBackgroundColor(new LightRed(60));
$graph->title->setPadding(3, 3, 3, 3);
$values = array(8, 4, 6, 3, 4);
$colors = array(
new LightOrange,
new LightPurple,
new LightBlue,
new LightRed,
new LightPink
);
$plot = new Pie($values, $colors);
$plot->setSize(0.70, 0.60);
$plot->setCenter(0.40, 0.55);
$plot->set3D(10);
$plot->setBorderColor(new LightGray);
$plot->setLegend(array(
'Alpha',
'Beta',
'Gamma',
'Delta',
'Epsilon'
));
$plot->legend->setPosition(1.30);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,29 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->title->set("Pie (example 10) - Just a pie");
$graph->title->setFont(new Tuffy(10));
$values = array(8, 4, 6, 1, 2, 3, 4);
$plot = new Pie($values);
$plot->set3D(10);
$plot->legend->hide(TRUE);
$plot->label->hide(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,48 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
function createPie($values, $title, $x, $y) {
$plot = new Pie($values, Pie::EARTH);
$plot->title->set($title);
$plot->title->setFont(new TuffyBold(8));
$plot->title->move(NULL, -12);
$plot->label->setFont(new Tuffy(7));
$plot->legend->hide(TRUE);
$plot->setLabelPosition(5);
$plot->setSize(0.45, 0.45);
$plot->setCenter($x, $y);
$plot->set3D(10);
$plot->setBorderColor(new Color(230, 230, 230));
return $plot;
}
$graph = new Graph(400, 300);
$plot = createPie(array(1, 4, 5, 2, 3), "Cowléoptère", 0.22, 0.25);
$graph->add($plot);
$plot = createPie(array(1, 9, 1, 2, 1), "Asticow", 0.68, 0.25);
$graph->add($plot);
$plot = createPie(array(5, 7, 8, 6, 3), "Cowlibri", 0.22, 0.75);
$graph->add($plot);
$plot = createPie(array(6, 4, 6, 5, 6), "Bourricow", 0.68, 0.75);
$plot->legend->hide(FALSE); // We print only one legend
$plot->legend->setPosition(1.18, 0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,38 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(300, 300);
$graph->title->set("Pie (example 12)");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values, Pie::EARTH);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->explode(array(1 => 20, 4 => 25));
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,40 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 13)");
$values = array(12, 5, 13, 18, 10, 6, 11);
$plot = new Pie($values, Pie::EARTH);
$plot->setCenter(0.4, 0.55);
$plot->setAbsSize(180, 180);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.5);
$plot->legend->shadow->setSize(0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,48 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
function createPie($values, $title, $x, $y) {
$plot = new Pie($values);
$plot->title->set($title);
$plot->title->setFont(new TuffyBold(8));
$plot->title->move(NULL, -12);
$plot->label->setFont(new Tuffy(7));
$plot->legend->hide(TRUE);
$plot->setLabelPosition(5);
$plot->setSize(0.40, 0.40);
$plot->setCenter($x, $y);
$plot->setBorderColor(new Black);
return $plot;
}
$graph = new Graph(400, 400);
$graph->setAntiAliasing(TRUE);
$plot = createPie(array(1, 4, 5, 2, 3), "Cowléoptère", 0.22, 0.25);
$graph->add($plot);
$plot = createPie(array(1, 9, 1, 2, 1), "Asticow", 0.66, 0.25);
$graph->add($plot);
$plot = createPie(array(5, 7, 8, 6, 3), "Cowlibri", 0.22, 0.75);
$graph->add($plot);
$plot = createPie(array(6, 4, 6, 5, 6), "Bourricow", 0.66, 0.75);
$plot->legend->hide(FALSE); // We print only one legend
$plot->legend->setPosition(1.25, 0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,50 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 300);
$graph->setBackgroundGradient(
new LinearGradient(
new VeryLightGray,
new White,
0
)
);
$graph->title->set("Pie (example 15) - Arbitrary labels");
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.6, 0.6 * 4 / 3);
$plot->label->set(array(
'Arthur', 'Abel', 'Bernard', 'Thierry', 'Paul', 'Gaston', 'Joe'
));
$plot->label->setCallbackFunction(NULL); // We must disable the default callback function
$plot->setLegend(array(
'ABC',
'DEF',
'GHI',
'JKL',
'MNO',
'PQR',
'STU'
));
$plot->legend->setPosition(1.3);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,45 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 13) - Adjusting labels");
$values = array(16, 9, 13, 23, 10);
$plot = new Pie($values, Pie::EARTH);
$plot->setCenter(0.4, 0.55);
$plot->setAbsSize(220, 220);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->setLabelPosition(-40);
$plot->label->setPadding(2, 2, 2, 2);
$plot->label->setFont(new Tuffy(7));
$plot->label->setBackgroundColor(new White(60));
$plot->legend->setPosition(1.3);
$plot->legend->shadow->setSize(0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,48 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 17)");
$graph->title->setFont(new Tuffy(14));
$values = array(12, 16, 13, 18, 10, 20, 11);
$plot = new Pie($values, Pie::AQUA);
$plot->setCenter(0.4, 0.55);
$plot->setAbsSize(180, 180);
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$explode = array();
for($i = 0; $i < count($values); $i++) {
$explode[] = 15;
}
$plot->explode($explode);
$plot->legend->setPosition(1.5);
$plot->legend->shadow->setSize(0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,32 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../Pie.class.php";
$graph = new Graph(400, 250);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Pie (example 18) - Display labels > 10 %");
$graph->title->setFont(new Tuffy(14));
$values = array(1, 5, 6, 16, 18, 19, 21, 3, 4, 7, 6);
$plot = new Pie($values);
$plot->setCenter(0.4, 0.55);
$plot->setAbsSize(180, 180);
$plot->setLabelMinimum(10);
$plot->legend->setPosition(1.5);
$plot->legend->shadow->setSize(0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,21 @@
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Simple ScatterPlot');
$y = array(1, 10, 3,-4, 1, 4, 8, 7);
$x = array(0.5, 0.5, 3, 5, 2, 3, 4, 1.5);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new VeryLightGray);
$plot->setPadding(NULL, NULL, 40, 20);
$plot->legend->add($plot, 'Some points', Legend::MARKONLY);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,21 @@
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Linked ScatterPlot');
$y = array(1, 10, 3,-4, 1, 4, 8, 7);
$x = array(0.5, 0.5, 3, 5, 2, 3, 4, 1.5);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new VeryLightGray);
$plot->setPadding(NULL, NULL, 40, 20);
$plot->link(TRUE, new DarkBlue);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,30 @@
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->shadow->setSize(5);
$graph->title->set('ScatterPlot with values');
$y = array(4, 3, 2, 5, 8, 1, 3, 6, 4, 5);
$x = array(1, 2, 5, 4, 3, 6, 2, 4, 5, 1);
$plot = new ScatterPlot($y, $x);
$plot->setSpace(6, 6, 6, 0);
$plot->setPadding(NULL, NULL, 40, 20);
// Set dashed lines on the grid
$plot->grid->setType(Line::DASHED);
$plot->mark->setSize(30);
$plot->mark->setFill(new DarkOrange(20));
$plot->label->set($y);
$plot->label->setColor(new White);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,32 @@
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->shadow->setSize(5);
$y = array();
for($i = 0; $i < 60; $i++) {
$y[] = cos($i / 30 * 2 * M_PI);
}
$plot = new ScatterPlot($y);
$plot->setSpace(6, 6);
// Set impulses
$plot->setImpulse(new DarkGreen);
$plot->grid->hideVertical();
// Hide axis labels and ticks
$plot->xAxis->label->hide();
$plot->xAxis->hideTicks();
$plot->mark->setType(Mark::SQUARE);
$plot->mark->setSize(4);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,37 @@
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Impulses');
$graph->title->move(0, 30);
$graph->shadow->setSize(5);
$y = array();
for($i = 0; $i < 60; $i++) {
$y[] = cos($i / 30 * 2 * M_PI) / (1.5 + $i / 15);
}
$plot = new ScatterPlot($y);
$plot->setBackgroundColor(new VeryLightOrange);
$plot->setSpace(5);
// Set impulses
$plot->setImpulse(new DarkBlue);
$plot->grid->hideVertical();
// Hide ticks
$plot->xAxis->hideTicks();
// Change labels interval
$plot->xAxis->label->setInterval(5);
$plot->mark->setType(Mark::SQUARE);
$plot->mark->setSize(4);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,39 @@
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$center = 5;
$x = array();
$y = array();
for($i = 0; $i <= 30; $i++) {
$rad = ($i / 30) * 2 * M_PI;
$x[] = $center + cos($rad) * $center;
$y[] = $center + sin($rad) * $center;
}
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new VeryLightGray);
$plot->setPadding(30, 30, 30, 30);
$plot->setSpace(5, 5, 5, 5);
$plot->link(TRUE, new DarkGreen);
$plot->mark->setFill(new DarkOrange);
$plot->mark->setType(Mark::SQUARE, 4);
$plot->setXAxis(Plot::BOTH);
$plot->setXAxisZero(FALSE);
$plot->setYAxis(Plot::BOTH);
$plot->legend->add($plot, 'A circle', Legend::MARK);
$plot->legend->setPosition(0.5, 0.5);
$plot->legend->setAlign(Legend::CENTER, Legend::MIDDLE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,60 @@
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$group = new PlotGroup;
$group->setBackgroundColor(new VeryLightGray);
$group->setPadding(30, 30, 30, 30);
$group->setSpace(5, 5, 5, 5);
$group->legend->setPosition(0.5, 0.62);
$group->legend->setAlign(Legend::CENTER, Legend::MIDDLE);
function getCircle($size) {
$center = 0;
$x = array();
$y = array();
for($i = 0; $i <= 30; $i++) {
$rad = ($i / 30) * 2 * M_PI;
$x[] = $center + cos($rad) * $size;
$y[] = $center + sin($rad) * $size;
}
return array($x, $y);
}
list($x, $y) = getCircle(3);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkBlue);
$plot->mark->setFill(new DarkPink);
$plot->mark->setType(Mark::CIRCLE, 6);
$group->legend->add($plot, 'Circle #1', Legend::MARK);
$group->add($plot);
list($x, $y) = getCircle(5);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkGreen);
$plot->mark->setFill(new DarkOrange);
$plot->mark->setType(Mark::SQUARE, 4);
$group->legend->add($plot, 'Circle #2', Legend::MARK);
$group->add($plot);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,80 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
$graph = new Graph(280, 200);
$graph->setAntiAliasing(TRUE);
$x = array(
1, 2, 5, 0.5, 3, 8, 6
);
$plot = new BarPlot($x);
$plot->setSpace(4, 4, 10, 0);
$plot->setPadding(40, 15, 10, 40);
$plot->title->set("Zoé and friends");
$plot->title->setFont(new TuffyBold(11));
$plot->title->border->show();
$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
$plot->title->setPadding(4, 4, 4, 4);
$plot->title->move(-20, 25);
$plot->yAxis->title->set("Axe des Y");
$plot->yAxis->title->setFont(new TuffyBold(10));
$plot->yAxis->title->move(-4, 0);
$plot->yAxis->setTitleAlignment(Label::TOP);
$plot->xAxis->title->set("Axe des X");
$plot->xAxis->title->setFont(new TuffyBold(10));
$plot->xAxis->setTitleAlignment(Label::RIGHT);
$plot->setBackgroundGradient(
new LinearGradient(
new Color(230, 230, 230),
new Color(255, 255, 255),
0
)
);
$plot->barBorder->setColor(new Color(0, 0, 150, 20));
$plot->setBarGradient(
new LinearGradient(
new Color(150, 150, 210, 0),
new Color(230, 230, 255, 30),
0
)
);
$y = array(
'Zoé',
'Yvan',
'Fred',
'Lucie',
'Ilia',
'Nino',
'Marie'
);
$plot->xAxis->setLabelText($y);
$plot->xAxis->label->setFont(new TuffyBold(7));
$graph->shadow->setSize(4);
$graph->shadow->setPosition(Shadow::LEFT_TOP);
$graph->shadow->smooth(TRUE);
$graph->shadow->setColor(new Color(160, 160, 160));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,80 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
$graph = new Graph(280, 280);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup;
$group->setSpace(6, 6, 5, 5);
$group->setBackgroundGradient(
new LinearGradient(
new Color(235, 235, 235),
new White(),
0
)
);
$group->setPadding(40, 10, 10, 50);
$group->axis->left->setLabelPrecision(2);
$group->axis->bottom->label->hide(TRUE);
$group->axis->bottom->hideTicks(TRUE);
$group->grid->setType(Line::DASHED);
$group->grid->hideHorizontal(TRUE);
$gradients = array(
new LinearGradient(
new Color(30, 30, 160, 10), new Color(120, 120, 160, 10), 0
),
new LinearGradient(
new Color(30, 160, 30, 10), new Color(120, 160, 120, 10), 0
),
new LinearGradient(
new Color(160, 30, 30, 10), new Color(160, 120, 120, 10), 0
)
);
for($n = 0; $n < 3; $n++) {
$x = array();
for($i = 0; $i < 6; $i++) {
$x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 900) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0);
}
$plot = new BarPlot($x, $n + 1, 3);
$plot->setXAxis(Plot::BOTTOM);
$plot->barShadow->setSize(1);
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
$plot->barShadow->setColor(new Color(160, 160, 160, 10));
$plot->barBorder->setColor($gradients[$n]->from);
$plot->setBarGradient($gradients[$n]);
$plot->setBarSpace(2);
$group->legend->add($plot, 'Bar#'.($n + 1), Legend::BACKGROUND);
$group->add($plot);
}
$group->legend->setModel(Legend::MODEL_BOTTOM);
$group->legend->setPosition(NULL, 0.86);
$group->legend->shadow->hide();
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,73 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
function color($a = NULL) {
if($a === NULL) {
$a = 0;
}
return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$graph->border->hide();
$group = new PlotGroup;
$group->setSpace(5, 10, 20, 15);
$group->setPadding(40, 10, NULL, 20);
$group->setXAxisZero(FALSE);
$group->axis->left->setLabelPrecision(2);
$colors = array(
new Color(100, 180, 154, 12),
new Color(100, 154, 180, 12),
new Color(154, 100, 180, 12),
new Color(180, 100, 154, 12)
);
for($n = 0; $n < 4; $n++) {
$x = array();
for($i = 0; $i < 6; $i++) {
$x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 1400) / 1000 - 0.5);
}
$plot = new BarPlot($x, 1, 1, (3 - $n) * 7);
$plot->barBorder->setColor(new Color(0, 0, 0));
$plot->setBarSize(0.54);
$plot->barShadow->setSize(3);
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
$plot->barShadow->setColor(new Color(160, 160, 160, 10));
$plot->barShadow->smooth(TRUE);
$plot->setBarColor($colors[$n]);
$group->add($plot);
$group->legend->add($plot, "Barre #".$n, Legend::BACKGROUND);
}
$group->legend->shadow->setSize(0);
$group->legend->setAlign(Legend::CENTER);
$group->legend->setSpace(6);
$group->legend->setTextFont(new Tuffy(8));
$group->legend->setPosition(0.50, 0.12);
$group->legend->setBackgroundColor(new Color(255, 255, 255, 25));
$group->legend->setColumns(2);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,92 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
function labelFormat($value) {
return round($value, 2);
}
$graph = new Graph(280, 200);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup;
$group->setSpace(5, 5, 15, 0);
$group->setPadding(40, 40);
$group->axis->left->setLabelPrecision(2);
$group->axis->right->setLabelPrecision(2);
$colors = array(
new Color(80, 105, 190, 10),
new Color(105, 190, 80, 10)
);
$darkColor = array(
new Color(40, 55, 120, 10),
new Color(55, 120, 40, 10)
);
$axis = array(
Plot::LEFT,
Plot::RIGHT
);
$group->axis->left->setColor($darkColor[0]);
$group->axis->left->label->setColor($darkColor[0]);
$group->axis->right->setColor($darkColor[1]);
$group->axis->right->label->setColor($darkColor[1]);
$group->setBackgroundGradient(
new LinearGradient(
new Color(225, 225, 225),
new Color(255, 255, 255),
0
)
);
for($n = 0; $n < 2; $n++) {
$x = array();
for($i = 0; $i < 4; $i++) {
$x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0) + 1;
}
$plot = new BarPlot($x, $n+1, 2);
$plot->barBorder->setColor(new Color(0, 0, 0, 30));
$plot->setBarPadding(0.1, 0.1);
$plot->setBarSpace(5);
$plot->barShadow->setSize(3);
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
$plot->barShadow->setColor(new Color(180, 180, 180, 10));
$plot->barShadow->smooth(TRUE);
$plot->label->set($x);
$plot->label->move(0, -6);
$plot->label->setFont(new Tuffy(7));
$plot->label->setAngle(90);
$plot->label->setAlign(NULL, Label::TOP);
$plot->label->setPadding(3, 1, 0, 6);
$plot->label->setCallbackFunction("labelFormat");
$plot->setBarColor($colors[$n]);
$plot->setYAxis($axis[$n]);
$group->add($plot);
}
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,82 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$graph->border->hide();
$group = new PlotGroup;
$group->grid->hide(TRUE);
$group->setSpace(2, 2, 20, 0);
$group->setPadding(30, 10, NULL, NULL);
$colors = array(
new Orange(25),
new LightBlue(10)
);
for($n = 0; $n < 2; $n++) {
$x = array();
for($i = 0; $i < 3 - $n * 3; $i++) {
$x[] = NULL;
}
for($i = 3 - ($n * 3); $i < 12 - ($n * 3); $i++) {
$x[] = cos($i * M_PI / 100) * mt_rand(800, 1200) / 1000 * (((1 - $n) * 5 + 10) / 10);
}
for($i = 0; $i < $n * 3; $i++) {
$x[] = NULL;
}
$plot = new BarPlot($x, 1, 1, (1 - $n) * 6);
// $plot->setBarPadding(2, 2);
$plot->barShadow->setSize(2);
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
$plot->barShadow->setColor(new Color(160, 160, 160, 10));
$plot->barShadow->smooth(TRUE);
$plot->setBarColor($colors[$n]);
$group->add($plot);
$group->legend->add($plot, $n + date('Y'), Legend::BACKGROUND);
}
function setPc($value) {
return round($value * 10).'%';
}
$group->axis->left->label->setCallbackFunction('setPc');
$months = array(
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
);
$group->axis->bottom->setLabelText($months);
$group->axis->bottom->hideTicks(TRUE);
$group->legend->shadow->setSize(0);
$group->legend->setAlign(Legend::CENTER);
$group->legend->setSpace(6);
$group->legend->setTextFont(new Tuffy(8));
$group->legend->setPosition(0.50, 0.10);
$group->legend->setBackgroundColor(new Color(255, 255, 255, 25));
$group->legend->setColumns(2);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,68 @@
<?php
require_once "../../Graph.class.php";
$graph = new Graph(300, 200);
$driver = $graph->getDriver();
$driver->filledRectangle(
new Color(230, 230, 230, 0),
new Line(
new Point(10, 10),
new Point(200, 150)
)
);
for($i = 7; $i < 400; $i += 15) {
$driver->line(
new Color(0, 0, 0),
new Line(
new Point($i, 0 + 50),
new Point($i, 30 + 50)
)
);
}
for($i = 7; $i < 30; $i += 15) {
$driver->line(
new Color(0, 0, 0),
new Line(
new Point(0, $i + 50),
new Point(400, $i + 50)
)
);
}
$driver->filledRectangle(
new Color(0, 100, 200, 50),
new Line(
new Point(100, 100),
new Point(280, 180)
)
);
$debut = new Color(230, 250, 0);
$fin = new Color(255, 255, 255, 100);
$driver->filledEllipse(
new RadialGradient(
$debut,
$fin
),
new Point(105, 135),
90, 90
);
$text = new Text(
"Artichow !",
new Tuffy(15),
new Color(0, 0, 80),
45
);
$driver->string($text, new Point(210, 75));
$graph->draw();
?>

View file

@ -0,0 +1,36 @@
<?php
require_once "../../ScatterPlot.class.php";
$graph = new Graph(300, 200);
$graph->title->set('Impulses');
$graph->shadow->setSize(4);
$y = array();
for($i = 0; $i < 40; $i++) {
$y[] = cos($i / 15 * 2 * M_PI) / (0.8 + $i / 15) * 4;
}
$plot = new ScatterPlot($y);
$plot->setPadding(25, 15, 35, 15);
$plot->setBackgroundColor(new Color(230, 230, 255));
$plot->setSpace(2, 2);
// Set impulses
$plot->setImpulse(new DarkBlue);
$plot->grid->hideVertical();
$plot->grid->setType(Line::DASHED);
// Hide ticks
$plot->xAxis->hideTicks();
$plot->xAxis->label->hide();
$plot->mark->setType(Mark::SQUARE);
$plot->mark->setSize(4);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,71 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(300, 175);
$graph->setAntiAliasing(TRUE);
$x = array(
3, 1, 5, 6, 3, 8, 6
);
$plot = new LinePlot($x);
$plot->grid->setNoBackground();
$plot->title->set("Filled line and marks");
$plot->title->setFont(new Tuffy(10));
$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
$plot->title->border->show();
$plot->title->setPadding(3, 3, 3, 3);
$plot->title->move(-20, 25);
$plot->setSpace(4, 4, 10, 0);
$plot->setPadding(25, 15, 10, 18);
$plot->setBackgroundGradient(
new LinearGradient(
new Color(210, 210, 210),
new Color(255, 255, 255),
0
)
);
$plot->setColor(new Color(0, 0, 150, 20));
$plot->setFillGradient(
new LinearGradient(
new Color(150, 150, 210),
new Color(245, 245, 245),
0
)
);
$plot->mark->setType(Mark::CIRCLE);
$plot->mark->border->show();
$y = array(
'Lundi',
'Mardi',
'Mercredi',
'Jeudi',
'Vendredi',
'Samedi',
'Dimanche'
);
$plot->xAxis->setLabelText($y);
$plot->xAxis->label->setFont(new Tuffy(7));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,62 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(300, 175);
$graph->setAntiAliasing(TRUE);
$x = array(
4, 3, 1, 0, -2, 1, 3, 2, 3, 5, 4, 1
);
$plot = new LinePlot($x);
$plot->setXAxisZero(FALSE);
$plot->grid->hide(TRUE);
$plot->title->set("Using dashed line and legend");
$plot->title->setFont(new TuffyItalic(9));
$plot->title->setBackgroundColor(new Color(255, 255, 255, 50));
$plot->title->setPadding(3, 3, 3, 3);
$plot->title->move(0, 20);
$plot->setSpace(6, 6, 10, 10);
$plot->setPadding(30, 10, 15, 25);
$plot->setBackgroundColor(
new Color(245, 245, 245)
);
$plot->setStyle(Line::DASHED);
$plot->setColor(new Color(0, 150, 0, 20));
$plot->setFillGradient(
new LinearGradient(
new Color(220, 220, 150, 40),
new Color(255, 255, 210, 30),
0
)
);
$graph->shadow->setSize(4);
$graph->shadow->setPosition(Shadow::LEFT_BOTTOM);
$graph->shadow->smooth(TRUE);
$plot->legend->add($plot, "Apples");
$plot->legend->shadow->setSize(0);
$plot->legend->setAlign(Legend::CENTER, Legend::TOP);
$plot->legend->setPosition(0.75, 0.60);
$plot->legend->setTextFont(new Tuffy(8));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,70 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(280, 200);
$x = array();
for($i = 115; $i < 115 + 180; $i++) {
$x[] = cos($i / 25);
}
function format($value) {
return sprintf("%.1f", $value).' %';
}
$plot = new LinePlot($x);
$plot->setBackgroundColor(
new Color(240, 240, 240)
);
$plot->setPadding(40, 15, 15, 15);
$plot->setColor(
new Color(60, 60, 150)
);
$plot->setFillColor(
new Color(120, 175, 80, 47)
);
$plot->grid->setType(Line::DASHED);
$plot->yAxis->setLabelNumber(6);
$plot->yAxis->setLabelPrecision(1);
$plot->yAxis->setNumberByTick('minor', 'major', 1);
$plot->yAxis->label->setCallbackFunction('format');
$plot->yAxis->label->setFont(new Tuffy(7));
$plot->xAxis->setNumberByTick('minor', 'major', 3);
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->setLabelInterval(50);
$plot->xAxis->label->setFont(new Tuffy(7));
$plot->grid->setInterval(1, 50);
$graph->shadow->setSize(4);
$graph->shadow->setPosition(Shadow::RIGHT_BOTTOM);
$graph->shadow->smooth(TRUE);
$plot->label->set($x);
$plot->label->setInterval(25);
$plot->label->hideFirst(TRUE);
$plot->label->setPadding(1, 1, 1, 1);
$plot->label->setCallbackFunction('format');
$plot->label->setBackgroundColor(
new Color(227, 223, 241, 15)
);
$plot->label->setFont(new Tuffy(7));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,104 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
require_once "../../BarPlot.class.php";
$graph = new Graph(600, 250);
$graph->setBackgroundColor(new Color(0xF4, 0xF4, 0xF4));
$graph->shadow->setSize(3);
$graph->title->set("Evolution");
$graph->title->setFont(new Tuffy(15));
$graph->title->setColor(new Color(0x00, 0x00, 0x8B));
$group = new PlotGroup;
$group->setSize(0.82, 1);
$group->setCenter(0.41, 0.5);
$group->setPadding(35, 26, 40, 27);
$group->setSpace(2, 2);
$group->grid->setColor(new Color(0xC4, 0xC4, 0xC4));
$group->grid->setType(Line::DASHED);
$group->grid->hideVertical(TRUE);
$group->grid->setBackgroundColor(new White);
$group->axis->left->setColor(new DarkGreen);
$group->axis->left->label->setFont(new Font2);
$group->axis->right->setColor(new DarkBlue);
$group->axis->right->label->setFont(new Font2);
$group->axis->bottom->label->setFont(new Font2);
$group->legend->setPosition(1.18);
$group->legend->setTextFont(new Tuffy(8));
$group->legend->setSpace(10);
// Add a bar plot
$x = array(16, 16, 12, 13, 11, 18, 10, 12, 11, 12, 11, 16);
$plot = new BarPlot($x, 1, 2);
$plot->setBarColor(new MidYellow);
$plot->setBarPadding(0.15, 0.15);
$plot->barShadow->setSize(3);
$plot->barShadow->smooth(TRUE);
$plot->barShadow->setColor(new Color(200, 200, 200, 10));
$plot->move(1, 0);
$group->legend->add($plot, "Yellow bar", Legend::BACKGROUND);
$group->add($plot);
// Add a bar plot
$x = array(20, 25, 20, 18, 16, 25, 29, 12, 15, 18, 21, 26);
$plot = new BarPlot($x, 2, 2);
$plot->setBarColor(new Color(120, 175, 80, 10));
$plot->setBarPadding(0.15, 0.15);
$plot->barShadow->setSize(3);
$plot->barShadow->smooth(TRUE);
$plot->barShadow->setColor(new Color(200, 200, 200, 10));
$group->legend->add($plot, "Green bar", Legend::BACKGROUND);
$group->add($plot);
// Add a second bar plot
$x = array(12, 14, 10, 9, 10, 16, 12, 8, 8, 10, 12, 13);
$plot = new BarPlot($x, 2, 2);
$plot->setBarColor(new Orange);
$plot->setBarPadding(0.15, 0.15);
$group->legend->add($plot, "Orange bar", Legend::BACKGROUND);
$group->add($plot);
// Add a line plot
$x = array(6, 5, 6, 5.5, 4.5, 4, 4.5, 4, 5, 4, 5, 5.5);
$plot = new LinePlot($x, LinePlot::MIDDLE);
$plot->setColor(new DarkBlue);
$plot->setThickness(5);
$plot->setYAxis(Plot::RIGHT);
$plot->setYMax(12);
$plot->mark->setType(Mark::CIRCLE);
$plot->mark->setSize(6);
$plot->mark->setFill(new LightBlue);
$plot->mark->border->show();
$group->legend->add($plot, "Blue line", Legend::MARK);
$group->add($plot);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,58 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$x = array(
-4, -5, -2, -8, -3, 1, 4, 9, 5, 6, 2
);
$plot = new LinePlot($x);
$plot->setStyle(Line::DASHED);
$plot->setSpace(4, 4, 10, 0);
$plot->setPadding(25, 15, 10, 18);
$plot->setBackgroundGradient(
new LinearGradient(
new Color(230, 230, 230),
new Color(255, 255, 255),
90
)
);
$plot->setFilledArea(7, 9, new Red(25));
$plot->setFilledArea(1, 4, new Yellow(25));
$plot->setColor(new Color(0, 0, 150, 20));
$plot->grid->setColor(new VeryLightGray);
$plot->mark->setType(Mark::SQUARE);
$plot->mark->setSize(4);
$plot->mark->setFill(new VeryDarkGreen(30));
$plot->mark->border->show();
$plot->mark->border->setColor(new DarkBlue(60));
$plot->xAxis->label->hide(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 3);
$plot->yAxis->setLabelNumber(8);
$plot->legend->add($plot, "My line");
$plot->legend->setPosition(0.9, 0.77);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,70 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(300, 200);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup;
$group->grid->setType(Line::DASHED);
$group->setPadding(40, NULL, 20, NULL);
$group->axis->left->setLabelNumber(8);
$group->axis->left->setLabelPrecision(1);
$group->axis->left->setTickStyle(Tick::OUT);
$x = array(2, 4, 8, 16, 32, 48, 56, 60, 62);
$plot = new LinePlot($x);
$plot->setColor(new Orange());
$plot->setFillColor(new LightOrange(80));
$plot->mark->setType(Mark::CIRCLE);
$plot->mark->setFill(new MidRed);
$plot->mark->setSize(6);
$group->legend->add($plot, "John", Legend::MARK);
$group->add($plot);
$x = array(NULL, NULL, NULL, 10, 12, 14, 18, 26, 42);
$plot = new LinePlot($x);
$plot->setColor(new Color(120, 120, 30, 10));
$plot->setFillColor(new Color(120, 120, 60, 90));
$plot->mark->setType(Mark::SQUARE);
$plot->mark->setFill(new DarkGreen);
$plot->mark->setSize(5);
$group->add($plot);
function setYear($value) {
return $value + 2000;
}
$group->axis->bottom->label->setCallbackFunction('setYear');
function setK($value) {
return round($value).'K';
}
$group->axis->left->label->setCallbackFunction('setK');
$group->legend->add($plot, "George", Legend::MARK);
$group->legend->setPosition(0.45, 0.25);
$group->legend->shadow->smooth(TRUE);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,51 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(500, 100);
$graph->setAntiAliasing(TRUE);
$graph->border->hide();
$x = array();
for($i = 0; $i < 20; $i++) {
$x[] = mt_rand(4, 12);
}
$plot = new LinePlot($x);
$plot->setSpace(0, 0, 50, 0);
$plot->setPadding(3, 3, 3, 3);
$plot->setBackgroundGradient(
new LinearGradient(
new Color(230, 230, 230),
new Color(255, 255, 255),
0
)
);
$plot->setColor(new Color(0, 0, 180, 20));
$plot->setFillGradient(
new LinearGradient(
new Color(220, 220, 230, 25),
new Color(240, 240, 255, 25),
90
)
);
$plot->xAxis->hide(TRUE);
$plot->yAxis->hide(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,45 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../MathPlot.class.php";
$graph = new Graph(300, 300);
$plot = new MathPlot(-3, 3, 3, -3);
$plot->setInterval(0.2);
$plot->setPadding(NULL, NULL, NULL, 20);
$function = new MathFunction('cos');
$function->setColor(new DarkGreen);
$function->mark->setType(Mark::SQUARE);
$function->mark->setSize(3);
$plot->add($function, "f(x) = cos(x)", Legend::MARK);
$function = new MathFunction('exp');
$function->setColor(new DarkRed);
$function->mark->setType(Mark::SQUARE);
$function->mark->setSize(3);
$function->mark->setFill(new DarkBlue);
$plot->add($function, "f(x) = exp(x)", Legend::MARK);
function x2($x) {
return - $x * $x + 0.5;
}
$function = new MathFunction('x2');
$function->setColor(new DarkBlue);
$plot->add($function, "f(x) = - x * x + 0.5");
$plot->legend->setPosition(0.9, 0.8);
$plot->legend->setPadding(3, 3, 3, 3, 3);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,60 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$x = array(
0, 2, 5, 2, 3, 8
);
$plot = new LinePlot($x);
$plot->setXAxisZero(FALSE);
$plot->grid->setNobackground();
$plot->setSpace(6, 6, 10, 10);
$plot->setPadding(30, 6, 8, 18);
// Set a background gradient
$plot->setBackgroundGradient(
new LinearGradient(
new Color(210, 210, 210),
new Color(255, 255, 255),
0
)
);
// Change line color
$plot->setColor(new Color(0, 0, 150, 20));
// Set line background gradient
$plot->setFillGradient(
new LinearGradient(
new Color(150, 150, 210),
new Color(230, 230, 255),
0
)
);
// Change mark type
$plot->mark->setType(Mark::CIRCLE);
$plot->mark->border->show();
$plot->mark->setSize(6);
$plot->yAxis->setLabelPrecision(1);
$plot->yAxis->label->setFont(new Font1);
$plot->xAxis->label->setFont(new Font1);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,50 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$x = array(
1, 2, 5, 0.5, 3, 8, 7, 6, 2, -4
);
$plot = new LinePlot($x);
$plot->grid->setNobackground();
$plot->setPadding(20, 8, 8, 20);
$plot->setXAxisZero(FALSE);
// Set a background gradient
$plot->setBackgroundGradient(
new LinearGradient(
new Color(210, 210, 210),
new Color(255, 255, 255),
0
)
);
// Set semi-transparent background gradient
$plot->setFillGradient(
new LinearGradient(
new Color(230, 150, 150, 20),
new Color(230, 230, 180, 50),
90
)
);
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->label->hideLast(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 2);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,56 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(150, 100);
$x = array();
for($i = 0; $i < 8; $i++) {
$x[] = cos($i / 3 * M_PI) + mt_rand(-10, 10) / 40;
}
$plot = new LinePlot($x);
$plot->setPadding(22, 5, 25, 8);
// Hide grid
$plot->grid->setType(Line::DASHED);
// Change background color
$plot->setBackgroundColor(new Color(240, 240, 240, 50));
// Set Y on both left and rights sides
$plot->setYAxis(Plot::BOTH);
// Change line properties
$plot->setColor(new Color(0, 0, 0));
$plot->setFillColor(new Color(240, 190, 130, 50));
// Chenge ticks and labels interval
$plot->xAxis->setTickInterval(2);
$plot->xAxis->label->hide(TRUE);
$plot->xAxis->setNumberByTick('minor', 'major', 1);
// Hide first and last values on X axis
$plot->xAxis->label->hideFirst(TRUE);
$plot->xAxis->label->hideLast(TRUE);
// Add a title
$plot->title->set("Random values");
$plot->title->move(0, 2);
$plot->title->setFont(new Tuffy(8));
$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
$plot->title->border->show();
$plot->title->setPadding(2, 2, 2, 2);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,59 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$x = array(
1, 2, 5, 4, 2, 3
);
$plot = new LinePlot($x);
// Change component padding
$plot->setPadding(10, 12, 12, 7);
// Set a background gradient
$plot->setBackgroundGradient(
new LinearGradient(
new Color(230, 230, 230),
new Color(255, 255, 255),
0
)
);
// Change line background color
$plot->setFillGradient(
new LinearGradient(
new Color(200, 240, 215, 30),
new Color(150, 190, 165, 30),
0
)
);
// Hide grid
$plot->grid->hide(TRUE);
$plot->grid->setNobackground();
$plot->yAxis->label->hide(TRUE);
$plot->xAxis->label->hide(TRUE);
$plot->label->set($x);
$plot->label->setBackgroundColor(new Color(240, 240, 240, 10));
$plot->label->border->setColor(new Color(255, 0, 0, 15));
$plot->label->setPadding(3, 2, 0, 0);
$plot->label->setFont(new Font1);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,46 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$x = array();
for($i = 0; $i < 10; $i++) {
$x[] = mt_rand(1, 99) / 10;
}
$plot = new LinePlot($x);
$plot->setBackgroundColor(new Color(240, 240, 240));
$plot->setPadding(30, 8, 8, 20);
$plot->setColor(
new Color(60, 60, 150)
);
$plot->setFillGradient(
new LinearGradient(
new Color(120, 175, 80, 47),
new Color(231, 172, 113, 30),
0
)
);
$plot->grid->setType(Line::DASHED);
$plot->yAxis->setLabelNumber(2);
$plot->yAxis->setLabelPrecision(1);
$plot->xAxis->setLabelInterval(2);
$plot->xAxis->setNumberByTick('minor', 'major', 2);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,53 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
// Return a random color
function color($a = NULL) {
return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
function formatLabel($value) {
return sprintf("%.2f", $value);
}
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup;
$group->setXAxisZero(FALSE);
$group->setBackgroundColor(new Color(197, 180, 210, 80));
$group->setPadding(25, 10, 10, 20);
$group->axis->left->setLabelNumber(2);
$group->axis->left->setLabelPrecision(1);
// Display two lines
for($n = 0; $n < 2; $n++) {
$x = array();
for($i = 0; $i < 10; $i++) {
$x[] = (cos($i * M_PI / 5)) / ($n + 1);
}
$plot = new LinePlot($x);
$plot->setColor(color(10)); // Random line color
$plot->setFillColor(color(90)); // Random background color
$group->add($plot);
}
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,42 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../Pie.class.php";
$graph = new Graph(300, 175);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Stats");
$graph->title->setFont(new TuffyItalic(16));
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values, Pie::EARTH);
$plot->setCenter(0.4, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->explode(array(1 => 14, 4 => 20, 0 => 10));
$plot->setLegend(array(
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
));
$plot->legend->setPosition(1.3);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,50 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../Pie.class.php";
$graph = new Graph(300, 175);
$graph->setBackgroundGradient(
new LinearGradient(
new White,
new VeryLightGray(40),
0
)
);
$graph->title->set("Horses");
$graph->shadow->setSize(5);
$graph->shadow->smooth(TRUE);
$graph->shadow->setPosition(Shadow::LEFT_BOTTOM);
$graph->shadow->setColor(new DarkGray);
$values = array(8, 4, 6, 2, 5);
$plot = new Pie($values);
$plot->setCenter(0.35, 0.55);
$plot->setSize(0.7, 0.6);
$plot->set3D(10);
$plot->setLabelPosition(10);
$plot->setLegend(array(
'France',
'Spain',
'Italy',
'Germany',
'England'
));
$plot->legend->setPosition(1.40);
$plot->legend->shadow->setSize(0);
$plot->legend->setBackgroundColor(new VeryLightGray(30));
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,52 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../Pie.class.php";
$graph = new Graph(300, 175);
$graph->setAntiAliasing(TRUE);
$graph->title->set("Customized colors");
$graph->title->setFont(new Tuffy(12));
$graph->title->move(80, 10);
$values = array(16, 9, 13, 23);
$colors = array(
new LightOrange,
new LightPurple,
new LightBlue,
new LightRed,
new LightPink
);
$plot = new Pie($values, $colors);
$plot->setCenter(0.3, 0.53);
$plot->setAbsSize(200, 200);
$plot->setBorderColor(new White);
$plot->setStartAngle(234);
$plot->setLegend(array(
'Arthur',
'Abel',
'Pascal',
'Thamer'
));
$plot->setLabelPosition(-40);
$plot->label->setPadding(2, 2, 2, 2);
$plot->label->setFont(new Tuffy(7));
$plot->label->setBackgroundColor(new White(60));
$plot->legend->setPosition(1.38);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,53 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../Pie.class.php";
$graph = new Graph(300, 175);
$graph->setBackgroundGradient(
new LinearGradient(
new VeryLightGray(40),
new White,
90
)
);
$graph->title->set("Arbitrary labels");
$graph->title->setAngle(90);
$graph->title->move(120, NULL);
$values = array(8, 4, 6, 2, 5, 3, 4);
$plot = new Pie($values);
$plot->setCenter(0.45, 0.5);
$plot->setSize(0.55, 0.55 * 300 / 175);
$plot->label->set(array(
'Arthur', 'Abel', 'Bernard', 'Thierry', 'Paul', 'Gaston', 'Joe'
));
$plot->label->setCallbackFunction(NULL); // We must disable the default callback function
$plot->setLabelPosition(10);
$plot->setLegend(array(
'ABC',
'DEF',
'GHI',
'JKL',
'MNO',
'PQR',
'STU'
));
$plot->legend->hide(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,51 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../Pie.class.php";
function createPie($values, $title, $x, $y) {
$plot = new Pie($values, Pie::EARTH);
$plot->title->set($title);
$plot->title->setFont(new TuffyBold(9));
$plot->title->move(NULL, -12);
$plot->label->setFont(new Tuffy(7));
$plot->legend->hide(TRUE);
$plot->setLabelPosition(5);
$plot->setSize(0.48, 0.35);
$plot->setCenter($x, $y);
$plot->set3D(8);
$plot->setBorderColor(new White);
return $plot;
}
$graph = new Graph(280, 350);
$graph->setAntiAliasing(TRUE);
$plot = createPie(array(1, 4, 5, 2, 3), "Cowléoptère", 0.25, 0.24);
$graph->add($plot);
$plot = createPie(array(1, 9, 1, 2, 1), "Asticow", 0.75, 0.24);
$graph->add($plot);
$plot = createPie(array(5, 7, 8, 6, 3), "Cowlibri", 0.25, 0.65);
$graph->add($plot);
$plot = createPie(array(6, 4, 6, 5, 6), "Bourricow", 0.75, 0.65);
$plot->legend->setModel(Legend::MODEL_BOTTOM);
$plot->setLegend(array('plip', 'plop', 'plap', 'plup', 'plep'));
$plot->legend->hide(FALSE); // We print only one legend
$plot->legend->setPosition(0, 1.10);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,69 @@
<?php
require_once "../../ScatterPlot.class.php";
$graph = new Graph(280, 280);
$graph->title->move(-40, 0);
$graph->title->set('Two circles');
$group = new PlotGroup;
$group->setBackgroundGradient(
new LinearGradient(
new VeryLightGray,
new Color(245, 245, 245),
0
)
);
$group->setPadding(25, 20, 40, 15);
$group->setSpace(5, 5, 5, 5);
$group->legend->setPosition(0.82, 0.1);
$group->legend->setAlign(Legend::CENTER, Legend::MIDDLE);
function getCircle($size) {
$center = 0;
$x = array();
$y = array();
for($i = 0; $i <= 20; $i++) {
$rad = ($i / 20) * 2 * M_PI;
$x[] = $center + cos($rad) * $size;
$y[] = $center + sin($rad) * $size;
}
return array($x, $y);
}
list($x, $y) = getCircle(3);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkBlue);
$plot->mark->setFill(new DarkPink);
$plot->mark->setType(Mark::CIRCLE, 6);
$group->legend->add($plot, 'Circle #1', Legend::MARK);
$group->add($plot);
list($x, $y) = getCircle(5);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkGreen);
$plot->mark->setFill(new DarkOrange);
$plot->mark->setType(Mark::SQUARE, 4);
$group->legend->add($plot, 'Circle #2', Legend::MARK);
$group->add($plot);
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,30 @@
<?php
require_once "../../ScatterPlot.class.php";
$graph = new Graph(300, 240);
$graph->title->set('Simple ScatterPlot');
$graph->shadow->setSize(4);
$y = array(1, 1.3, 1.8, 1.6, 10, 7, 8, 3, 4, 2, 4);
$x = array(0.5, 0.7, 0.65, 0.9, 0.5, 1.5, 4, 3, 5, 2, 2);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new Color(255, 245, 220));
$plot->mark->setSize(15);
$plot->mark->setFill(
new RadialGradient(
new LightRed,
new Red
)
);
$plot->setSpace(6, 6, 6, 0);
$plot->setPadding(25, NULL, 40, 20);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,34 @@
<?php
require_once "../../ScatterPlot.class.php";
$graph = new Graph(300, 280);
$graph->title->set('Linked ScatterPlot');
$graph->title->setFont(new TuffyItalic(14));
$graph->shadow->setSize(4);
$y = array(1, 10, 7, 8, 5, 4, 2, 4);
$x = array(0.5, 0.5, 1.5, 4, 3, 5, 2, 2);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new Color(235, 235, 235));
$plot->mark->setSize(15);
$plot->mark->setFill(
new RadialGradient(
new LightGreen,
new DarkGreen
)
);
$plot->link(TRUE);
$plot->setColor(new DarkGreen);
$plot->setSpace(6, 6, 6, 0);
$plot->setPadding(25, NULL, 40, 20);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,69 @@
<?php
require_once "../../Graph.class.php";
$message = "Missing imageantialias() function.\nCheck your PHP installation.";
$message = wordwrap($message, 48, "\n", TRUE);
$width = 400;
$height = max(90, 50 + 13 * (substr_count($message, "\n") + 1));
$graph = new Graph($width, $height);
$driver = $graph->getDriver();
// Display title
$driver->filledRectangle(
new White,
new Line(
new Point(0, 0),
new Point($width, $height)
)
);
$driver->filledRectangle(
new Red,
new Line(
new Point(0, 0),
new Point(110, 25)
)
);
$text = new Text(
"Artichow error",
new Font3,
new White,
0
);
$driver->string($text, new Point(5, 6));
// Display red box
$driver->rectangle(
new Red,
new Line(
new Point(0, 25),
new Point($width - 90, $height - 1)
)
);
// Display error image
$image = new FileImage('error.png');
$driver->copyImage($image, new Point($width - 81, $height - 81), new Point($width - 1, $height - 1));
// Draw message
$text = new Text(
$message,
new Font2,
new Black,
0
);
$driver->string($text, new Point(10, 40));
$graph->draw();
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -0,0 +1,37 @@
<?php
require_once "../../Graph.class.php";
$graph = new Graph(400, 600);
$driver = $graph->getDriver();
$driver->filledRectangle(
new Red,
new Line(
new Point(200, 0),
new Point(200, 600)
)
);
$text = new Text(
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean gravida quam semper nibh. Sed orci. Aenean ullamcorper magna eget odio. Sed nonummy ante sit amet sapien.\nPhasellus nulla dui, aliquet vel, adipiscing vel, vulputate sed, velit.\nSed at neque vel ipsum commodo hendrerit.\nA. Nonyme",
new Tuffy(mt_rand(10, 15)),
new Color(mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)),
0
);
$driver->string($text, new Point(0, 0), 200);
$text = new Text(
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean gravida quam semper nibh. Sed orci. Aenean ullamcorper magna eget odio. Sed nonummy ante sit amet sapien.\nPhasellus nulla dui, aliquet vel, adipiscing vel, vulputate sed, velit.\nSed at neque vel ipsum commodo hendrerit.\nA. Nonyme",
new Font(mt_rand(2, 4)),
new Color(mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)),
0
);
$driver->string($text, new Point(0, 400), 200);
$graph->draw();
?>

View file

@ -0,0 +1,58 @@
<?php
require_once '../../BarPlot.class.php';
$graph = new Graph(600, 200);
$graph->setAntiAliasing(TRUE);
$values = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0);
$plot = new BarPlot($values);
$plot->setBarColor(
new Color(234, 236, 255)
);
$plot->setSpace(5, 5, NULL, NULL);
$plot->barShadow->setSize(3);
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
$plot->barShadow->setColor(new Color(180, 180, 180, 10));
$plot->barShadow->smooth(TRUE);
$mois = array ('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 'Juil', 'Août', 'Sept', 'Oct', 'Nov', 'Déc');
$label = array ();
foreach ($mois as $m) { $label []= $m; }
$label []= ' ';
foreach ($mois as $m) { $label []= $m; }
$plot->xAxis->setLabelText($label);
/* ICI */
$max = array_max($values);
$yValues = array();
for($i=0; $i<= $max; $i++) {
$yValues[]=$i;
}
$plot->yAxis->setLabelText($yValues);
// Image::drawError(var_export($yValues, TRUE));
$plot->yAxis->setLabelText($yValues);
$plot->setPadding(30,5,20,15);
$labelAvant = new Label("2005");
$labelAvant->setFont (new TTFFont(ARTICHOW_FONT.'/TuffyBold.ttf', 12));
$labelAvant->move (180,10);
$labelMaintenant = new Label("2006");
$labelMaintenant->setFont (new TTFFont(ARTICHOW_FONT.'/TuffyBold.ttf', 12));
$labelMaintenant->move (450,10);
$graph->add($plot);
$graph->addLabel($labelAvant, 0, 0);
$graph->addLabel($labelMaintenant, 0, 0);
$graph->draw();
?>

View file

@ -0,0 +1,5 @@
<form action="valid.php" method="get">
<img src="spam.php" style="vertical-align: middle"/>
<input type="text" name="code"/>
<input type="submit" value="Submit"/>
</form>

View file

@ -0,0 +1,18 @@
<?php
require_once '../../../AntiSpam.class.php';
// On créé l'image anti-spam
$object = new AntiSpam();
// La valeur affichée sur l'image fera 5 caractères
$object->setRand(5);
// On assigne un nom à cette image pour vérifier
// ultérieurement la valeur fournie par l'utilisateur
$object->save('example');
// On affiche l'image à l'écran
$object->draw();
?>

View file

@ -0,0 +1,11 @@
<?php
require_once "../../../AntiSpam.class.php";
$object = new AntiSpam();
if($object->check('example', $_GET['code'])) {
echo "Good value :-)";
} else {
echo "Bad value :-(";
}
?>

View file

@ -0,0 +1,47 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
$graph = new Graph(450, 400);
$graph->setAntiAliasing(TRUE);
$blue = new Color(0, 0, 200);
$red = new Color(200, 0, 0);
$group = new PlotGroup;
$group->setPadding(40, 40);
$group->setBackgroundColor(
new Color(240, 240, 240)
);
$values = array(12, 8, 20, 32, 15, 5);
$plot = new BarPlot($values, 1, 2);
$plot->setBarColor($blue);
$plot->setYAxis(Plot::LEFT);
$group->add($plot);
$group->axis->left->setColor($blue);
$group->axis->left->title->set("Blue bars");
$values = array(6, 12, 14, 2, 11, 7);
$plot = new BarPlot($values, 2, 2);
$plot->setBarColor($red);
$plot->setYAxis(Plot::RIGHT);
$group->add($plot);
$group->axis->right->setColor($red);
$group->axis->right->title->set("Red bars");
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,31 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
$graph = new Graph(400, 400);
$graph->setAntiAliasing(TRUE);
$values = array(19, 42, 15, -25, 3);
$plot = new BarPlot($values);
$plot->setBarColor(
new Color(250, 230, 180)
);
$plot->setSpace(5, 5, NULL, NULL);
$plot->barShadow->setSize(4);
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
$plot->barShadow->setColor(new Color(180, 180, 180, 10));
$plot->barShadow->smooth(TRUE);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,40 @@
<?php
require_once "../../Graph.class.php";
$graph = new Graph(400, 30);
$graph->border->hide();
$driver = $graph->getDriver();
for($i = 7; $i < 400; $i += 15) {
$driver->line(
new Color(0, 0, 0),
new Line(
new Point($i, 0),
new Point($i, 30)
)
);
}
for($i = 7; $i < 30; $i += 15) {
$driver->line(
new Color(0, 0, 0),
new Line(
new Point(0, $i),
new Point(400, $i)
)
);
}
$driver->filledRectangle(
new Color(0, 100, 200, 50),
new Line(
new Point(0, 0),
new Point(400, 30)
)
);
$graph->draw();
?>

View file

@ -0,0 +1,25 @@
<?php
require_once "../../Graph.class.php";
$graph = new Graph(400, 30);
$graph->border->hide();
$driver = $graph->getDriver();
$driver->filledRectangle(
new LinearGradient(
new Black,
new White,
0
),
new Line(
new Point(0, 0),
new Point(400, 30)
)
);
$graph->draw();
?>

View file

@ -0,0 +1,24 @@
<?php
require_once "../../Graph.class.php";
$graph = new Graph(250, 250);
$graph->border->hide();
$driver = $graph->getDriver();
$start = new Color(125, 250, 0);
$end = new Color(0, 125, 125);
// On dessine le dégradé radial dans un cercle
$driver->filledEllipse(
new RadialGradient(
$start,
$end
),
new Point(125, 125),
250, 250
);
$graph->draw();
?>

View file

@ -0,0 +1,50 @@
<?php
require_once "../../LinePlot.class.php";
$graph = new Graph(400, 300);
$graph->setAntiAliasing(TRUE);
$values = array(1, 7, 3, 2.5, 5, -4.5, -5);
$plot = new LinePlot($values);
$plot->setBackgroundColor(new Color(245, 245, 245));
$plot->hideLine(TRUE);
$plot->setFillColor(new Color(180, 180, 180, 75));
$plot->grid->setBackgroundColor(new Color(235, 235, 180, 60));
$plot->yAxis->setLabelPrecision(2);
$plot->yAxis->setLabelNumber(6);
$days = array(
'Lundi',
'Mardi',
'Mercredi',
'Jeudi',
'Vendredi',
'Samedi',
'Dimanche'
);
$plot->xAxis->setLabelText($days);
$plot->setSpace(6, 6, 10, 10);
$plot->mark->setType(Mark::IMAGE);
$plot->mark->setImage(new FileImage("smiley.png"));
$plot->label->set($values);
$plot->label->move(0, -23);
$plot->label->setBackgroundGradient(
new LinearGradient(
new Color(250, 250, 250, 10),
new Color(255, 200, 200, 30),
0
)
);
$plot->label->border->setColor(new Color(20, 20, 20, 20));
$plot->label->setPadding(3, 1, 1, 0);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,49 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../LinePlot.class.php";
$graph = new Graph(450, 400);
$graph->setAntiAliasing(TRUE);
$blue = new Color(0, 0, 200);
$red = new Color(200, 0, 0);
$group = new PlotGroup;
$group->setBackgroundColor(
new Color(240, 240, 240)
);
$group->setPadding(40, 40);
$values = array(12, 5, 20, 32, 15, 4, 16);
$plot = new LinePlot($values);
$plot->setColor($blue);
$plot->setYAxis(Plot::LEFT);
$group->add($plot);
$group->axis->left->setColor($blue);
$group->axis->left->title->set("Blue line");
$values = array(6, 12, 14, 2, 11, 5, 21);
$plot = new LinePlot($values);
$plot->setColor($red);
$plot->setYAxis(Plot::RIGHT);
$group->add($plot);
$group->axis->right->setColor($red);
$group->axis->right->title->set("Red line");
$graph->add($group);
$graph->draw();
?>

View file

@ -0,0 +1,22 @@
<?php
require_once "../../LinePlot.class.php";
$graph = new Graph(400, 400);
$graph->setAntiAliasing(FALSE);
$values = array(1, 4, 5, -2.5, 3);
$plot = new LinePlot($values);
$plot->setBackgroundGradient(
new LinearGradient(
new Color(210, 210, 210),
new Color(250, 250, 250),
0
)
);
$plot->yAxis->setLabelPrecision(1);
$plot->setSpace(5, 5, NULL, NULL);
$graph->add($plot);
$graph->draw();
?>

View file

@ -0,0 +1,47 @@
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../BarPlot.class.php";
require_once "../../LinePlot.class.php";
$graph = new Graph(450, 400);
$graph->setAntiAliasing(TRUE);
$blue = new Color(150, 150, 230, 50);
$red = new Color(240, 50, 50, 25);
$group = new PlotGroup;
$group->setSpace(5, 5, 5, 0);
$group->setBackgroundColor(
new Color(240, 240, 240)
);
$values = array(18, 12, 14, 21, 11, 7, 9, 16, 7, 23);
$plot = new BarPlot($values);
$plot->setBarColor($red);
$group->add($plot);
$values = array(12, 8, 6, 12, 7, 5, 4, 9, 3, 12);
$plot = new LinePlot($values, LinePlot::MIDDLE);
$plot->setFillColor($blue);
$plot->mark->setType(Mark::SQUARE);
$plot->mark->setSize(7);
$plot->mark->setFill(new Color(255, 255, 255));
$plot->mark->border->show();
$group->add($plot);
$graph->add($group);
$graph->draw();
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B