Source for file BarPlot.class.php
Documentation is available at BarPlot.class.php
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
require_once dirname(__FILE__ ). "/Plot.class.php";
* @package linea21.externals
* Labels on your bar plot
* Construct a new awBarPlot
* @param array $values Some numeric values for Y axis
* @param int $identifier Plot identifier
* @param int $number Bar plot number
* @param int $depth Bar plot depth in pixels
public function __construct($values, $identifier = 1, $number = 1, $depth = 0) {
$this->depth = (int) $depth;
$this->grid->hideVertical(TRUE);
* This method is not compatible with awBarPlot::setBarPadding()
* @param float $left Left padding (between 0 and 1)
* @param float $right Right padding (between 0 and 1)
* This method is not compatible with awBarPlot::setBarPadding()
* @param int $width Bars size (between 0 and 1)
$padding = (1 - $size) / 2;
public function move($x, $y) {
$this->move->set($x, NULL, $y, NULL);
* @param int $space Space in pixels
* Change line background color
* Change line background gradient
* @param awGradient $gradient
* Get the background color or gradient of an element of the component
* @return Color, Gradient
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
if($this->xAxisZero and $min <= 0 and $max >= 0) {
// Distance between two values on the graph
$distance = $this->xAxis->getDistance(0, 1);
$leftPadding = $this->barPadding->left * $distance;
$rightPadding = $this->barPadding->right * $distance;
$padding = $leftPadding + $rightPadding;
$barSize = ($distance - $padding - $space) / $this->number;
$barPosition = $leftPadding + $barSize * ($this->identifier - 1);
for($key = 0; $key < $count; $key++ ) {
$value = $this->datay[$key];
$barStop = $barStart + $barSize;
$t1 = min($zero->y, $position->y);
$t2 = max($zero->y, $position->y);
if(round($t2 - $t1) == 0) {
foreach($this->datay as $key => $value) {
$position->y - $this->depth
$this->label->draw($driver, $point, $key);
// ça bidouille à fond ici !
protected function drawBar(awDriver $driver, awPoint $p1, awPoint $p2) {
if(abs($p2->y - $p1->y) > 1) {
$b1 = $p1->move($size, $size);
$b2 = $p2->move(- 1 * $size, - 1 * $size);
$driver->filledRectangle(
|