Source for file Custom.php
Documentation is available at Custom.php
* Description: Base Series class inherited by a number of TeeChart
* @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
//private Color areaColor;
private $colorEachLine = true;
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
public function Custom($c= null) {
$this->tmpColor = new Color(0,0,0,0,true);
$this->oldColor= $this->tmpColor; // ->EMPTY;
return parent::readResolve();
* Allows mouse clicks over the line drawn between points.<br>
* <pre><font face="Courier" size="4">
* lineSeries.setClickableLine( false );
* Allows mouse clicks over the line drawn between points.
* Opacity level from 0 to 100%
* Sets Opacity level from 0 to 100%
* Transparency level from 0 to 100%
return $this->getBrush()->getTransparency();
* Sets Transparency level from 0 to 100%
* <p>Example:<pre><font face="Courier" size="4">
* Series1.setTransparency(45);
$this->getBrush()->setTransparency($value);
* Sets Brush characteristics.
* @return object {@link ChartBrush}
* Darkens parts of 3D Line Series to add depth.<br>
* Darkens parts of 3D Line Series to add depth.<br>
if ($this->outLine != null) {
$this->outLine->setChart($c);
parent::setColor($value);
* Steps line joining adjacent points.<br>
* In most normal situations, a series draws a line between each Line
* point. This makes the Line appear as a "mountain" shape. However,
* setting Stairs to true will make the Series draw 2 Lines between each
* pair of points, thus giving a "stair" appearance.<br>
* This is most used in some financial Chart representations. <br>
* When Stairs is set to true you may set InvertedStairs to true to alter
* the direction of the step. <br>
* Steps line joining adjacent points.<br>
* <pre><font face="Courier" size="4">
* areaSeries1.setStairs(true);
* areaSeries2.setStairs(true);
* Enables/Disables the coloring of each connecting line of a series.<br>
* <pre><font face="Courier" size="4">
* lineSeries.setColorEach(true); lineSeries.setColorEachLine(false);
return $this->colorEachLine;
* Enables/Disables the coloring of each connecting line of a series.<br>
* Changes the direction of the step, when true.<br>
return $this->invertedStairs;
* Changes the direction of the step, when true.<br>
* Pen for Series Line's outer pen.<br>
* <pre><font face="Courier" size="4">
* lineSeries.getOutline().setColor(Color.Yellow);
if ($this->outLine == null) {
$this->tmpColor = new Color(0,0,0); // Black
$this->outLine = new ChartPen($this->chart, $this->tmpColor, false,
* The vertical thickness of the line in pixels.<br>
return $this->lineHeight;
* Sets the vertical thickness of the line in pixels.<br>
$this->internalCalcMargin(!$this->getYMandatory(), true, $margins);
private function internalCalcMargin($sameSide, $horizontal, $margins) {
$this->getPointer()->calcVerticalMargins($margins);
if (($this->outLine != null) && ($this->outLine->getVisible())) {
$a = max($a, $this->outLine->getWidth());
$b = max($b, $this->outLine->getWidth());
if ($this->marks!= null) {
if ($this->marks->getVisible() && $sameSide) {
$a = max($a, $this->marks->getArrowLength());
$b = max($b, $this->marks->getArrowLength());
if ($this->marks->getVisible() && $sameSide) {
$tmp = $this->marks->getCallout()->getLength() +
$this->marks->getCallout()->getDistance();
$this->internalCalcMargin($this->yMandatory, false, $margins);
if (($this->lineHeight > 0) && (!$this->drawArea) && $this->chart->getAspect()->getView3D()) {
if ($this->lineHeight > $margins->max) {
$margins->max = $this->lineHeight;
private function pointInVertLine($p, $x0, $y0, $y1) {
private function pointInHorizLine($p, $x0, $y0, $x1) {
private function checkPointInLine($p, $tmpX, $tmpY, $oldXPos, $oldYPos) {
if ($this->chart->getAspect()->getView3D()) {
$tmpY - $this->chart->getSeriesHeight3D());
$tmp[2] = new TeePoint($oldXPos + $this->chart->getSeriesWidth3D(),
$oldYPos - $this->chart->getSeriesHeight3D());
$tmp[3] = new TeePoint($oldXPos, $oldYPos);
if ($this->invertedStairs) {
return $this->pointInVertLine($p, $oldXPos, $oldYPos, $tmpY) ||
$this->pointInHorizLine($p, $oldXPos, $tmpY, $tmpX);
return $this->pointInHorizLine($p, $oldXPos, $oldYPos, $tmpX) ||
$this->pointInVertLine($p, $tmpX, $oldYPos, $tmpY);
* Calculates if any point is at XY position.
* @return int Point index
if ($this->chart != null) {
$p = $this->chart->getGraphics3D()->calculate2DPosition($x, $y, $this->getStartZ());
if (($tmpX == $x) && ($tmpY == $y)) {
$tmp[0] = new TeePoint($oldXPos, $oldYPos);
if ($this->checkPointInLine($p, $tmpX, $tmpY, $oldXPos,
$this->Graphics3D->pointInPolygon($p, $tmp))) {
$previousBottomPos = $this->bottomPos;
protected function draw() {
if ($this->shadow->getVisible())
$tmpSize= $this->shadow->getSize();
if (($tmpSize->width!= 0) || ( $tmpSize->height!= 0))
if (($this->outLine != null) && ($this->outLine->getVisible())) {
$this->setColor($this->outLine->getColor());
$oldWidth = $this->linePen->getWidth();
$this->linePen->setWidth($oldWidth + $this->outLine->getWidth() + 2);
$this->linePen->setWidth($oldWidth);
/* calculate vertical pixel */
private function calcYPosLeftRight($yLimit, $anotherIndex, $valueIndex) {
$tmpPredValueX = $this->vxValues->value[$anotherIndex];
$tmpDif = $this->vxValues->value[$valueIndex] - $tmpPredValueX;
$tmpPredValueY = $this->vyValues->value[$anotherIndex];
return $this->getVertAxis()->calcYPosValue(1.0 * $tmpPredValueY +
($this->yLimit - $tmpPredValueX) *
$tmpPredValueY) / $tmpDif);
// private Rectangle RectFromPoints(int P0X,int P0Y,int P1X,int P1Y,int P2X,int P2Y,int P3X,int P3Y)
// Rectangle r=new Rectangle();
// r.x=Math.min(P3X,Math.min(P2X,Math.min(P0X,P1X)));
// r.y=Math.min(P3Y,Math.min(P2Y,Math.min(P0Y,P1Y)));
// r.width=Math.max(P3X,Math.max(P2X,Math.max(P0X,P1X)))-r.x;
// r.height=Math.max(P3Y,Math.max(P2Y,Math.max(P0Y,P1Y)))-r.y;
// return chart.getAspect().getView3D() ? chart.getGraphics3D().CalcRect3D(r,getStartZ()) : r;
private function drawArea($brushColor, $x, $y) {
$g = $this->chart->getGraphics3D();
if ($this->chart->getAspect()->getView3D() && $this->isLastValue) { // final point
if ($this->invertedStairs) {
$tmpBottom = $this->bottomPos;
$tmpY = $this->yMandatory ? $this->oldY : $this->oldX;
$tmpBottom = $this->oldBottomPos;
$tmpR = new Rectangle($this->oldX, $tmpY, $x - $this->oldX,
$tmpR = new Rectangle($tmpBottom, $y, $tmpY - $tmpBottom - 1,
if ($this->chart->getAspect()->getView3D()) {
if ($g->getSupportsFullRotation()) {
$g->rectangle($tmpR, $this->getEndZ());
// not in "stairs" mode...
$tmp0 = new TeePoint($this->oldX, $this->oldBottomPos);
$tmp3 = new TeePoint($x, $this->bottomPos);
$tmp0 = new TeePoint($this->oldBottomPos, $this->oldY);
$tmp3 = new TeePoint($this->bottomPos, $y);
$tmp1 = new TeePoint($this->oldX, $this->oldY);
if ($this->chart->getAspect()->getView3D()) {
$g->_plane($tmp0, $tmp1, $tmp2, $tmp3, $this->startZ);
$tmpR = new Rectangle($this->oldX, $tmpMax, $x, $tmpMin);
$tmpR = new Rectangle($tmpMin, $this->oldY, $tmpMax, $y);
$this->getBrush()->getGradient()->draw($g, $tmpR);
$g->verticalLine($this->oldX, $this->oldY, $this->oldBottomPos);
$g->horizontalLine($this->oldBottomPos, $this->oldX, $this->oldY);
if ($g->getSupportsFullRotation()) {
$g->plane($tmp0, $tmp1, $tmp2, $tmp3, $this->getEndZ());
if ($this->linePen->getVisible()) {
$g->_line($this->oldX, $this->oldY, $x, $y, $this->getStartZ());
private function drawPoint($drawOldPointer, $valueIndex, $x, $y) {
$g = $this->chart->getGraphics3D();
if ((($x != $this->oldX) || ($y != $this->oldY)) && (!$this->tmpColor->isEmpty())) { // <-- if !null
if ($this->chart->getAspect()->getView3D()) {
if ($this->tmpColor->isNull()) {
$g->getPen()->setColor($this->tmpColor);
//if ( linePen.getVisible() ) CheckPenWidth(g.Pen);
if ($this->colorEachLine || $this->drawArea) {
$oldDarkColor = $this->getColor(); // 6.01
//OldDarkColor=GetAreaBrushColor(tmpColor);
$oldBrushColor = $g->getBrush()->getColor();
$g->getBrush()->setColor($oldDarkColor);
// OldDarkColor=Color.FromArgb((100-transparency)*255/100,OldDarkColor);
// g.SetTransparency(transparency);
//if ( g.getBrush().Image != null )
// g.getBrush().Bitmap=Brush.Image.Bitmap;
$tmpOldP = new TeePoint($this->oldX, $this->oldY);
if ($this->invertedStairs) {
/* || LastValue=FirstValueIndex */
$g->getBrush()->applyDark(GraphicsGD::$DARKCOLORQUANTITY);
$g->rectangleZ($tmpOldP->x, $tmpOldP->y, $y,
$g->getBrush()->setColor($oldDarkColor);
$g->rectangleY($tmpPoint->x, $tmpPoint->y, $this->oldX,
$g->rectangleY($tmpOldP->x, $tmpOldP->y, $x,
$g->getBrush()->applyDark(GraphicsGD::$DARKCOLORQUANTITY);
$g->rectangleZ($tmpPoint->x, $tmpPoint->y, $this->oldY,
$g->getBrush()->setColor($oldDarkColor);
if (($this->lineHeight > 0) && (!$this->drawArea)) {
$p4[2] = new TeePoint($tmpOldP);
$p4[2]->y += $this->lineHeight;
$p4[3]->y += $this->lineHeight;
if ($this->isLastValue) {
$g->rectangleZ($tmpPoint->x, $tmpPoint->y,
$tmpPoint->y + $this->lineHeight,
$tmpDark3D = $this->bDark3D && (!$g->getSupportsFullRotation());
$tmpDifX = $tmpPoint->getX() - $tmpOldP->getX();
if (($tmpDifX != 0) && ($this->tmpDark3DRatio != 0) &&
(($tmpOldP->getY() - $tmpPoint->getY()) / $tmpDifX >
$this->tmpDark3DRatio)) {
$g->getBrush()->applyDark(GraphicsGD::$DARKCOLORQUANTITY);
if (($this->lineHeight > 0) && (!$this->drawArea)) {
$tmpPoint->setY($tmpOldP->getY() + $this->lineHeight);
$tmpOldP->setY($tmpOldP->getY() + $this->lineHeight);
if ($g->getMonochrome()) {
$this->tmpColor = new Color(255,255,255); // White
$g->getBrush()->setColor($this->tmpColor);
$g->getBrush()->setColor($oldDarkColor);
$g->getBrush()->setColor($oldBrushColor);
//Color oldColor=g.getBrush().Color;
$g->getPen()->setColor($this->tmpColor);
$this->drawArea($g->getBrush()->getColor(), $x, $y);
//g.getBrush().Color=oldColor;
if ((!$this->chart->getAspect()->getView3D()) && $this->drawLine) {
$this->linePrepareCanvas($g, $this->colorEachLine ? $this->tmpColor : $this->getColor());
if ($this->invertedStairs) {
$g->verticalLine($this->oldX, $this->oldY, $y);
$g->horizontalLine($this->oldX, $x, $this->oldY);
$g->moveToXY($x,$this->oldY);
// $g->___lineTo($this->oldX, $this->oldY, 0);
$g->line($this->oldX, $this->oldY, $x, $y);
if ($this->point->getVisible() && $drawOldPointer) {
if (!$this->oldColor->isEmpty()) /* <-- if ( !null */
$this->drawPointer($this->oldX, $this->oldY, $this->oldColor, $valueIndex - 1);
if ($this->isLastValue && (!$this->tmpColor->isEmpty())) /*<-- if ( !null */
$this->drawPointer($x, $y, $this->tmpColor, $valueIndex);
* Called internally. Draws the "ValueIndex" point of the Series.
$g = $this->chart->getGraphics3D();
$g->getPen()->setColor(new Color(0,0,0));
$g->getBrush()->setColor($this->tmpColor);
if ($this->oldColor->isEmpty()) { // if null
$this->isLastValue = ($valueIndex == $this->lastVisible);
if ($valueIndex == $tmpFirst) {
if ($this->chart->getSeriesWidth3D() != 0) {
$this->tmpDark3DRatio = $this->chart->getSeriesHeight3D() / $this->chart->getSeriesWidth3D();
$this->tmpDark3DRatio = 1;
if (($tmpFirst == $this->firstVisible) && ($valueIndex > 0)) {
// previous point outside left
$this->oldX = $this->calcXPos($valueIndex - 1);
$this->oldY = $this->calcYPos($valueIndex - 1);
$tmpRect = $this->chart->getChartRect();
$this->oldX = $this->getHorizAxis()->getInverted() ? $tmpRect->getRight() :
$this->oldY = $this->calcYPos($valueIndex - 1);
$this->oldY = $this->calcYPosLeftRight($this->xScreenToValue($this->oldX),
$valueIndex - 1, $valueIndex);
if (!$this->isNull($valueIndex - 1)) {
$this->drawPoint(false, $valueIndex, $x, $y);
if ($this->isLastValue && $this->point->getVisible()) {
$this->drawPointer($x, $y, $this->tmpColor, $valueIndex);
if ($g->getSupportsFullRotation() && $this->drawArea &&
$this->chart->getAspect()->getView3D()) {
if (!$this->isNull($valueIndex - 1)) {
$this->drawPoint(true, $valueIndex, $x, $y);
$this->oldBottomPos = $this->bottomPos;
$this->oldColor = $this->tmpColor;
private function drawLine($g, $drawRectangle, $tmpColor, $rect) {
if ($this->chart->getLegend()->getSymbol()->getDefaultPen()) {
$this->linePrepareCanvas($g, $tmpColor);
$g->horizontalLine($rect->x, $rect->getRight(),
($rect->y + $rect->getBottom()) / 2,0);
$tmpLegendColor = ($valueIndex == - 1) ? $this->getColor() :
$this->drawLine($g, false, $tmpLegendColor, $rect);
$this->point->drawLegendShape($g, $tmpLegendColor, $rect, $this->getLinePen()->getVisible());
$this->drawLine($g, $this->chart->getAspect()->getView3D(), $tmpLegendColor, $rect);
private function linePrepareCanvas($g, $aColor) {
if ($g->getMonochrome()) {
$aColor = new Color(255,255,255); // White
if ($this->chart->getAspect()->getView3D()) {
if ($this->bBrush->getImage() != null) {
$g->getBrush()->setImage($this->bBrush->getImage());
$g->getBrush()->setStyle($this->bBrush->getStyle());
$g->getBrush()->setColor($aColor);
$g->getPen()->setColor($aColor);
$g->getBrush()->setVisible(false);
$g->getPen()->setColor($aColor);
// chart.CheckPenWidth(g.Pen);
$this->shadow->assign($value);
|