Subversion Repositories Applications.gtt

Rev

Rev 60 | 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 "../../BarPlot.class.php";
11
 
12
function labelFormat($value) {
13
	return round($value, 2);
14
}
15
 
16
$graph = new Graph(280, 200);
17
 
18
$graph->setAntiAliasing(TRUE);
19
 
20
$group = new PlotGroup;
21
$group->setSpace(5, 5, 15, 0);
22
$group->setPadding(40, 40);
23
 
24
$group->axis->left->setLabelPrecision(2);
25
$group->axis->right->setLabelPrecision(2);
26
 
27
$colors = array(
28
	new Color(80, 105, 190, 10),
29
	new Color(105, 190, 80, 10)
30
);
31
 
32
$darkColor = array(
33
	new Color(40, 55, 120, 10),
34
	new Color(55, 120, 40, 10)
35
);
36
 
37
$axis = array(
38
	Plot::LEFT,
39
	Plot::RIGHT
40
);
41
 
42
$group->axis->left->setColor($darkColor[0]);
43
$group->axis->left->label->setColor($darkColor[0]);
44
$group->axis->right->setColor($darkColor[1]);
45
$group->axis->right->label->setColor($darkColor[1]);
46
 
47
$group->setBackgroundGradient(
48
	new LinearGradient(
49
		new Color(225, 225, 225),
50
		new Color(255, 255, 255),
51
 
52
	)
53
);
54
 
55
for($n = 0; $n < 2; $n++) {
56
 
57
	$x = array();
58
 
59
	for($i = 0; $i < 4; $i++) {
60
		$x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0) + 1;
61
	}
62
 
63
	$plot = new BarPlot($x, $n+1, 2);
64
	$plot->barBorder->setColor(new Color(0, 0, 0, 30));
65
 
66
	$plot->setBarPadding(0.1, 0.1);
67
	$plot->setBarSpace(5);
68
 
69
	$plot->barShadow->setSize(3);
70
	$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
71
	$plot->barShadow->setColor(new Color(180, 180, 180, 10));
72
	$plot->barShadow->smooth(TRUE);
73
 
74
	$plot->label->set($x);
75
	$plot->label->move(0, -6);
76
	$plot->label->setFont(new Tuffy(7));
77
	$plot->label->setAngle(90);
78
	$plot->label->setAlign(NULL, Label::TOP);
79
	$plot->label->setPadding(3, 1, 0, 6);
80
	$plot->label->setCallbackFunction("labelFormat");
81
 
82
	$plot->setBarColor($colors[$n]);
83
 
84
	$plot->setYAxis($axis[$n]);
85
 
86
	$group->add($plot);
87
 
88
}
89
 
90
$graph->add($group);
91
$graph->draw();
92
?>