jpgraph_line.php 23.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
<?php
/*=======================================================================
 // File:  		 JPGRAPH_LINE.PHP
 // Description: Line plot extension for JpGraph
 // Created:  	 2001-01-08
 // Ver:  		 $Id: jpgraph_line.php 1921 2009-12-11 11:46:39Z ljp $
 //
 // Copyright (c) Asial Corporation. All rights reserved.
 //========================================================================
 */

require_once ('jpgraph_plotmark.inc.php');

// constants for the (filled) area
DEFINE("LP_AREA_FILLED", true);
DEFINE("LP_AREA_NOT_FILLED", false);
DEFINE("LP_AREA_BORDER",false);
DEFINE("LP_AREA_NO_BORDER",true);

//===================================================
// CLASS LinePlot
// Description:
//===================================================
class LinePlot extends Plot{
    public $mark=null;
    protected $filled=false;
    protected $fill_color='blue';
    protected $step_style=false, $center=false;
    protected $line_style=1; // Default to solid
    protected $filledAreas = array(); // array of arrays(with min,max,col,filled in them)
    public $barcenter=false;  // When we mix line and bar. Should we center the line in the bar.
    protected $fillFromMin = false, $fillFromMax = false;
    protected $fillgrad=false,$fillgrad_fromcolor='navy',$fillgrad_tocolor='silver',$fillgrad_numcolors=100;
    protected $iFastStroke=false;

    //---------------
    // CONSTRUCTOR
    function __construct($datay,$datax=false) {
        parent::__construct($datay,$datax);
        $this->mark = new PlotMark() ;
        $this->color = ColorFactory::getColor();
        $this->fill_color = $this->color;
    }
    //---------------
    // PUBLIC METHODS

    function SetFilled($aFlg=true) {
		$this->filled = $aFlg;
    }

    function SetBarCenter($aFlag=true) {
        $this->barcenter=$aFlag;
    }

    function SetStyle($aStyle) {
        $this->line_style=$aStyle;
    }

    function SetStepStyle($aFlag=true) {
        $this->step_style = $aFlag;
    }

    function SetColor($aColor) {
        parent::SetColor($aColor);
    }

    function SetFillFromYMin($f=true) {
        $this->fillFromMin = $f ;
    }

    function SetFillFromYMax($f=true) {
        $this->fillFromMax = $f ;
    }

    function SetFillColor($aColor,$aFilled=true) {
    	//$this->color = $aColor;
        $this->fill_color=$aColor;
        $this->filled=$aFilled;
    }

    function SetFillGradient($aFromColor,$aToColor,$aNumColors=100,$aFilled=true) {
        $this->fillgrad_fromcolor = $aFromColor;
        $this->fillgrad_tocolor   = $aToColor;
        $this->fillgrad_numcolors = $aNumColors;
        $this->filled = $aFilled;
        $this->fillgrad = true;
    }

