Source for file LinePlot.class.php
Documentation is available at LinePlot.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
* Add marks to your line plot
* Labels on your line plot
* Construct a new awLinePlot
* @param array $values Some numeric values for Y axis
public function __construct($values, $mode = awLinePlot::LINE) {
* @param int $start Begining of the area
* @param int $end End of the area
* @param mixed $background Background color or gradient of the area
awImage::drawError("Class LinePlot: End position can not be greater than begin position in setFilledArea().");
$this->areas[] = array((int) $start, (int) $stop, $background);
public function setColor(awColor $color) {
* 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) {
// Get start and stop values
list ($start, $stop) = $this->getLimit();
$inc = $this->xAxis->getDistance(0, 1) / 2;
for($key = $start; $key <= $stop; $key++ ) {
$value = $this->datay[$key];
$backgroundPolygon->append($p);
foreach($polygon->all() as $point) {
$backgroundPolygon->append(clone $point);
$backgroundPolygon->append($p);
// Draw polygon background
foreach($polygon->all() as $point) {
foreach($polygon->all() as $key => $point) {
$this->mark->draw($driver, $point);
$this->label->draw($driver, $point, $key);
protected function drawArea(awDriver $driver, awPolygon $polygon) {
foreach($this->areas as $area) {
foreach($this->areas as $area) {
list ($start, $stop, $background) = $area;
$polygonArea->append($p);
for($i = $start; $i <= $stop; $i++ ) {
$p = clone $polygon->get($i);
$polygonArea->append($p);
$polygonArea->append($p);
$driver->filledPolygon($background, $polygonArea);
* Useful to draw simple horizontal lines
* @package linea21.externals
* Construct a new awLinePlot
* @param float $value A Y value
* @param int $start Line start index
* @param int $stop Line stop index
* @param int $mode Line mode
public function __construct($value, $start, $stop, $mode = awLinePlot::LINE) {
public function setColor(awColor $color) {
public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
$inc = $this->xAxis->getDistance(0, 1) / 2;
|