| 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(400, 400);
|
|
|
13 |
|
|
|
14 |
// Set a title to the graph
|
|
|
15 |
$graph->title->set('The title');
|
|
|
16 |
|
|
|
17 |
// Change graph background color
|
|
|
18 |
$graph->setBackgroundColor(new Color(230, 230, 230));
|
|
|
19 |
|
|
|
20 |
$values = array(8, 2, 6, 1, 3, 5);
|
|
|
21 |
|
|
|
22 |
// Declare a new BarPlot
|
|
|
23 |
$plot = new BarPlot($values);
|
|
|
24 |
|
|
|
25 |
// Reduce padding around the plot
|
|
|
26 |
$plot->setPadding(NULL, NULL, NULL, 20);
|
|
|
27 |
|
|
|
28 |
// Reduce plot size and move it to the bottom of the graph
|
|
|
29 |
$plot->setSize(1, 0.96);
|
|
|
30 |
$plot->setCenter(0.5, 0.52);
|
|
|
31 |
|
|
|
32 |
// Set a background color to the plot
|
|
|
33 |
$plot->grid->setBackgroundColor(new White);
|
|
|
34 |
// Set a dashed grid
|
|
|
35 |
$plot->grid->setType(Line::DASHED);
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
$plot->label->set($values);
|
|
|
39 |
$plot->label->move(0, -10);
|
|
|
40 |
$plot->label->setColor(new DarkBlue);
|
|
|
41 |
|
|
|
42 |
// Set a shadow to the bars
|
|
|
43 |
$plot->barShadow->setSize(2);
|
|
|
44 |
|
|
|
45 |
// Bar size is at 60%
|
|
|
46 |
$plot->setBarSize(0.6);
|
|
|
47 |
|
|
|
48 |
// Change the color of the bars
|
|
|
49 |
$plot->setBarColor(
|
|
|
50 |
new Orange(15)
|
|
|
51 |
);
|
|
|
52 |
|
|
|
53 |
// Add the plot to the graph
|
|
|
54 |
$graph->add($plot);
|
|
|
55 |
|
|
|
56 |
// Draw the graph
|
|
|
57 |
$graph->draw();
|
|
|
58 |
|
|
|
59 |
?>
|