Subversion Repositories Applications.gtt

Rev

Rev 61 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
60 jpm 1
<?php
2
/*
3
 * This work is hereby released into the Public Domain.
4
 * To view a copy of the public domain dedication,
5
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
6
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
7
 *
8
 */
9
 
10
require_once "../../LinePlot.class.php";
11
 
12
// Return a random color
13
function color($a = NULL) {
14
	return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
15
}
16
 
17
function formatLabel($value) {
18
	return sprintf("%.2f", $value);
19
}
20
 
21
$graph = new Graph(150, 100);
22
 
23
$graph->setAntiAliasing(TRUE);
24
 
25
$group = new PlotGroup;
26
$group->setXAxisZero(FALSE);
27
$group->setBackgroundColor(new Color(197, 180, 210, 80));
28
 
29
$group->setPadding(25, 10, 10, 20);
30
 
31
$group->axis->left->setLabelNumber(2);
32
$group->axis->left->setLabelPrecision(1);
33
 
34
// Display two lines
35
for($n = 0; $n < 2; $n++) {
36
 
37
	$x = array();
38
 
39
	for($i = 0; $i < 10; $i++) {
40
		$x[] = (cos($i * M_PI / 5)) / ($n + 1);
41
	}
42
 
43
	$plot = new LinePlot($x);
44
	$plot->setColor(color(10)); // Random line color
45
	$plot->setFillColor(color(90)); // Random background color
46
 
47
	$group->add($plot);
48
 
49
}
50
 
51
$graph->add($group);
52
$graph->draw();
53
?>