Source for file Gantt.php
Documentation is available at Gantt.php
* Description: Gantt Series
* @copyright Copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
private static $NUMGANTTSAMPLES = 10;
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
* Creates a new Gantt series.
public function Gantt($c = null)
$this->vxValues->setName("ValuesGanttStart");// TODO $this->Language->getString("ValuesGanttStart");
$tmpColor = new Color(0, 0, 0);// Black
$this->endValues = new ValueList($this, "ValuesGanttEnd"/*$this->Language->getString("ValuesGanttEnd")*/);
$this->endValues->setDateTime(true);
$this->nextTask = new ValueList($this, "ValuesGanttNextTask"/*$this->Language->getString("ValuesGanttNextTask")*/);
* Defines the starting Gantt bar date values.<br>
* The ending Gantt bar point date is stored at TGanttSeries.EndValues.<br>
* StartValues and EndValues can be specified both as DateTime or double
* Both are standard TChartValueList components. That means you can access
* their values with same methods as you can access X or Y values.<br>
* The TGanttSeries.Add method must be used to add Gantt bar points. <br>
* Defines the ending Gantt bar date value.<br>
* The starting Gantt bar point is stored at TGanttSeries.StartValues<br>
* StartValues and EndValues can be specified both as DateTime or double
* Both are standard TChartValueList components. That means you can access
* their values with same methods as you can access X or Y values. <br>
* The TGanttSeries.Add method must be used to add Gantt bar points. <br>
* Holds the Gantt bar index each Gantt bar is connected to. <br>
* When a Gantt bar is added to TGanttSeries, it's NextTask value is
* assigned to -1 by default. That means the Gantt bar is NOT connected
* to any other Gantt Bar. <br>
* You need to set a valid bar index to NextTask. <br>
private function ganttSampleStr($index)
return "GanttSample1";//$this->Language->getString("GanttSample1");
return "GanttSample2";//$this->Language->getString("GanttSample2");
return "GanttSample3";//$this->Language->getString("GanttSample3");
return "GanttSample4";//$this->Language->getString("GanttSample4");
return "GanttSample5";//$this->Language->getString("GanttSample5");
return "GanttSample6";//$this->Language->getString("GanttSample6");
return "GanttSample7";//$this->Language->getString("GanttSample7");
return "GanttSample8";//$this->Language->getString("GanttSample8");
return "GanttSample9";//$this->Language->getString("GanttSample9");
return "GanttSample1";//$this->Language->getString("GanttSample1");
* Adds random values to series.
// some sample values to see something at design mode
for($t = 0; $t <= min($numValues, self::$NUMGANTTSAMPLES + MathUtils::round(20 * $r->Random())); $t++ )
$tmpStartTask = gettimeofday(true) + $t * 3 + 5 * $r->Random();
$tmpEndTask = $tmpStartTask + 9 + 16 * $r->Random();
$addedGantt = $this->addGantt($tmpStartTask,
$this->ganttSampleStr($tmpY)
for($tt = 0; $tt < $addedGantt; $tt++ )
if(($this->nextTask->value[$tt] == - 1) && ($tmpStartTask > $this->endValues->value[$tt]))
$this->nextTask->value[$tt] = $addedGantt;
* Determines the pen to draw the optional lines that connect Gantt
* Called internally. Draws the "ValueIndex" point of the Series.
// This overrided method is the main paint method for Gantt bar points.
if($this->point->getVisible())
$this->point->prepareCanvas($this->chart->getGraphics3D(), $c);
$x2 = $this->calcXPosValue($this->endValues->value[$valueIndex]);
$tmpHalfHorizSize = ($x2 - $x1) / 2;
$g = $this->chart->getGraphics3D();
$this->point->intDraw($g,
$this->chart->getAspect()->getView3D(),
$this->point->getVertSize(),
$tmpNextTask = round($this->nextTask->value[$valueIndex]);
if(($tmpNextTask >= 0) && ($tmpNextTask < $this->getCount()))
$g->getBrush()->setVisible(false);
$halfWay = $x2 + (($xNext - $x2) / 2);
$g->_line($x2, $y, $halfWay, $y, $this->getMiddleZ());
$g->___lineTo($halfWay, $yNext, $this->getMiddleZ());
$g->___lineTo($xNext, $yNext, $this->getMiddleZ());
protected function drawMark($valueIndex, $s, $aPosition)
$aPosition->leftTop->x +=
$aPosition->arrowFrom->x) / 2;
$aPosition->leftTop->y += $aPosition->height / 2;
parent::drawMark($valueIndex, $s, $aPosition);
parent::prepareForGallery($isEnabled);
$this->point->setVertSize(3);
public function Add($view) {
$tmpColor = $tmpColor->EMPTY;
$this->int[] $this->fields = new int[$this->ValuesLists->Count];
$this->foreach( $ValuesLists)
if ($this->v->DataMember->length() != 0) {
$this->fields[$ValuesLists->IndexOf($this->v)] = $view->Table->Columns->IndexOf($this->v->DataMember);
if ($this->labelMember->length() != 0) {
$labelField = $view->Table->Columns->IndexOf($this->labelMember);
if ($this->colorMember->length() != 0) {
$colorField = $view->Table->Columns->IndexOf($this->colorMember);
if ($fieldCount == $ValuesLists->Count - 1) {
$tmpColor = ($tmpColor) ($r[$colorField]);
$tmpLabel = $this->Convert->ToString($r[$labelField]);
$this->foreach( $ValuesLists) {
$fieldIndex = $this->fields[$ValuesLists->IndexOf($this->v)];
if ($r[$fieldIndex] $DateTime) {
$this->v->TempValue = $this->misc->Utils->DateTime(($this->System->DateTime) $r[
$this->v->TempValue = $this->Convert->ToDouble($r[$fieldIndex]);
$this->Add($this->XValues->TempValue, $this->endValues->TempValue, $this->YValues->TempValue,
public function add($start, $endDate, $y, $text="", $color=null) {
$tmpColor = new Color(0,0,0); // // EMPTY COLOR BLACK
return $this->add($start->toDouble(), $endDate->toDouble(), $y, $text,
* Adds a new Gantt bar with start and end coordinates, label and color.
public function addGantt($start, $endDate, $y, $text= "", $color= null)
$color = new Color(0, 0, 0, 0, true);// Black empty
$this->endValues->tempValue = $endDate;
$this->nextTask->tempValue = - 1;
// TODO review temp or correct **** ****
// $this->endValues->addChartValue($endDate);
// $this->nextTask->addChartValue(-1);
// ***** **** TODO reivew
* True if Series source is Gantt.<br>
* It returns false if the Value parameter is the same as Self. <br>
* It's used to validate DataSource both at design and run-time. <br>
return $value instanceof Gantt;
* Returns the Maximum Value of the Series X Values List.
return max(parent::getMaxXValue(), $this->endValues->getMaximum());
return $this->Language->getString("GalleryGantt");
|