1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
require_once 'Horde/Graph/Plot/bar.php';
/**
* Grouped bar graph implementation for the Horde_Graph package.
*
* $Horde: framework/Graph/Graph/Plot/bargrouped.php,v 1.1.10.4 2006/01/01 21:28:18 jan Exp $
*
* Copyright 2002-2006 Chuck Hagenbuch <chuck@horde.org>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @since Horde 3.0
* @package Horde_Graph
*/
class Horde_Graph_Plot_bargrouped extends Horde_Graph_Plot_bar {
var $_step = .5;
var $_colors = array();
var $_datasets = array();
function draw()
{
// Calculate the starting offset for each bar, from which we
// move it over by $this->_step.
$datasets = count($this->_datasets);
$globalOffset = $this->_offset - (($this->_step * ($datasets - 1)) / 2);
for ($i = 0; $i < $datasets; $i++) {
// Calculate the offset of this set of bars.
$this->_offset = $globalOffset + ($this->_step * $i);
// Set bar parameters that change per-group.
if (isset($this->_colors[$i])) {
$this->_color = $this->_colors[$i];
}
$this->_dataset = $this->_datasets[$i];
// Draw this dataset.
parent::draw();
}
}
}
|