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(280, 280);
|
|
|
13 |
|
|
|
14 |
$graph->setAntiAliasing(TRUE);
|
|
|
15 |
|
|
|
16 |
$group = new PlotGroup;
|
|
|
17 |
$group->setSpace(6, 6, 5, 5);
|
|
|
18 |
$group->setBackgroundGradient(
|
|
|
19 |
new LinearGradient(
|
|
|
20 |
new Color(235, 235, 235),
|
|
|
21 |
new White(),
|
|
|
22 |
|
|
|
23 |
)
|
|
|
24 |
);
|
|
|
25 |
$group->setPadding(40, 10, 10, 50);
|
|
|
26 |
|
|
|
27 |
$group->axis->left->setLabelPrecision(2);
|
|
|
28 |
$group->axis->bottom->label->hide(TRUE);
|
|
|
29 |
$group->axis->bottom->hideTicks(TRUE);
|
|
|
30 |
|
|
|
31 |
$group->grid->setType(Line::DASHED);
|
|
|
32 |
$group->grid->hideHorizontal(TRUE);
|
|
|
33 |
|
|
|
34 |
$gradients = array(
|
|
|
35 |
new LinearGradient(
|
|
|
36 |
new Color(30, 30, 160, 10), new Color(120, 120, 160, 10), 0
|
|
|
37 |
),
|
|
|
38 |
new LinearGradient(
|
|
|
39 |
new Color(30, 160, 30, 10), new Color(120, 160, 120, 10), 0
|
|
|
40 |
),
|
|
|
41 |
new LinearGradient(
|
|
|
42 |
new Color(160, 30, 30, 10), new Color(160, 120, 120, 10), 0
|
|
|
43 |
)
|
|
|
44 |
);
|
|
|
45 |
|
|
|
46 |
for($n = 0; $n < 3; $n++) {
|
|
|
47 |
|
|
|
48 |
$x = array();
|
|
|
49 |
|
|
|
50 |
for($i = 0; $i < 6; $i++) {
|
|
|
51 |
$x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 900) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
$plot = new BarPlot($x, $n + 1, 3);
|
|
|
55 |
|
|
|
56 |
$plot->setXAxis(Plot::BOTTOM);
|
|
|
57 |
|
|
|
58 |
$plot->barShadow->setSize(1);
|
|
|
59 |
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
|
|
|
60 |
$plot->barShadow->setColor(new Color(160, 160, 160, 10));
|
|
|
61 |
|
|
|
62 |
$plot->barBorder->setColor($gradients[$n]->from);
|
|
|
63 |
|
|
|
64 |
$plot->setBarGradient($gradients[$n]);
|
|
|
65 |
|
|
|
66 |
$plot->setBarSpace(2);
|
|
|
67 |
|
|
|
68 |
$group->legend->add($plot, 'Bar#'.($n + 1), Legend::BACKGROUND);
|
|
|
69 |
|
|
|
70 |
$group->add($plot);
|
|
|
71 |
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
$group->legend->setModel(Legend::MODEL_BOTTOM);
|
|
|
75 |
$group->legend->setPosition(NULL, 0.86);
|
|
|
76 |
$group->legend->shadow->hide();
|
|
|
77 |
|
|
|
78 |
$graph->add($group);
|
|
|
79 |
$graph->draw();
|
|
|
80 |
?>
|