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
require_once "../ScatterPlot.class.php";
4
 
5
$graph = new Graph(400, 400);
6
 
7
$group = new PlotGroup;
8
 
9
$group->setBackgroundColor(new VeryLightGray);
10
$group->setPadding(30, 30, 30, 30);
11
$group->setSpace(5, 5, 5, 5);
12
 
13
$group->legend->setPosition(0.5, 0.62);
14
$group->legend->setAlign(Legend::CENTER, Legend::MIDDLE);
15
 
16
function getCircle($size) {
17
 
18
	$center = 0;
19
 
20
	$x = array();
21
	$y = array();
22
 
23
	for($i = 0; $i <= 30; $i++) {
24
		$rad = ($i / 30) * 2 * M_PI;
25
		$x[] = $center + cos($rad) * $size;
26
		$y[] = $center + sin($rad) * $size;
27
	}
28
 
29
	return array($x, $y);
30
 
31
}
32
 
33
list($x, $y) = getCircle(3);
34
 
35
$plot = new ScatterPlot($y, $x);
36
 
37
$plot->link(TRUE, new DarkBlue);
38
 
39
$plot->mark->setFill(new DarkPink);
40
$plot->mark->setType(Mark::CIRCLE, 6);
41
 
42
$group->legend->add($plot, 'Circle #1', Legend::MARK);
43
$group->add($plot);
44
 
45
list($x, $y) = getCircle(5);
46
 
47
$plot = new ScatterPlot($y, $x);
48
 
49
$plot->link(TRUE, new DarkGreen);
50
 
51
$plot->mark->setFill(new DarkOrange);
52
$plot->mark->setType(Mark::SQUARE, 4);
53
 
54
$group->legend->add($plot, 'Circle #2', Legend::MARK);
55
$group->add($plot);
56
 
57
$graph->add($group);
58
$graph->draw();
59
 
60
?>