    function Legend($graph) {
        if( $this->legend!="" ) {
            if( $this->filled && !$this->fillgrad ) {
                $graph->legend->Add($this->legend,
                $this->fill_color,$this->mark,0,
                $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
            }
            elseif( $this->fillgrad ) {
                $color=array($this->fillgrad_fromcolor,$this->fillgrad_tocolor);
                // In order to differentiate between gradients and cooors specified as an RGB triple
                $graph->legend->Add($this->legend,$color,"",-2 /* -GRAD_HOR */,
                $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
            } else {
                $graph->legend->Add($this->legend,
                $this->color,$this->mark,$this->line_style,
                $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
            }
        }
    }

    function AddArea($aMin=0,$aMax=0,$aFilled=LP_AREA_NOT_FILLED,$aColor="gray9",$aBorder=LP_AREA_BORDER) {
        if($aMin > $aMax) {
            // swap
            $tmp = $aMin;
            $aMin = $aMax;
            $aMax = $tmp;
        }
        $this->filledAreas[] = array($aMin,$aMax,$aColor,$aFilled,$aBorder);
    }

    // Gets called before any axis are stroked
    function PreStrokeAdjust($graph) {

        // If another plot type have already adjusted the
        // offset we don't touch it.
        // (We check for empty in case the scale is  a log scale
        // and hence doesn't contain any xlabel_offset)
        if( empty($graph->xaxis->scale->ticks->xlabel_offset) || $graph->xaxis->scale->ticks->xlabel_offset == 0 ) {
            if( $this->center ) {
                ++$this->numpoints;
                $a=0.5; $b=0.5;
            } else {
                $a=0; $b=0;
            }
            $graph->xaxis->scale->ticks->SetXLabelOffset($a);
            $graph->SetTextScaleOff($b);
            //$graph->xaxis->scale->ticks->SupressMinorTickMarks();
        }
    }

    function SetFastStroke($aFlg=true) {
        $this->iFastStroke = $aFlg;
    }

    function FastStroke($img,$xscale,$yscale,$aStartPoint=0,$exist_x=true) {
        // An optimized stroke for many data points with no extra
        // features but 60% faster. You can't have values or line styles, or null
        // values in plots.
        $numpoints=count($this->coords[0]);
        if( $this->barcenter ) {
            $textadj = 0.5-$xscale->text_scale_off;
        }
        else {
            $textadj = 0;
        }

        $img->SetColor($this->color);
        $img->SetLineWeight($this->weight);
        $pnts=$aStartPoint;
        while( $pnts < $numpoints ) {
            if( $exist_x ) {
                $x=$this->coords[1][$pnts];
            }
            else {
                $x=$pnts+$textadj;
            }
            $xt = $xscale->Translate($x);
            $y=$this->coords[0][$pnts];
            $yt = $yscale->Translate($y);
            if( is_numeric($y) ) {
                $cord[] = $xt;
                $cord[] = $yt;
            }
            elseif( $y == '-' && $pnts > 0 ) {
                // Just ignore
            }
            else {
                JpGraphError::RaiseL(10002);//('Plot too complicated for fast line Stroke. Use standard Stroke()');
            }
            ++$pnts;
        } // WHILE

        $img->Polygon($cord,false,true);
    }

    function Stroke($img,$xscale,$yscale) {
        $idx=0;
        $numpoints=count($this->coords[0]);
        if( isset($this->coords[1]) ) {
            if( count($this->coords[1])!=$numpoints ) {
                JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints);
            //("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
            }
            else {
                $exist_x = true;
            }
        }
        else {
            $exist_x = false;
        }

        if( $this->barcenter ) {
            $textadj = 0.5-$xscale->text_scale_off;
        }
        else {
            $textadj = 0;
        }

        // Find the first numeric data point
        $startpoint=0;
        while( $startpoint < $numpoints && !is_numeric($this->coords[0][$startpoint]) ) {
            ++$startpoint;
        }

        // Bail out if no data points
        if( $startpoint == $numpoints ) return;

        if( $this->iFastStroke ) {
            $this->FastStroke($img,$xscale,$yscale,$startpoint,$exist_x);
            return;
        }

        if( $exist_x ) {
            $xs=$this->coords[1][$startpoint];
        }
        else {
            $xs= $textadj+$startpoint;
        }

        $img->SetStartPoint($xscale->Translate($xs),
        $yscale->Translate($this->coords[0][$startpoint]));

        if( $this->filled ) {
            if( $this->fillFromMax ) {
                //$max = $yscale->GetMaxVal();
                $cord[$idx++] = $xscale->Translate($xs);
                $cord[$idx++] = $yscale->scale_abs[1];
            }
            else {
                $min = $yscale->GetMinVal();
                if( $min > 0 || $this->fillFromMin ) {
                    $fillmin = $yscale->scale_abs[0];//Translate($min);
                }
                else {
                    $fillmin = $yscale->Translate(0);
                }

                $cord[$idx++] = $xscale->Translate($xs);
                $cord[$idx++] = $fillmin;
            }
        }
        $xt = $xscale->Translate($xs);
        $yt = $yscale->Translate($this->coords[0][$startpoint]);
        $cord[$idx++] = $xt;
        $cord[$idx++] = $yt;
        $yt_old = $yt;
        $xt_old = $xt;
        $y_old = $this->coords[0][$startpoint];

        $this->value->Stroke($img,$this->coords[0][$startpoint],$xt,$yt);

        $img->SetColor($this->color);
        $img->SetLineWeight($this->weight);
        $img->SetLineStyle($this->line_style);
        $pnts=$startpoint+1;
        $firstnonumeric = false;


        while( $pnts < $numpoints ) {

            if( $exist_x ) {
                $x=$this->coords[1][$pnts];
            }
            else {
                $x=$pnts+$textadj;
            }
            $xt = $xscale->Translate($x);
            $yt = $yscale->Translate($this->coords[0][$pnts]);

            $y=$this->coords[0][$pnts];
            if( $this->step_style ) {
                // To handle null values within step style we need to record the
                // first non numeric value so we know from where to start if the
                // non value is '-'.
                if( is_numeric($y) ) {
                    $firstnonumeric = false;
                    if( is_numeric($y_old) ) {
                        $img->StyleLine($xt_old,$yt_old,$xt,$yt_old);
                        $img->StyleLine($xt,$yt_old,$xt,$yt);
                    }
                    elseif( $y_old == '-' ) {
                        $img->StyleLine($xt_first,$yt_first,$xt,$yt_first);
                        $img->StyleLine($xt,$yt_first,$xt,$yt);
                    }
                    else {
                        $yt_old = $yt;
                        $xt_old = $xt;
                    }
                    $cord[$idx++] = $xt;
                    $cord[$idx++] = $yt_old;
                    $cord[$idx++] = $xt;
                    $cord[$idx++] = $yt;
                }
                elseif( $firstnonumeric==false ) {
                    $firstnonumeric = true;
                    $yt_first = $yt_old;
                    $xt_first = $xt_old;
                }
            }
            else {
                $tmp1=$y;
                $prev=$this->coords[0][$pnts-1];
                if( $tmp1==='' || $tmp1===NULL || $tmp1==='X' ) $tmp1 = 'x';
                if( $prev==='' || $prev===null || $prev==='X' ) $prev = 'x';

                if( is_numeric($y) || (is_string($y) && $y != '-') ) {
                    if( is_numeric($y) && (is_numeric($prev) || $prev === '-' ) ) {
                        $img->StyleLineTo($xt,$yt);
                    }
                    else {
                        $img->SetStartPoint($xt,$yt);
                    }
                }
                if( $this->filled && $tmp1 !== '-' ) {
                    if( $tmp1 === 'x' ) {
                        $cord[$idx++] = $cord[$idx-3];
                        $cord[$idx++] = $fillmin;
                    }
                    elseif( $prev === 'x' ) {
                        $cord[$idx++] = $xt;
                        $cord[$idx++] = $fillmin;
                        $cord[$idx++] = $xt;
                        $cord[$idx++] = $yt;
                    }
                    else {
                        $cord[$idx++] = $xt;
                        $cord[$idx++] = $yt;
                    }
                }
                else {
                    if( is_numeric($tmp1)  && (is_numeric($prev) || $prev === '-' ) ) {
                        $cord[$idx++] = $xt;
                        $cord[$idx++] = $yt;
                    }
                }
            }
            $yt_old = $yt;
            $xt_old = $xt;
            $y_old = $y;

            $this->StrokeDataValue($img,$this->coords[0][$pnts],$xt,$yt);

            ++$pnts;
        }

        if( $this->filled  ) {
            $cord[$idx++] = $xt;
            if( $this->fillFromMax ) {
                $cord[$idx++] = $yscale->scale_abs[1];
            }
            else {
                if( $min > 0 || $this->fillFromMin ) {
                    $cord[$idx++] = $yscale->Translate($min);
                }
                else {
                    $cord[$idx++] = $yscale->Translate(0);
                }
            }
            if( $this->fillgrad ) {
                $img->SetLineWeight(1);
                $grad = new Gradient($img);
                $grad->SetNumColors($this->fillgrad_numcolors);
                $grad->FilledFlatPolygon($cord,$this->fillgrad_fromcolor,$this->fillgrad_tocolor);
                $img->SetLineWeight($this->weight);
            }
            else {
                $img->SetColor($this->fill_color);
                $img->FilledPolygon($cord);
            }
            if( $this->weight > 0 ) { 
                $img->SetLineWeight($this->weight);
                $img->SetColor($this->color);
                // Remove first and last coordinate before drawing the line
                // sine we otherwise get the vertical start and end lines which
                // doesn't look appropriate
                $img->Polygon(array_slice($cord,2,count($cord)-4));
            }
        }

        if(!empty($this->filledAreas)) {

            $minY = $yscale->Translate($yscale->GetMinVal());
            $factor = ($this->step_style ? 4 : 2);

            for($i = 0; $i < sizeof($this->filledAreas); ++$i) {
                // go through all filled area elements ordered by insertion
                // fill polygon array
                $areaCoords[] = $cord[$this->filledAreas[$i][0] * $factor];
                $areaCoords[] = $minY;

                $areaCoords =
                array_merge($areaCoords,
                array_slice($cord,
                $this->filledAreas[$i][0] * $factor,
                ($this->filledAreas[$i][1] - $this->filledAreas[$i][0] + ($this->step_style ? 0 : 1))  * $factor));
                $areaCoords[] = $areaCoords[sizeof($areaCoords)-2]; // last x
                $areaCoords[] = $minY; // last y

                if($this->filledAreas[$i][3]) {
                    $img->SetColor($this->filledAreas[$i][2]);
                    $img->FilledPolygon($areaCoords);
                    $img->SetColor($this->color);
                }
                // Check if we should draw the frame.
                // If not we still re-draw the line since it might have been
                // partially overwritten by the filled area and it doesn't look
                // very good.
                if( $this->filledAreas[$i][4] ) {
                    $img->Polygon($areaCoords);
                }
                else {
                    $img->Polygon($cord);
                }

                $areaCoords = array();
            }
        }

        if( $this->mark->type == -1 || $this->mark->show == false )
        return;

        for( $pnts=0; $pnts<$numpoints; ++$pnts) {

            if( $exist_x ) {
                $x=$this->coords[1][$pnts];
            }
            else {
                $x=$pnts+$textadj;
            }
            $xt = $xscale->Translate($x);
            $yt = $yscale->Translate($this->coords[0][$pnts]);

            if( is_numeric($this->coords[0][$pnts]) ) {
                if( !empty($this->csimtargets[$pnts]) ) {
                    if( !empty($this->csimwintargets[$pnts]) ) {
                        $this->mark->SetCSIMTarget($this->csimtargets[$pnts],$this->csimwintargets[$pnts]);
                    }
                    else {
                        $this->mark->SetCSIMTarget($this->csimtargets[$pnts]);
                    }
                    $this->mark->SetCSIMAlt($this->csimalts[$pnts]);
                }
                if( $exist_x ) {
                    $x=$this->coords[1][$pnts];
                }
                else {
                    $x=$pnts;
                }
                $this->mark->SetCSIMAltVal($this->coords[0][$pnts],$x);
                $this->mark->Stroke($img,$xt,$yt);
                $this->csimareas .= $this->mark->GetCSIMAreas();
            }
        }
    }
} // Class


//===================================================
// CLASS AccLinePlot
// Description:
//===================================================
class AccLinePlot extends Plot {
    protected $plots=null,$nbrplots=0;
    private $iStartEndZero=true;
    //---------------
    // CONSTRUCTOR
    function __construct($plots) {
        $this->plots = $plots;
        $this->nbrplots = count($plots);
        $this->numpoints = $plots[0]->numpoints;

        // Verify that all plots have the same number of data points
        for( $i=1; $i < $this->nbrplots; ++$i ) {
            if( $plots[$i]->numpoints != $this->numpoints ) {
                JpGraphError::RaiseL(10003);//('Each plot in an accumulated lineplot must have the same number of data points',0)
            }
        }

        for($i=0; $i < $this->nbrplots; ++$i ) {
            $this->LineInterpolate($this->plots[$i]->coords[0]);
        }
    }

    //---------------
    // PUBLIC METHODS
    function Legend($graph) {
        foreach( $this->plots as $p ) {
            $p->DoLegend($graph);
        }
    }

    function Max() {
        list($xmax) = $this->plots[0]->Max();
        $nmax=0;
        $n = count($this->plots);
        for($i=0; $i < $n; ++$i) {
            $nc = count($this->plots[$i]->coords[0]);
            $nmax = max($nmax,$nc);
            list($x) = $this->plots[$i]->Max();
            $xmax = Max($xmax,$x);
        }
        for( $i = 0; $i < $nmax; $i++ ) {
            // Get y-value for line $i by adding the
            // individual bars from all the plots added.
            // It would be wrong to just add the
            // individual plots max y-value since that
            // would in most cases give to large y-value.
            $y=$this->plots[0]->coords[0][$i];
            for( $j = 1; $j < $this->nbrplots; $j++ ) {
                $y += $this->plots[ $j ]->coords[0][$i];
            }
            $ymax[$i] = $y;
        }
        $ymax = max($ymax);
        return array($xmax,$ymax);
    }

    function Min() {
        $nmax=0;
        list($xmin,$ysetmin) = $this->plots[0]->Min();
        $n = count($this->plots);
        for($i=0; $i < $n; ++$i) {
            $nc = count($this->plots[$i]->coords[0]);
            $nmax = max($nmax,$nc);
            list($x,$y) = $this->plots[$i]->Min();
            $xmin = Min($xmin,$x);
            $ysetmin = Min($y,$ysetmin);
        }
        for( $i = 0; $i < $nmax; $i++ ) {
            // Get y-value for line $i by adding the
            // individual bars from all the plots added.
            // It would be wrong to just add the
            // individual plots min y-value since that
            // would in most cases give to small y-value.
            $y=$this->plots[0]->coords[0][$i];
            for( $j = 1; $j < $this->nbrplots; $j++ ) {
                $y += $this->plots[ $j ]->coords[0][$i];
            }
            $ymin[$i] = $y;
        }
        $ymin = Min($ysetmin,Min($ymin));
        return array($xmin,$ymin);
    }

    // Gets called before any axis are stroked
    function PreStrokeAdjust($graph) {

        // If another plot type have already adjusted the
        // offset we don't touch it.
        // (We check for empty in case the scale is  a log scale
        // and hence doesn't contain any xlabel_offset)

        if( empty($graph->xaxis->scale->ticks->xlabel_offset) ||
        $graph->xaxis->scale->ticks->xlabel_offset == 0 ) {
            if( $this->center ) {
                ++$this->numpoints;
                $a=0.5; $b=0.5;
            } else {
                $a=0; $b=0;
            }
            $graph->xaxis->scale->ticks->SetXLabelOffset($a);
            $graph->SetTextScaleOff($b);
            $graph->xaxis->scale->ticks->SupressMinorTickMarks();
        }

    }

    function SetInterpolateMode($aIntMode) {
        $this->iStartEndZero=$aIntMode;
    }

    // Replace all '-' with an interpolated value. We use straightforward
    // linear interpolation. If the data starts with one or several '-' they
    // will be replaced by the the first valid data point
    function LineInterpolate(&$aData) {

        $n=count($aData);
        $i=0;

        // If first point is undefined we will set it to the same as the first
        // valid data
        if( $aData[$i]==='-' ) {
            // Find the first valid data
            while( $i < $n && $aData[$i]==='-' ) {
                ++$i;
            }
            if( $i < $n ) {
                for($j=0; $j < $i; ++$j ) {
                    if( $this->iStartEndZero )
                    $aData[$i] = 0;
                    else
                    $aData[$j] = $aData[$i];
                }
            }
            else {
                // All '-' => Error
                return false;
            }
        }

        while($i < $n) {
            while( $i < $n && $aData[$i] !== '-' ) {
                ++$i;
            }
            if( $i < $n ) {
                $pstart=$i-1;

                // Now see how long this segment of '-' are
                while( $i < $n && $aData[$i] === '-' ) {
                    ++$i;
                }
                if( $i < $n ) {
                    $pend=$i;
                    $size=$pend-$pstart;
                    $k=($aData[$pend]-$aData[$pstart])/$size;
                    // Replace the segment of '-' with a linear interpolated value.
                    for($j=1; $j < $size; ++$j ) {
                        $aData[$pstart+$j] = $aData[$pstart] + $j*$k ;
                    }
                }
                else {
                    // There are no valid end point. The '-' goes all the way to the end
                    // In that case we just set all the remaining values the the same as the
                    // last valid data point.
                    for( $j=$pstart+1; $j < $n; ++$j )
                    if( $this->iStartEndZero ) {
                        $aData[$j] = 0;
                    }
                    else {
                        $aData[$j] = $aData[$pstart] ;
                    }
                }
            }
        }
        return true;
    }

    // To avoid duplicate of line drawing code here we just
    // change the y-values for each plot and then restore it
    // after we have made the stroke. We must do this copy since
    // it wouldn't be possible to create an acc line plot
    // with the same graphs, i.e AccLinePlot(array($pl,$pl,$pl));
    // since this method would have a side effect.
    function Stroke($img,$xscale,$yscale) {
        $img->SetLineWeight($this->weight);
        $this->numpoints = count($this->plots[0]->coords[0]);
        // Allocate array
        $coords[$this->nbrplots][$this->numpoints]=0;
        for($i=0; $i<$this->numpoints; $i++) {
            $coords[0][$i]=$this->plots[0]->coords[0][$i];
            $accy=$coords[0][$i];
            for($j=1; $j<$this->nbrplots; ++$j ) {
                $coords[$j][$i] = $this->plots[$j]->coords[0][$i]+$accy;
                $accy = $coords[$j][$i];
            }
        }
        for($j=$this->nbrplots-1; $j>=0; --$j) {
            $p=$this->plots[$j];
            for( $i=0; $i<$this->numpoints; ++$i) {
                $tmp[$i]=$p->coords[0][$i];
                $p->coords[0][$i]=$coords[$j][$i];
            }
            $p->Stroke($img,$xscale,$yscale);
            for( $i=0; $i<$this->numpoints; ++$i) {
                $p->coords[0][$i]=$tmp[$i];
            }
            $p->coords[0][]=$tmp;
        }
    }
} // Class


/* EOF */
?>