Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / admin / jpgraph / jpgraph_polar.php
blob1690fcb2a23101d50287bd4bc79e59a071fc48e2
1 <?php
2 /*=======================================================================
3 // File: JPGRAPH_POLAR.PHP
4 // Description: Polar plot extension for JpGraph
5 // Created: 2003-02-02
6 // Author: Johan Persson (johanp@aditus.nu)
7 // Ver: $Id: jpgraph_polar.php,v 1.1 2006/07/07 13:37:14 powles Exp $
8 //
9 // Copyright (c) Aditus Consulting. All rights reserved.
10 //========================================================================
13 require_once ('jpgraph_plotmark.inc');
16 require_once "jpgraph_log.php";
19 DEFINE('POLAR_360',1);
20 DEFINE('POLAR_180',2);
23 // Note. Don't attempt to make sense of this code.
24 // In order not to have to be able to inherit the scaling code
25 // from the main graph package we have had to make some "tricks" since
26 // the original scaling and axis was not designed to do what is
27 // required here.
28 // There were two option. 1: Re-implement everything and get a clean design
29 // and 2: do some "small" trickery and be able to inherit most of
30 // the functionlity from the main graph package.
31 // We choose 2: here in order to save some time.
32 //
34 //--------------------------------------------------------------------------
35 // class PolarPlot
36 //--------------------------------------------------------------------------
37 class PolarPlot {
38 var $numpoints=0;
39 var $iColor='navy',$iFillColor='';
40 var $iLineWeight=1;
41 var $coord=null;
42 var $legendcsimtarget='';
43 var $legendcsimalt='';
44 var $legend="";
45 var $csimtargets=array(); // Array of targets for CSIM
46 var $csimareas=""; // Resultant CSIM area tags
47 var $csimalts=null; // ALT:s for corresponding target
48 var $line_style='solid',$mark;
50 function __construct($aData) {
51 $n = count($aData);
52 if( $n & 1 ) {
53 JpGraphError::RaiseL(17001);
54 //('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).');
56 $this->numpoints = $n/2;
57 $this->coord = $aData;
58 $this->mark = new PlotMark();
61 function SetWeight($aWeight) {
62 $this->iLineWeight = $aWeight;
65 function SetColor($aColor){
66 $this->iColor = $aColor;
69 function SetFillColor($aColor){
70 $this->iFillColor = $aColor;
73 function Max() {
74 $m = $this->coord[1];
75 $i=1;
76 while( $i < $this->numpoints ) {
77 $m = max($m,$this->coord[2*$i+1]);
78 ++$i;
80 return $m;
82 // Set href targets for CSIM
83 function SetCSIMTargets($aTargets,$aAlts=null) {
84 $this->csimtargets=$aTargets;
85 $this->csimalts=$aAlts;
88 // Get all created areas
89 function GetCSIMareas() {
90 return $this->csimareas;
93 function SetLegend($aLegend,$aCSIM="",$aCSIMAlt="") {
94 $this->legend = $aLegend;
95 $this->legendcsimtarget = $aCSIM;
96 $this->legendcsimalt = $aCSIMAlt;
99 // Private methods
101 function Legend(&$aGraph) {
102 $color = $this->iColor ;
103 if( $this->legend != "" ) {
104 if( $this->iFillColor!='' ) {
105 $color = $this->iFillColor;
106 $aGraph->legend->Add($this->legend,$color,$this->mark,0,
107 $this->legendcsimtarget,$this->legendcsimalt);
109 else {
110 $aGraph->legend->Add($this->legend,$color,$this->mark,$this->line_style,
111 $this->legendcsimtarget,$this->legendcsimalt);
116 function Stroke(&$img,$scale) {
118 $i=0;
119 $p=array();
120 $this->csimareas='';
121 while($i < $this->numpoints) {
122 list($x1,$y1) = $scale->PTranslate($this->coord[2*$i],$this->coord[2*$i+1]);
123 $p[2*$i] = $x1;
124 $p[2*$i+1] = $y1;
126 if( isset($this->csimtargets[$i]) ) {
127 $this->mark->SetCSIMTarget($this->csimtargets[$i]);
128 $this->mark->SetCSIMAlt($this->csimalts[$i]);
129 $this->mark->SetCSIMAltVal($this->coord[2*$i], $this->coord[2*$i+1]);
130 $this->mark->Stroke($img,$x1,$y1);
131 $this->csimareas .= $this->mark->GetCSIMAreas();
133 else
134 $this->mark->Stroke($img,$x1,$y1);
136 ++$i;
139 if( $this->iFillColor != '' ) {
140 $img->SetColor($this->iFillColor);
141 $img->FilledPolygon($p);
143 $img->SetLineWeight($this->iLineWeight);
144 $img->SetColor($this->iColor);
145 $img->Polygon($p,$this->iFillColor!='');
149 //--------------------------------------------------------------------------
150 // class PolarAxis
151 //--------------------------------------------------------------------------
152 class PolarAxis extends Axis {
153 var $angle_step=15,$angle_color='lightgray',$angle_label_color='black';
154 var $angle_fontfam=FF_FONT1,$angle_fontstyle=FS_NORMAL,$angle_fontsize=10;
155 var $angle_fontcolor = 'navy';
156 var $gridminor_color='lightgray',$gridmajor_color='lightgray';
157 var $show_minor_grid = false, $show_major_grid = true ;
158 var $show_angle_mark=true, $show_angle_grid=true, $show_angle_label=true;
159 var $angle_tick_len=3, $angle_tick_len2=3, $angle_tick_color='black';
160 var $show_angle_tick=true;
161 var $radius_tick_color='black';
163 function PolarAxis(&$img,&$aScale) {
164 parent::Axis($img,$aScale);
167 function ShowAngleDegreeMark($aFlg=true) {
168 $this->show_angle_mark = $aFlg;
171 function SetAngleStep($aStep) {
172 $this->angle_step=$aStep;
175 function HideTicks($aFlg=true,$aAngleFlg=true) {
176 parent::HideTicks($aFlg,$aFlg);
177 $this->show_angle_tick = !$aAngleFlg;
180 function ShowAngleLabel($aFlg=true) {
181 $this->show_angle_label = $aFlg;
184 function ShowGrid($aMajor=true,$aMinor=false,$aAngle=true) {
185 $this->show_minor_grid = $aMinor;
186 $this->show_major_grid = $aMajor;
187 $this->show_angle_grid = $aAngle ;
190 function SetAngleFont($aFontFam,$aFontStyle=FS_NORMAL,$aFontSize=10) {
191 $this->angle_fontfam = $aFontFam;
192 $this->angle_fontstyle = $aFontStyle;
193 $this->angle_fontsize = $aFontSize;
196 function SetColor($aColor,$aRadColor='',$aAngleColor='') {
197 if( $aAngleColor == '' )
198 $aAngleColor=$aColor;
199 parent::SetColor($aColor,$aRadColor);
200 $this->angle_fontcolor = $aAngleColor;
203 function SetGridColor($aMajorColor,$aMinorColor='',$aAngleColor='') {
204 if( $aMinorColor == '' )
205 $aMinorColor = $aMajorColor;
206 if( $aAngleColor == '' )
207 $aAngleColor = $aMajorColor;
209 $this->gridminor_color = $aMinorColor;
210 $this->gridmajor_color = $aMajorColor;
211 $this->angle_color = $aAngleColor;
214 function SetTickColors($aRadColor,$aAngleColor='') {
215 $this->radius_tick_color = $aRadColor;
216 $this->angle_tick_color = $aAngleColor;
219 // Private methods
220 function StrokeGrid($pos) {
221 $x = round($this->img->left_margin + $this->img->plotwidth/2);
222 $this->scale->ticks->Stroke($this->img,$this->scale,$pos);
224 // Stroke the minor arcs
225 $pmin = array();
226 $p = $this->scale->ticks->ticks_pos;
227 $n = count($p);
228 $i = 0;
229 $this->img->SetColor($this->gridminor_color);
230 while( $i < $n ) {
231 $r = $p[$i]-$x+1;
232 $pmin[]=$r;
233 if( $this->show_minor_grid ) {
234 $this->img->Circle($x,$pos,$r);
236 $i++;
239 $limit = max($this->img->plotwidth,$this->img->plotheight)*1.4 ;
240 while( $r < $limit ) {
241 $off = $r;
242 $i=1;
243 $r = $off + round($p[$i]-$x+1);
244 while( $r < $limit && $i < $n ) {
245 $r = $off+$p[$i]-$x;
246 $pmin[]=$r;
247 if( $this->show_minor_grid ) {
248 $this->img->Circle($x,$pos,$r);
250 $i++;
254 // Stroke the major arcs
255 if( $this->show_major_grid ) {
256 // First determine how many minor step on
257 // every major step. We have recorded the minor radius
258 // in pmin and use these values. This is done in order
259 // to avoid rounding errors if we were to recalculate the
260 // different major radius.
261 $pmaj = $this->scale->ticks->maj_ticks_pos;
262 $p = $this->scale->ticks->ticks_pos;
263 if( $this->scale->name == 'lin' ) {
264 $step=round(($pmaj[1] - $pmaj[0])/($p[1] - $p[0]));
266 else {
267 $step=9;
269 $n = round(count($pmin)/$step);
270 $i = 0;
271 $this->img->SetColor($this->gridmajor_color);
272 $limit = max($this->img->plotwidth,$this->img->plotheight)*1.4 ;
273 $off = $r;
274 $i=0;
275 $r = $pmin[$i*$step];
276 while( $r < $limit && $i < $n ) {
277 $r = $pmin[$i*$step];
278 $this->img->Circle($x,$pos,$r);
279 $i++;
283 // Draw angles
284 if( $this->show_angle_grid ) {
285 $this->img->SetColor($this->angle_color);
286 $d = max($this->img->plotheight,$this->img->plotwidth)*1.4 ;
287 $a = 0;
288 $p = $this->scale->ticks->ticks_pos;
289 $start_radius = $p[1]-$x;
290 while( $a < 360 ) {
291 if( $a == 90 || $a == 270 ) {
292 // Make sure there are no rounding problem with
293 // exactly vertical lines
294 $this->img->Line($x+$start_radius*cos($a/180*M_PI)+1,
295 $pos-$start_radius*sin($a/180*M_PI),
296 $x+$start_radius*cos($a/180*M_PI)+1,
297 $pos-$d*sin($a/180*M_PI));
300 else {
301 $this->img->Line($x+$start_radius*cos($a/180*M_PI)+1,
302 $pos-$start_radius*sin($a/180*M_PI),
303 $x+$d*cos($a/180*M_PI),
304 $pos-$d*sin($a/180*M_PI));
306 $a += $this->angle_step;
311 function StrokeAngleLabels($pos,$type) {
313 if( !$this->show_angle_label )
314 return;
316 $x0 = round($this->img->left_margin+$this->img->plotwidth/2)+1;
318 $d = max($this->img->plotwidth,$this->img->plotheight)*1.42;
319 $a = $this->angle_step;
320 $t = new Text();
321 $t->SetColor($this->angle_fontcolor);
322 $t->SetFont($this->angle_fontfam,$this->angle_fontstyle,$this->angle_fontsize);
323 $xright = $this->img->width - $this->img->right_margin;
324 $ytop = $this->img->top_margin;
325 $xleft = $this->img->left_margin;
326 $ybottom = $this->img->height - $this->img->bottom_margin;
327 $ha = 'left';
328 $va = 'center';
329 $w = $this->img->plotwidth/2;
330 $h = $this->img->plotheight/2;
331 $xt = $x0; $yt = $pos;
332 $margin=5;
334 $tl = $this->angle_tick_len ; // Outer len
335 $tl2 = $this->angle_tick_len2 ; // Interior len
337 $this->img->SetColor($this->angle_tick_color);
338 $rot90 = $this->img->a == 90 ;
340 if( $type == POLAR_360 ) {
341 $ca1 = atan($h/$w)/M_PI*180;
342 $ca2 = 180-$ca1;
343 $ca3 = $ca1+180;
344 $ca4 = 360-$ca1;
345 $end = 360;
346 while( $a < $end ) {
347 $ca = cos($a/180*M_PI);
348 $sa = sin($a/180*M_PI);
349 $x = $d*$ca;
350 $y = $d*$sa;
351 $xt=1000;$yt=1000;
352 if( $a <= $ca1 || $a >= $ca4 ) {
353 $yt = $pos - $w * $y/$x;
354 $xt = $xright + $margin;
355 if( $rot90 ) {
356 $ha = 'center';
357 $va = 'top';
359 else {
360 $ha = 'left';
361 $va = 'center';
363 $x1=$xright-$tl2; $x2=$xright+$tl;
364 $y1=$y2=$yt;
366 elseif( $a > $ca1 && $a < $ca2 ) {
367 $xt = $x0 + $h * $x/$y;
368 $yt = $ytop - $margin;
369 if( $rot90 ) {
370 $ha = 'left';
371 $va = 'center';
373 else {
374 $ha = 'center';
375 $va = 'bottom';
377 $y1=$ytop+$tl2;$y2=$ytop-$tl;
378 $x1=$x2=$xt;
380 elseif( $a >= $ca2 && $a <= $ca3 ) {
381 $yt = $pos + $w * $y/$x;
382 $xt = $xleft - $margin;
383 if( $rot90 ) {
384 $ha = 'center';
385 $va = 'bottom';
387 else {
388 $ha = 'right';
389 $va = 'center';
391 $x1=$xleft+$tl2;$x2=$xleft-$tl;
392 $y1=$y2=$yt;
394 else {
395 $xt = $x0 - $h * $x/$y;
396 $yt = $ybottom + $margin;
397 if( $rot90 ) {
398 $ha = 'right';
399 $va = 'center';
401 else {
402 $ha = 'center';
403 $va = 'top';
405 $y1=$ybottom-$tl2;$y2=$ybottom+$tl;
406 $x1=$x2=$xt;
408 if( $a != 0 && $a != 180 ) {
409 $t->Align($ha,$va);
410 if( $this->show_angle_mark )
411 $a .= '°';
412 $t->Set($a);
413 $t->Stroke($this->img,$xt,$yt);
414 if( $this->show_angle_tick )
415 $this->img->Line($x1,$y1,$x2,$y2);
417 $a += $this->angle_step;
420 else {
421 // POLAR_HALF
422 $ca1 = atan($h/$w*2)/M_PI*180;
423 $ca2 = 180-$ca1;
424 $end = 180;
425 while( $a < $end ) {
426 $ca = cos($a/180*M_PI);
427 $sa = sin($a/180*M_PI);
428 $x = $d*$ca;
429 $y = $d*$sa;
430 if( $a <= $ca1 ) {
431 $yt = $pos - $w * $y/$x;
432 $xt = $xright + $margin;
433 if( $rot90 ) {
434 $ha = 'center';
435 $va = 'top';
437 else {
438 $ha = 'left';
439 $va = 'center';
441 $x1=$xright-$tl2; $x2=$xright+$tl;
442 $y1=$y2=$yt;
444 elseif( $a > $ca1 && $a < $ca2 ) {
445 $xt = $x0 + 2*$h * $x/$y;
446 $yt = $ytop - $margin;
447 if( $rot90 ) {
448 $ha = 'left';
449 $va = 'center';
451 else {
452 $ha = 'center';
453 $va = 'bottom';
455 $y1=$ytop+$tl2;$y2=$ytop-$tl;
456 $x1=$x2=$xt;
458 elseif( $a >= $ca2 ) {
459 $yt = $pos + $w * $y/$x;
460 $xt = $xleft - $margin;
461 if( $rot90 ) {
462 $ha = 'center';
463 $va = 'bottom';
465 else {
466 $ha = 'right';
467 $va = 'center';
469 $x1=$xleft+$tl2;$x2=$xleft-$tl;
470 $y1=$y2=$yt;
472 $t->Align($ha,$va);
473 if( $this->show_angle_mark )
474 $a .= '°';
475 $t->Set($a);
476 $t->Stroke($this->img,$xt,$yt);
477 if( $this->show_angle_tick )
478 $this->img->Line($x1,$y1,$x2,$y2);
479 $a += $this->angle_step;
484 function Stroke($pos) {
486 $this->img->SetLineWeight($this->weight);
487 $this->img->SetColor($this->color);
488 $this->img->SetFont($this->font_family,$this->font_style,$this->font_size);
489 if( !$this->hide_line )
490 $this->img->FilledRectangle($this->img->left_margin,$pos,
491 $this->img->width-$this->img->right_margin,$pos+$this->weight-1);
492 $y=$pos+$this->img->GetFontHeight()+$this->title_margin+$this->title->margin;
493 if( $this->title_adjust=="high" )
494 $this->title->Pos($this->img->width-$this->img->right_margin,$y,"right","top");
495 elseif( $this->title_adjust=="middle" || $this->title_adjust=="center" )
496 $this->title->Pos(($this->img->width-$this->img->left_margin-
497 $this->img->right_margin)/2+$this->img->left_margin,
498 $y,"center","top");
499 elseif($this->title_adjust=="low")
500 $this->title->Pos($this->img->left_margin,$y,"left","top");
501 else {
502 JpGraphError::RaiseL(17002,$this->title_adjust);
503 //('Unknown alignment specified for X-axis title. ('.$this->title_adjust.')');
507 if (!$this->hide_labels) {
508 $this->StrokeLabels($pos,false);
510 $this->img->SetColor($this->radius_tick_color);
511 $this->scale->ticks->Stroke($this->img,$this->scale,$pos);
514 // Mirror the positions for the left side of the scale
516 $mid = 2*($this->img->left_margin+$this->img->plotwidth/2);
517 $n = count($this->scale->ticks->ticks_pos);
518 $i=0;
519 while( $i < $n ) {
520 $this->scale->ticks->ticks_pos[$i] =
521 $mid-$this->scale->ticks->ticks_pos[$i] ;
522 ++$i;
525 $n = count($this->scale->ticks->maj_ticks_pos);
526 $i=0;
527 while( $i < $n ) {
528 $this->scale->ticks->maj_ticks_pos[$i] =
529 $mid-$this->scale->ticks->maj_ticks_pos[$i] ;
530 ++$i;
533 $n = count($this->scale->ticks->maj_ticklabels_pos);
534 $i=1;
535 while( $i < $n ) {
536 $this->scale->ticks->maj_ticklabels_pos[$i] =
537 $mid-$this->scale->ticks->maj_ticklabels_pos[$i] ;
538 ++$i;
541 // Draw the left side of the scale
542 $n = count($this->scale->ticks->ticks_pos);
543 $yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMinTickAbsSize();
546 // Minor ticks
547 if( ! $this->scale->ticks->supress_minor_tickmarks ) {
548 $i=1;
549 while( $i < $n/2 ) {
550 $x = round($this->scale->ticks->ticks_pos[$i]) ;
551 $this->img->Line($x,$pos,$x,$yu);
552 ++$i;
556 $n = count($this->scale->ticks->maj_ticks_pos);
557 $yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMajTickAbsSize();
560 // Major ticks
561 if( ! $this->scale->ticks->supress_tickmarks ) {
562 $i=1;
563 while( $i < $n/2 ) {
564 $x = round($this->scale->ticks->maj_ticks_pos[$i]) ;
565 $this->img->Line($x,$pos,$x,$yu);
566 ++$i;
569 if (!$this->hide_labels) {
570 $this->StrokeLabels($pos,false);
572 $this->title->Stroke($this->img);
576 class PolarScale extends LinearScale {
577 var $graph;
578 function PolarScale($aMax=0,&$graph) {
579 parent::LinearScale(0,$aMax,'x');
580 $this->graph = &$graph;
583 function _Translate($v) {
584 return parent::Translate($v);
587 function PTranslate($aAngle,$aRad) {
589 $m = $this->scale[1];
590 $w = $this->graph->img->plotwidth/2;
591 $aRad = $aRad/$m*$w;
593 $x = cos( $aAngle/180 * M_PI ) * $aRad;
594 $y = sin( $aAngle/180 * M_PI ) * $aRad;
596 $x += $this->_Translate(0);
598 if( $this->graph->iType == POLAR_360 ) {
599 $y = ($this->graph->img->top_margin + $this->graph->img->plotheight/2) - $y;
601 else {
602 $y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y;
604 return array($x,$y);
608 class PolarLogScale extends LogScale {
609 var $graph;
610 function PolarLogScale($aMax=1,&$graph) {
611 parent::LogScale(0,$aMax,'x');
612 $this->graph = &$graph;
613 $this->ticks->SetLabelLogType(LOGLABELS_MAGNITUDE);
617 function PTranslate($aAngle,$aRad) {
619 if( $aRad == 0 )
620 $aRad = 1;
621 $aRad = log10($aRad);
622 $m = $this->scale[1];
623 $w = $this->graph->img->plotwidth/2;
624 $aRad = $aRad/$m*$w;
626 $x = cos( $aAngle/180 * M_PI ) * $aRad;
627 $y = sin( $aAngle/180 * M_PI ) * $aRad;
629 $x += $w+$this->graph->img->left_margin;//$this->_Translate(0);
630 if( $this->graph->iType == POLAR_360 ) {
631 $y = ($this->graph->img->top_margin + $this->graph->img->plotheight/2) - $y;
633 else {
634 $y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y;
636 return array($x,$y);
640 class PolarGraph extends Graph {
641 var $scale;
642 var $iType=POLAR_360;
643 var $axis;
645 function PolarGraph($aWidth=300,$aHeight=200,$aCachedName="",$aTimeOut=0,$aInline=true) {
646 parent::Graph($aWidth,$aHeight,$aCachedName,$aTimeOut,$aInline) ;
647 $this->SetDensity(TICKD_DENSE);
648 $this->SetBox();
649 $this->SetMarginColor('white');
652 function SetDensity($aDense) {
653 $this->SetTickDensity(TICKD_NORMAL,$aDense);
656 function Set90AndMargin($lm=0,$rm=0,$tm=0,$bm=0) {
657 $adj = ($this->img->height - $this->img->width)/2;
658 $this->SetAngle(90);
659 $this->img->SetMargin($lm-$adj,$rm-$adj,$tm+$adj,$bm+$adj);
660 $this->img->SetCenter(floor($this->img->width/2),floor($this->img->height/2));
661 $this->axis->SetLabelAlign('right','center');
662 //JpGraphError::Raise('Set90AndMargin() is not supported for polar graphs.');
665 function SetScale($aScale,$rmax=0) {
666 if( $aScale == 'lin' )
667 $this->scale = new PolarScale($rmax,$this);
668 elseif( $aScale == 'log' ) {
669 $this->scale = new PolarLogScale($rmax,$this);
671 else {
672 JpGraphError::RaiseL(17004);//('Unknown scale type for polar graph. Must be "lin" or "log"');
675 $this->axis = new PolarAxis($this->img,$this->scale);
676 $this->SetMargin(40,40,50,40);
679 function SetType($aType) {
680 $this->iType = $aType;
683 function SetPlotSize($w,$h) {
684 $this->SetMargin(($this->img->width-$w)/2,($this->img->width-$w)/2,
685 ($this->img->height-$h)/2,($this->img->height-$h)/2);
688 // Private methods
689 function GetPlotsMax() {
690 $n = count($this->plots);
691 $m = $this->plots[0]->Max();
692 $i=1;
693 while($i < $n) {
694 $m = max($this->plots[$i]->Max(),$m);
695 ++$i;
697 return $m;
700 function Stroke($aStrokeFileName="") {
702 // Start by adjusting the margin so that potential titles will fit.
703 $this->AdjustMarginsForTitles();
705 // If the filename is the predefined value = '_csim_special_'
706 // we assume that the call to stroke only needs to do enough
707 // to correctly generate the CSIM maps.
708 // We use this variable to skip things we don't strictly need
709 // to do to generate the image map to improve performance
710 // a best we can. Therefor you will see a lot of tests !$_csim in the
711 // code below.
712 $_csim = ($aStrokeFileName===_CSIM_SPECIALFILE);
714 // We need to know if we have stroked the plot in the
715 // GetCSIMareas. Otherwise the CSIM hasn't been generated
716 // and in the case of GetCSIM called before stroke to generate
717 // CSIM without storing an image to disk GetCSIM must call Stroke.
718 $this->iHasStroked = true;
720 //Check if we should autoscale axis
721 if( !$this->scale->IsSpecified() && count($this->plots)>0 ) {
722 $max = $this->GetPlotsMax();
723 $t1 = $this->img->plotwidth;
724 $this->img->plotwidth /= 2;
725 $t2 = $this->img->left_margin;
726 $this->img->left_margin += $this->img->plotwidth+1;
727 $this->scale->AutoScale($this->img,0,$max,
728 $this->img->plotwidth/$this->xtick_factor/2);
729 $this->img->plotwidth = $t1;
730 $this->img->left_margin = $t2;
732 else {
733 // The tick calculation will use the user suplied min/max values to determine
734 // the ticks. If auto_ticks is false the exact user specifed min and max
735 // values will be used for the scale.
736 // If auto_ticks is true then the scale might be slightly adjusted
737 // so that the min and max values falls on an even major step.
738 //$min = 0;
739 $max = $this->scale->scale[1];
740 $t1 = $this->img->plotwidth;
741 $this->img->plotwidth /= 2;
742 $t2 = $this->img->left_margin;
743 $this->img->left_margin += $this->img->plotwidth+1;
744 $this->scale->AutoScale($this->img,0,$max,
745 $this->img->plotwidth/$this->xtick_factor/2);
746 $this->img->plotwidth = $t1;
747 $this->img->left_margin = $t2;
750 if( $this->iType == POLAR_180 )
751 $pos = $this->img->height - $this->img->bottom_margin;
752 else
753 $pos = $this->img->plotheight/2 + $this->img->top_margin;
756 if( !$_csim ) {
757 $this->StrokePlotArea();
760 $this->iDoClipping = true;
762 if( $this->iDoClipping ) {
763 $oldimage = $this->img->CloneCanvasH();
766 if( !$_csim ) {
767 $this->axis->StrokeGrid($pos);
770 // Stroke all plots for Y1 axis
771 for($i=0; $i < count($this->plots); ++$i) {
772 $this->plots[$i]->Stroke($this->img,$this->scale);
776 if( $this->iDoClipping ) {
777 // Clipping only supports graphs at 0 and 90 degrees
778 if( $this->img->a == 0 ) {
779 $this->img->CopyCanvasH($oldimage,$this->img->img,
780 $this->img->left_margin,$this->img->top_margin,
781 $this->img->left_margin,$this->img->top_margin,
782 $this->img->plotwidth+1,$this->img->plotheight+1);
784 elseif( $this->img->a == 90 ) {
785 $adj = round(($this->img->height - $this->img->width)/2);
786 $this->img->CopyCanvasH($oldimage,$this->img->img,
787 $this->img->bottom_margin-$adj,$this->img->left_margin+$adj,
788 $this->img->bottom_margin-$adj,$this->img->left_margin+$adj,
789 $this->img->plotheight,$this->img->plotwidth);
791 $this->img->Destroy();
792 $this->img->SetCanvasH($oldimage);
795 if( !$_csim ) {
796 $this->axis->Stroke($pos);
797 $this->axis->StrokeAngleLabels($pos,$this->iType);
800 if( !$_csim ) {
801 $this->StrokePlotBox();
802 $this->footer->Stroke($this->img);
804 // The titles and legends never gets rotated so make sure
805 // that the angle is 0 before stroking them
806 $aa = $this->img->SetAngle(0);
807 $this->StrokeTitles();
810 for($i=0; $i < count($this->plots) ; ++$i ) {
811 $this->plots[$i]->Legend($this);
814 $this->legend->Stroke($this->img);
816 if( !$_csim ) {
818 $this->StrokeTexts();
819 $this->img->SetAngle($aa);
821 // Draw an outline around the image map
822 if(_JPG_DEBUG)
823 $this->DisplayClientSideaImageMapAreas();
825 // Adjust the appearance of the image
826 $this->AdjustSaturationBrightnessContrast();
828 // If the filename is given as the special "__handle"
829 // then the image handler is returned and the image is NOT
830 // streamed back
831 if( $aStrokeFileName == _IMG_HANDLER ) {
832 return $this->img->img;
834 else {
835 // Finally stream the generated picture
836 $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,
837 $aStrokeFileName);