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