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
 
13
$graph = new Graph(150, 100);
14
 
15
$x = array();
16
 
17
for($i = 0; $i < 8; $i++) {
18
	$x[] = cos($i / 3 * M_PI) + mt_rand(-10, 10) / 40;
19
}
20
 
21
$plot = new LinePlot($x);
22
$plot->setPadding(22, 5, 25, 8);
23
 
24
// Hide grid
25
$plot->grid->setType(Line::DASHED);
26
 
27
// Change background color
28
$plot->setBackgroundColor(new Color(240, 240, 240, 50));
29
 
30
// Set Y on both left and rights sides
31
$plot->setYAxis(Plot::BOTH);
32
 
33
// Change line properties
34
$plot->setColor(new Color(0, 0, 0));
35
$plot->setFillColor(new Color(240, 190, 130, 50));
36
 
37
// Chenge ticks and labels interval
38
$plot->xAxis->setTickInterval(2);
39
$plot->xAxis->label->hide(TRUE);
40
$plot->xAxis->setNumberByTick('minor', 'major', 1);
41
 
42
// Hide first and last values on X axis
43
$plot->xAxis->label->hideFirst(TRUE);
44
$plot->xAxis->label->hideLast(TRUE);
45
 
46
// Add a title
47
$plot->title->set("Random values");
48
$plot->title->move(0, 2);
49
$plot->title->setFont(new Tuffy(8));
50
$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
51
$plot->title->border->show();
52
$plot->title->setPadding(2, 2, 2, 2);
53
 
54
$graph->add($plot);
55
$graph->draw();
56
?>