Source for file SeriesMarks.php
Documentation is available at SeriesMarks.php
* Description: Series Marks characteristics
* @copyright Copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
* When True, Marks arrow pen color is changed if the
* point has the same color.
private $multiLine= false;
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
$tmpColor = new Color(255,255,180); // LIGHT_YELLOW
$this->getBrush()->setDefaultColor($tmpColor);
$this->shadow->setDefaultSize(1);
$this->shadow->getBrush()->setDefaultColor(new Color(128,128,128)); // DARK_GRAY
$this->callout->setDefaultLength(10);
$this->items->iMarks = $this;
* Marks Callout characteristics.<br>
* Determines how to draw a line connecting a series mark to its
* Returns a collection of mark items. <br>
* Each mark item has its own formatting (color, font, shadow, etc).<br>
* By default Items are empty, so the default marks formatting is used.
* Accesses Custom position characteristics for Series Marks. <br>
* TeeChart for Net has a number of algorithmns that were designed to stop
* TeeChart SeriesMark overlap. However, if you aren't happy with the
* automatically generated mark positions, you can always move marks around
* (Remember that you could also use the DragMarks Tool to reposition
* Contains the list of lines drawn on the chart by the user at run-time.
* Series is a read-only runtime method.<br>
* It returns the Series component that owns the TSeriesMarks subcomponent.
* All Series types own a Marks subcomponent of the TSeriesMarks class.
$Defines $how $Series $Marks $are $static $finalructed.<br>
* Each different Style value makes Marks output a different text.
* Several options are available, but you can also use the TChart
* Series.OnGetMarkText event and override the default Series Marks text.
* Default value: MarksStyle.Label
* Defines how Series Marks are constructed.<br>
* Default value: MarksStyle.Label
* @param value MarksStyle
if($this->symbol == null)
$this->symbol->setVisible(false);
$this->symbol->setTransparent(false);
$this->symbol->getShadow()->setWidth(1);
$this->symbol->getShadow()->setHeight(1);
if($this->symbol != null)
$this->symbol->setChart($value);
* Tells chart to repaint using automatically positioned marks.<br>
* Turns all Marks positions Custom to false.
* Removes all mark positions and mark items.
* Determines which Mark contains the p point parameters.
return $this->clicked($p->x, $p->y);
* Determines which Mark contains the XY pixel point parameters.
* @return int the Mark index containing the XY point.
if($this->iSeries->getChart() != null)
$p = $this->iSeries->getChart()->getGraphics3D()->calculate2DPosition($x, $y,
for($t = 0; $t < $this->pPositions->count(); $t++ )
if(($result % $this->drawEvery == 0) && ($p != null) &&
($p->getBounds()->contains($x, $y)))
* Obsolete. Use the Color method instead.
* Obsolete. Use the Color method instead.
* Obsolete. Use the Pen method instead.
* The Pen used to draw a line connecting Marks to Series points.<br>
* Each Series class handles Marks in a different manner, thus the Arrow
* coordinates are specific to each Series type. <br>
* By default, Arrow pen is defined to be a White solid pen of 1 pixel
return $this->callout->getArrow();
//protected boolean shouldSerializeArrowLength() {
// return getArrowLength() != defaultArrowLength;
* The length in pixels for the line connecting the Mark to Series point.
return $this->callout->getLength();
* Stes the length in pixels of the line connecting the Mark to Series
* Restricts Marks to Chart axes space, when true.<br>
* When true, Marks will be drawn only within inner chart boundaries,
* keeping Axis Labels, Titles, Legend, etc almost untouched.<br>
* Restricts Marks to Chart axes space, when true.<br>
* Characters in Mark texts are split into multiple lines, when true.<br>
* Characters in Mark texts are split into multiple lines, when true.<br>
* The number of Marks to skip.<br>
* Default is 1, all Marks are displayed.
* Setting it to two will draw every other Mark, to three every third etc.
* Sets the number of Marks to skip.<br>
* The angle from 0 to 360 to rotate Marks.<br>
* Sets angle from 0 to 360 to rotate Marks.<br>
* The Position in pixels on the Z axis.
* Sets Position in pixels on the Z axis.
private function drawTextLine($lineSt, $r, $tmpNumRow, $tmpRowHeight)
$tmpCenter = $r->center();
$tmpY = $tmpNumRow * $tmpRowHeight -
($r->getBottom() - $tmpCenter->y);
$tmpP->setX($tmpP->getX() + 2);
$tmpP->setX($tmpCenter->getX());
$tmpP->setY($r->y + $tmpNumRow * $tmpRowHeight);
if($this->getPen()->getVisible())
$tmpP->setX($tmpP->getX() + $this->getPen()->getWidth());
$tmpP->setY($tmpP->getY() + $this->getPen()->getWidth());
$g = $this->iSeries->getChart()->getGraphics3D();
$g->setTextAlign($this->textAlign);
if($g->getSupports3DText())
$g->textOut($tmpP->getX(), $tmpP->getY(), $this->getZPosition(), $lineSt);
$g->rotateLabel($tmpP->getX(), $tmpP->getY(),$this->getZPosition(), $lineSt,
$g->textOut($tmpP->getX(), $tmpP->getY(),0,$lineSt);
$g->rotateLabel($tmpP->getX(), $tmpP->getY(), 0, $lineSt, $this->angle);
for($t = 0; $t < $this->chart->getSeriesCount(); $t++ )
if(!$this->chart->getSeries($t)->getMarks()->getVisible())
$tmp = $this->callout->getLength() + $this->callout->getDistance();
$aPos->leftTop->setY($aPos->leftTop->getY() - $tmp);
$aPos->arrowTo->setY($aPos->arrowTo->getY() - $tmp);
$aPos->arrowFrom->setY($aPos->arrowFrom->getY() - $this->callout->getDistance());
* Returns the String showing a "percent" value for a given point.<br>
* The optional "AddTotal" parameter, when true, returns: "25% of 1234".
* @param addTotal boolean
$m = $this->iSeries->getMandatory();
$tmp = ($m->getTotalABS() != 0) ?
$tmpResult = $this->NumberFormat->getPercentInstance()->format($tmp);
$m->getTotalABS(), $this->iSeries->getValueFormat());
private function drawText($r, $st)
$tmpRowHeight = $this->iSeries->getChart()->getGraphics3D()->getFontHeight();
// tODO $i = $st->indexOf($this->Language->getString("LineSeparator"));
$this->drawTextLine($tmpSt->substring(0, $i), $r, $tmpNumRow,
$tmpSt = $tmpSt->substring($i + $this->sepLength, strlen($tmpSt));
$this->drawTextLine($tmpSt, $r, $tmpNumRow, $tmpRowHeight);
$this->drawTextLine($st, $r, $tmpNumRow, $tmpRowHeight);
private function usePosition($index, $markPosition)
// $this->pPositions->append(null);
// $this->pPositions->add(null);
if($this->pPositions->getPosition($index) == null)
if($markPosition->arrowFix)
$old = $markPosition->arrowFrom;
$markPosition->assign($tmp);
$markPosition->arrowFrom = $old;
$markPosition->assign($tmp);
$tmp->assign($markPosition);
* Returns the length in pixels for the ValueIndex th mark text String.<br>
* It checks if the Mark has multiple lines of text.
$tmpSt = $this->iSeries->getMarkText($valueIndex);
// TODO $i = $tmpSt->indexOf($this->Language->getString("LineSeparator"));
// temp line TODO remove -1
$tmpSt2 = $tmpSt->substring(0, $i);
$tmpResult = max($tmpResult,
$this->iSeries->getChart()->getGraphics3D()->textWidth($tmpSt2));
$tmpSt = $tmpSt->substring($i + 1);
$tmpResult = max($tmpResult,
$this->iSeries->getChart()->getGraphics3D()->textWidth($tmpSt));
if($this->chart->getAspect()->getView3D() &&
!$this->chart->getGraphics3D()->getSupports3DText())
$tmpDifX = $aPos->arrowTo->getX() - $p->getX();
$tmpDifY = $aPos->arrowTo->getY() - $p->getY();
$tmpPos2D = $this->chart->getGraphics3D()->calc3DPoint($aPos->arrowTo->getX(),
$p->setX($tmpPos2D->getX() - $tmpDifX);
$p->setY($tmpPos2D->getY() - $tmpDifY);
private function totalBounds($valueIndex, $aPos)
$result = $aPos->getBounds();
$tmpMark = $this->markItem($valueIndex);
if($tmpMark->getPen()->getVisible())
$result->width += $tmpMark->getPen()->getWidth();
$result->height += $tmpMark->getPen()->getWidth();
if($tmpMark->getShadow()->getWidth() > 0)
$result->width += $tmpMark->getShadow()->getWidth();
if($tmpMark->getShadow()->getWidth() < 0)
$result->x -= $tmpMark->getShadow()->getWidth();
if($tmpMark->getShadow()->getHeight() > 0)
$result->height += $tmpMark->getShadow()->getHeight();
if($tmpMark->getShadow()->getHeight() < 0)
$result->y -= $tmpMark->getShadow()->getHeight();
$p = $this->convertTo2D($aPos, $result->getLocation());
$tmp = $result->x - $p->getX();
$tmp = $result->getY() - $p->getY();
public /*protected*/ function antiOverlap($first, $valueIndex, $aPos)
$tmpBounds = $this->totalBounds($valueIndex, $aPos);
for($t = $first; $t < $valueIndex; $t++ )
$tmpR = $this->totalBounds($t, $this->getPositions()->getPosition($t));
if($tmpBounds->getTop() < $tmpR->getTop())
$tmpH = $tmpBounds->getBottom() - $tmpR->y;
$tmpH = $tmpBounds->y - $tmpR->getBottom();
$aPos->leftTop->setY($aPos->leftTop->getY() - $tmpH);
$aPos->arrowTo->setY($aPos->arrowTo->getY() - $tmpH);
public /*protected*/ function markItem($valueIndex)
$result = $this->getItems()->getItem($valueIndex);
public /*protected*/ function internalDraw($index, $aColor, $st, $aPos)
$old_name= TChart::$controlName;
TChart::$controlName .= 'Mark_';
$this->usePosition($index, $aPos);
$g = $c->getGraphics3D();
$tmp3D = $c->getAspect()->getView3D();
if($this->callout->getVisible() || $this->callout->getArrow()->getVisible())
$this->callout->draw($aColor, $aPos->arrowFrom, $aPos->arrowTo,
$tmpMark->setTransparent(true);
if($tmpMark->getTransparent())
$g->getBrush()->setVisible(false);
$g->setBrush($tmpMark->getBrush());
$g->setPen($tmpMark->getPen());
$aPos->leftTop = $this->convertTo2D($aPos, $aPos->leftTop);
// TODO added extra -2 and +4, ok?
$frameRect = new Rectangle($aPos->leftTop->getX()- 2,
$aPos->leftTop->getY(), $aPos->width + 2 + 4,
$tmpMark->drawRectRotated($g, $frameRect, (int) ($this->angle % 360),
$this->symbol->setColor($this->getSeries()->getValueColor($index));
$this->symbol->setTransparent(false);
$tmpH = $g->getFontHeight();
$aPos->leftTop->getY() + 3,
$aPos->leftTop->getX() + $tmpH - 1,
$aPos->leftTop->getY() + $tmpH - 2));
$this->symbol->drawRectRotated($g, $this->symbol->getShapeBounds(),
$g->getBrush()->setVisible(false);
$tmp = 4 + $this->symbol->getShapeBounds()->width;
$r->setX($r->getX() + $tmp);
$this->drawText($r, $st);
TChart::$controlName= $old_name;
return($this->symbol != null) && ($this->symbol->getVisible()) &&
(!$this->symbol->getTransparent());
|