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 |
$graph = new Graph(300, 200);
|
|
|
13 |
|
|
|
14 |
$graph->setAntiAliasing(TRUE);
|
|
|
15 |
$graph->border->hide();
|
|
|
16 |
|
|
|
17 |
$group = new PlotGroup;
|
|
|
18 |
$group->grid->hide(TRUE);
|
|
|
19 |
$group->setSpace(2, 2, 20, 0);
|
|
|
20 |
$group->setPadding(30, 10, NULL, NULL);
|
|
|
21 |
|
|
|
22 |
$colors = array(
|
|
|
23 |
new Orange(25),
|
|
|
24 |
new LightBlue(10)
|
|
|
25 |
);
|
|
|
26 |
|
|
|
27 |
for($n = 0; $n < 2; $n++) {
|
|
|
28 |
|
|
|
29 |
$x = array();
|
|
|
30 |
|
|
|
31 |
for($i = 0; $i < 3 - $n * 3; $i++) {
|
|
|
32 |
$x[] = NULL;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
for($i = 3 - ($n * 3); $i < 12 - ($n * 3); $i++) {
|
|
|
36 |
$x[] = cos($i * M_PI / 100) * mt_rand(800, 1200) / 1000 * (((1 - $n) * 5 + 10) / 10);
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
for($i = 0; $i < $n * 3; $i++) {
|
|
|
40 |
$x[] = NULL;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
$plot = new BarPlot($x, 1, 1, (1 - $n) * 6);
|
|
|
44 |
|
|
|
45 |
// $plot->setBarPadding(2, 2);
|
|
|
46 |
|
|
|
47 |
$plot->barShadow->setSize(2);
|
|
|
48 |
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
|
|
|
49 |
$plot->barShadow->setColor(new Color(160, 160, 160, 10));
|
|
|
50 |
$plot->barShadow->smooth(TRUE);
|
|
|
51 |
|
|
|
52 |
$plot->setBarColor($colors[$n]);
|
|
|
53 |
|
|
|
54 |
$group->add($plot);
|
|
|
55 |
$group->legend->add($plot, $n + date('Y'), Legend::BACKGROUND);
|
|
|
56 |
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
function setPc($value) {
|
|
|
60 |
return round($value * 10).'%';
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
$group->axis->left->label->setCallbackFunction('setPc');
|
|
|
64 |
|
|
|
65 |
$months = array(
|
|
|
66 |
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
|
|
|
67 |
);
|
|
|
68 |
|
|
|
69 |
$group->axis->bottom->setLabelText($months);
|
|
|
70 |
$group->axis->bottom->hideTicks(TRUE);
|
|
|
71 |
|
|
|
72 |
$group->legend->shadow->setSize(0);
|
|
|
73 |
$group->legend->setAlign(Legend::CENTER);
|
|
|
74 |
$group->legend->setSpace(6);
|
|
|
75 |
$group->legend->setTextFont(new Tuffy(8));
|
|
|
76 |
$group->legend->setPosition(0.50, 0.10);
|
|
|
77 |
$group->legend->setBackgroundColor(new Color(255, 255, 255, 25));
|
|
|
78 |
$group->legend->setColumns(2);
|
|
|
79 |
|
|
|
80 |
$graph->add($group);
|
|
|
81 |
$graph->draw();
|
|
|
82 |
?>
|