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(450, 400);
22
$graph->setAntiAliasing(TRUE);
23
$graph->title->set("Some lines");
24
 
25
$group = new PlotGroup;
26
$group->setXAxisZero(FALSE);
27
$group->setBackgroundColor(new Color(197, 180, 210, 80));
28
 
29
$group->setPadding(40, NULL, 50, NULL);
30
 
31
$group->axis->left->setLabelNumber(8);
32
$group->axis->left->setLabelPrecision(1);
33
$group->axis->left->setTickStyle(Tick::OUT);
34
 
35
$group->axis->bottom->setTickStyle(Tick::OUT);
36
 
37
// Display two lines
38
for($n = 0; $n < 2; $n++) {
39
 
40
	$x = array();
41
 
42
	for($i = 0; $i < 10; $i++) {
43
		$x[] = (cos($i * M_PI / 5)) / ($n + 1);
44
	}
45
 
46
	$plot = new LinePlot($x);
47
	$plot->setColor(color(10)); // Random line color
48
	$plot->setFillColor(color(90)); // Random background color
49
 
50
	$plot->label->set($x);
51
	$plot->label->setBackgroundColor(new Color(220, 234, 230, 25));
52
	$plot->label->setPadding(1, 0, 0, 0);
53
	$plot->label->setCallbackFunction("formatLabel");
54
	$plot->label->setInterval(2);
55
 
56
	$group->add($plot);
57
	$group->legend->add($plot, "Line #".($n + 1), Legend::LINE);
58
 
59
}
60
 
61
$group->legend->setSpace(12);
62
$group->legend->setBackgroundColor(new Color(255, 255, 255));
63
$group->setPadding(NULL, 100, NULL, NULL);
64
 
65
$graph->add($group);
66
$graph->draw();
67
?>