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 color($a = NULL) {
|
|
|
13 |
if($a === NULL) {
|
|
|
14 |
$a = 0;
|
|
|
15 |
}
|
|
|
16 |
return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
$graph = new Graph(300, 200);
|
|
|
20 |
|
|
|
21 |
$graph->setAntiAliasing(TRUE);
|
|
|
22 |
$graph->border->hide();
|
|
|
23 |
|
|
|
24 |
$group = new PlotGroup;
|
|
|
25 |
$group->setSpace(5, 10, 20, 15);
|
|
|
26 |
$group->setPadding(40, 10, NULL, 20);
|
|
|
27 |
$group->setXAxisZero(FALSE);
|
|
|
28 |
|
|
|
29 |
$group->axis->left->setLabelPrecision(2);
|
|
|
30 |
|
|
|
31 |
$colors = array(
|
|
|
32 |
new Color(100, 180, 154, 12),
|
|
|
33 |
new Color(100, 154, 180, 12),
|
|
|
34 |
new Color(154, 100, 180, 12),
|
|
|
35 |
new Color(180, 100, 154, 12)
|
|
|
36 |
);
|
|
|
37 |
|
|
|
38 |
for($n = 0; $n < 4; $n++) {
|
|
|
39 |
|
|
|
40 |
$x = array();
|
|
|
41 |
|
|
|
42 |
for($i = 0; $i < 6; $i++) {
|
|
|
43 |
$x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 1400) / 1000 - 0.5);
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
$plot = new BarPlot($x, 1, 1, (3 - $n) * 7);
|
|
|
47 |
$plot->barBorder->setColor(new Color(0, 0, 0));
|
|
|
48 |
|
|
|
49 |
$plot->setBarSize(0.54);
|
|
|
50 |
|
|
|
51 |
$plot->barShadow->setSize(3);
|
|
|
52 |
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
|
|
|
53 |
$plot->barShadow->setColor(new Color(160, 160, 160, 10));
|
|
|
54 |
$plot->barShadow->smooth(TRUE);
|
|
|
55 |
|
|
|
56 |
$plot->setBarColor($colors[$n]);
|
|
|
57 |
|
|
|
58 |
$group->add($plot);
|
|
|
59 |
$group->legend->add($plot, "Barre #".$n, Legend::BACKGROUND);
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
$group->legend->shadow->setSize(0);
|
|
|
64 |
$group->legend->setAlign(Legend::CENTER);
|
|
|
65 |
$group->legend->setSpace(6);
|
|
|
66 |
$group->legend->setTextFont(new Tuffy(8));
|
|
|
67 |
$group->legend->setPosition(0.50, 0.12);
|
|
|
68 |
$group->legend->setBackgroundColor(new Color(255, 255, 255, 25));
|
|
|
69 |
$group->legend->setColumns(2);
|
|
|
70 |
|
|
|
71 |
$graph->add($group);
|
|
|
72 |
$graph->draw();
|
|
|
73 |
?>
|