Subversion Repositories Sites.obs-saisons.fr

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 aurelien 1
<?php
2
/*=======================================================================
3
// File:	JPGRAPH_RADAR.PHP
4
// Description: Radar plot extension for JpGraph
5
// Created: 	2001-02-04
6
// Ver:		$Id: jpgraph_radar.php 857 2007-03-23 19:03:13Z ljp $
7
//
8
// Copyright (c) Aditus Consulting. All rights reserved.
9
//========================================================================
10
*/
11
 
12
require_once('jpgraph_plotmark.inc.php');
13
 
14
class RadarLogTicks extends Ticks {
15
//---------------
16
// CONSTRUCTOR
17
    function RadarLogTicks() {
18
    }
19
//---------------
20
// PUBLIC METHODS
21
 
22
    // TODO: Add Argument grid
23
    function Stroke(&$aImg,&$grid,$aPos,$aAxisAngle,&$aScale,&$aMajPos,&$aMajLabel) {
24
	$start = $aScale->GetMinVal();
25
	$limit = $aScale->GetMaxVal();
26
	$nextMajor = 10*$start;
27
	$step = $nextMajor / 10.0;
28
	$count=1;
29
 
30
	$ticklen_maj=5;
31
	$dx_maj=round(sin($aAxisAngle)*$ticklen_maj);
32
	$dy_maj=round(cos($aAxisAngle)*$ticklen_maj);
33
	$ticklen_min=3;
34
	$dx_min=round(sin($aAxisAngle)*$ticklen_min);
35
	$dy_min=round(cos($aAxisAngle)*$ticklen_min);
36
 
37
	$aMajPos=array();
38
	$aMajLabel=array();
39
 
40
	if( $this->supress_first )
41
	    $aMajLabel[]="";
42
	else
43
	    $aMajLabel[]=$start;
44
	$yr=$aScale->RelTranslate($start);
45
	$xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0];
46
	$yt=$aPos-round($yr*sin($aAxisAngle));
47
	$aMajPos[]=$xt+2*$dx_maj;
48
	$aMajPos[]=$yt-$aImg->GetFontheight()/2;
49
	$grid[]=$xt;
50
	$grid[]=$yt;
51
 
52
	$aImg->SetLineWeight($this->weight);
53
 
54
	for($y=$start; $y<=$limit; $y+=$step,++$count  ) {
55
	    $yr=$aScale->RelTranslate($y);
56
	    $xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0];
57
	    $yt=$aPos-round($yr*sin($aAxisAngle));
58
	    if( $count % 10 == 0 ) {
59
		$grid[]=$xt;
60
		$grid[]=$yt;
61
		$aMajPos[]=$xt+2*$dx_maj;
62
		$aMajPos[]=$yt-$aImg->GetFontheight()/2;
63
		if( !$this->supress_tickmarks )	{
64
		    if( $this->majcolor!="" ) $aImg->PushColor($this->majcolor);
65
		    $aImg->Line($xt+$dx_maj,$yt+$dy_maj,$xt-$dx_maj,$yt-$dy_maj);
66
		    if( $this->majcolor!="" ) $aImg->PopColor();
67
		}
68
		if( $this->label_formfunc != "" ) {
69
		    $f=$this->label_formfunc;
70
		    $l = call_user_func($f,$nextMajor);
71
		}
72
		else
73
		    $l = $nextMajor;
74
		$aMajLabel[]=$l;
75
		$nextMajor *= 10;
76
		$step *= 10;
77
		$count=1;
78
	    }
79
	    else
80
		if( !$this->supress_minor_tickmarks )	{
81
		    if( $this->mincolor!="" ) $aImg->PushColor($this->mincolor);
82
		    $aImg->Line($xt+$dx_min,$yt+$dy_min,$xt-$dx_min,$yt-$dy_min);
83
		    if( $this->mincolor!="" ) $aImg->PopColor();
84
		}
85
	}
86
    }
87
}
88
 
89
class RadarLinearTicks extends LinearTicks {
90
//---------------
91
// CONSTRUCTOR
92
    function RadarLinearTicks() {
93
	// Empty
94
    }
95
 
96
//---------------
97
// PUBLIC METHODS
98
 
99
    // TODO: Add argument grid
100
    function Stroke(&$aImg,&$grid,$aPos,$aAxisAngle,&$aScale,&$aMajPos,&$aMajLabel) {
101
	// Prepare to draw linear ticks
102
	$maj_step_abs = abs($aScale->scale_factor*$this->major_step);
103
	$min_step_abs = abs($aScale->scale_factor*$this->minor_step);
104
	$nbrmaj = floor(($aScale->world_abs_size)/$maj_step_abs);
105
	$nbrmin = floor(($aScale->world_abs_size)/$min_step_abs);
106
	$skip = round($nbrmin/$nbrmaj); // Don't draw minor ontop of major
107
 
108
	// Draw major ticks
109
	$ticklen2=$this->major_abs_size;
110
	$dx=round(sin($aAxisAngle)*$ticklen2);
111
	$dy=round(cos($aAxisAngle)*$ticklen2);
112
	$label=$aScale->scale[0]+$this->major_step;
113
 
114
	$aImg->SetLineWeight($this->weight);
115
 
116
	for($i=1; $i<=$nbrmaj; ++$i) {
117
	    $xt=round($i*$maj_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0];
118
	    $yt=$aPos-round($i*$maj_step_abs*sin($aAxisAngle));
119
 
120
	    if( $this->label_formfunc != "" ) {
121
		$f=$this->label_formfunc;
122
		$l = call_user_func($f,$label);
123
	    }
124
	    else
125
		$l = $label;
126
 
127
	    $aMajLabel[]=$l;
128
	    $label += $this->major_step;
129
	    $grid[]=$xt;
130
	    $grid[]=$yt;
131
	    $aMajPos[($i-1)*2]=$xt+2*$dx;
132
	    $aMajPos[($i-1)*2+1]=$yt-$aImg->GetFontheight()/2;
133
	    if( !$this->supress_tickmarks ) {
134
		if( $this->majcolor!="" ) $aImg->PushColor($this->majcolor);
135
		$aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy);
136
		if( $this->majcolor!="" ) $aImg->PopColor();
137
	    }
138
	}
139
 
140
	// Draw minor ticks
141
	$ticklen2=$this->minor_abs_size;
142
	$dx=round(sin($aAxisAngle)*$ticklen2);
143
	$dy=round(cos($aAxisAngle)*$ticklen2);
144
	if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks)	{
145
	    if( $this->mincolor!="" ) $aImg->PushColor($this->mincolor);
146
	    for($i=1; $i<=$nbrmin; ++$i) {
147
		if( ($i % $skip) == 0 ) continue;
148
		$xt=round($i*$min_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0];
149
		$yt=$aPos-round($i*$min_step_abs*sin($aAxisAngle));
150
		$aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy);
151
	    }
152
	    if( $this->mincolor!="" ) $aImg->PopColor();
153
	}
154
    }
155
}
156
 
157
 
158
 
159
//===================================================
160
// CLASS RadarAxis
161
// Description: Implements axis for the radar graph
162
//===================================================
163
class RadarAxis extends Axis {
164
    var $title_color="navy";
165
    var $title=null;
166
//---------------
167
// CONSTRUCTOR
168
    function RadarAxis(&$img,&$aScale,$color=array(0,0,0)) {
169
	parent::Axis($img,$aScale,$color);
170
	$this->len=$img->plotheight;
171
	$this->title = new Text();
172
	$this->title->SetFont(FF_FONT1,FS_BOLD);
173
	$this->color = array(0,0,0);
174
    }
175
//---------------
176
// PUBLIC METHODS
177
    function SetTickLabels($l) {
178
	$this->ticks_label = $l;
179
    }
180
 
181
 
182
    // Stroke the axis
183
    // $pos 			= Vertical position of axis
184
    // $aAxisAngle = Axis angle
185
    // $grid			= Returns an array with positions used to draw the grid
186
    //	$lf			= Label flag, TRUE if the axis should have labels
187
    function Stroke($pos,$aAxisAngle,&$grid,$title,$lf) {
188
	$this->img->SetColor($this->color);
189
 
190
	// Determine end points for the axis
191
	$x=round($this->scale->world_abs_size*cos($aAxisAngle)+$this->scale->scale_abs[0]);
192
	$y=round($pos-$this->scale->world_abs_size*sin($aAxisAngle));
193
 
194
	// Draw axis
195
	$this->img->SetColor($this->color);
196
	$this->img->SetLineWeight($this->weight);
197
	if( !$this->hide )
198
	    $this->img->Line($this->scale->scale_abs[0],$pos,$x,$y);
199
 
200
	$this->scale->ticks->Stroke($this->img,$grid,$pos,$aAxisAngle,$this->scale,$majpos,$majlabel);
201
 
202
	// Draw labels
203
	if( $lf && !$this->hide ) {
204
	    $this->img->SetFont($this->font_family,$this->font_style,$this->font_size);
205
	    $this->img->SetTextAlign("left","top");
206
	    $this->img->SetColor($this->label_color);
207
 
208
	    // majpos contains (x,y) coordinates for labels
209
	    if( ! $this->hide_labels ) {
210
		$n = floor(count($majpos)/2);
211
		for($i=0; $i < $n; ++$i) {
212
		    if( $this->ticks_label != null && isset($this->ticks_label[$i]) )
213
			$this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$this->ticks_label[$i]);
214
		    else
215
			$this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$majlabel[$i]);
216
		}
217
	    }
218
	}
219
	$this->_StrokeAxisTitle($pos,$aAxisAngle,$title);
220
    }
221
//---------------
222
// PRIVATE METHODS
223
 
224
    function _StrokeAxisTitle($pos,$aAxisAngle,$title) {
225
	$this->title->Set($title);
226
	$marg=6+$this->title->margin;
227
	$xt=round(($this->scale->world_abs_size+$marg)*cos($aAxisAngle)+$this->scale->scale_abs[0]);
228
	$yt=round($pos-($this->scale->world_abs_size+$marg)*sin($aAxisAngle));
229
 
230
	// Position the axis title.
231
	// dx, dy is the offset from the top left corner of the bounding box that sorrounds the text
232
	// that intersects with the extension of the corresponding axis. The code looks a little
233
	// bit messy but this is really the only way of having a reasonable position of the
234
	// axis titles.
235
	if( $this->title->iWordwrap > 0 ) {
236
	    $title = wordwrap($title,$this->title->iWordwrap,"\n");
237
	}
238
 
239
	$h=$this->img->GetTextHeight($title)*1.2;
240
	$w=$this->img->GetTextWidth($title)*1.2;
241
	while( $aAxisAngle > 2*M_PI ) $aAxisAngle -= 2*M_PI;
242
 
243
 
244
	// Around 3 a'clock
245
	if( $aAxisAngle>=7*M_PI/4 || $aAxisAngle <= M_PI/4 ) $dx=-0.15; // Small trimming to make the dist to the axis more even
246
	// Around 12 a'clock
247
	if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dx=($aAxisAngle-M_PI/4)*2/M_PI;
248
	// Around 9 a'clock
249
	if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dx=1;
250
	// Around 6 a'clock
251
	if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dx=(1-($aAxisAngle-M_PI*5/4)*2/M_PI);
252
 
253
 
254
	if( $aAxisAngle>=7*M_PI/4 ) $dy=(($aAxisAngle-M_PI)-3*M_PI/4)*2/M_PI;
255
	if( $aAxisAngle<=M_PI/12 ) $dy=(0.5-$aAxisAngle*2/M_PI);
256
	if( $aAxisAngle<=M_PI/4 && $aAxisAngle > M_PI/12) $dy=(1-$aAxisAngle*2/M_PI);
257
	if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dy=1;
258
	if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dy=(1-($aAxisAngle-3*M_PI/4)*2/M_PI);
259
	if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dy=0;
260
 
261
	if( !$this->hide ) {
262
	    $this->title->Stroke($this->img,$xt-$dx*$w,$yt-$dy*$h,$title);
263
	}
264
    }
265
 
266
 
267
} // Class
268
 
269
 
270
//===================================================
271
// CLASS RadarGrid
272
// Description: Draws grid for the radar graph
273
//===================================================
274
class RadarGrid extends Grid {
275
//------------
276
// CONSTRUCTOR
277
    function RadarGrid() {
278
    }
279
 
280
//----------------
281
// PRIVATE METHODS
282
    function Stroke(&$img,&$grid) {
283
	if( !$this->show ) return;
284
	$nbrticks = count($grid[0])/2;
285
	$nbrpnts = count($grid);
286
	$img->SetColor($this->grid_color);
287
	$img->SetLineWeight($this->weight);
288
	for($i=0; $i<$nbrticks; ++$i) {
289
	    for($j=0; $j<$nbrpnts; ++$j) {
290
		$pnts[$j*2]=$grid[$j][$i*2];
291
		$pnts[$j*2+1]=$grid[$j][$i*2+1];
292
	    }
293
	    for($k=0; $k<$nbrpnts; ++$k ){
294
		$l=($k+1)%$nbrpnts;
295
		if( $this->type == "solid" )
296
		    $img->Line($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1]);
297
		elseif( $this->type == "dotted" )
298
		    $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],1,6);
299
		elseif( $this->type == "dashed" )
300
		    $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],2,4);
301
		elseif( $this->type == "longdashed" )
302
		    $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],8,6);
303
	    }
304
	    $pnts=array();
305
	}
306
    }
307
} // Class
308
 
309
 
310
//===================================================
311
// CLASS RadarPlot
312
// Description: Plot a radarplot
313
//===================================================
314
class RadarPlot {
315
    var $data=array();
316
    var $fill=false, $fill_color=array(200,170,180);
317
    var $color=array(0,0,0);
318
    var $legend="";
319
    var $weight=1;
320
    var $linestyle='solid';
321
    var $mark=null;
322
//---------------
323
// CONSTRUCTOR
324
    function RadarPlot($data) {
325
	$this->data = $data;
326
	$this->mark = new PlotMark();
327
    }
328
 
329
//---------------
330
// PUBLIC METHODS
331
    function Min() {
332
	return Min($this->data);
333
    }
334
 
335
    function Max() {
336
	return Max($this->data);
337
    }
338
 
339
    function SetLegend($legend) {
340
	$this->legend=$legend;
341
    }
342
 
343
    function SetLineStyle($aStyle) {
344
	$this->linestyle=$aStyle;
345
    }
346
 
347
    function SetLineWeight($w) {
348
	$this->weight=$w;
349
    }
350
 
351
    function SetFillColor($aColor) {
352
	$this->fill_color = $aColor;
353
	$this->fill = true;
354
    }
355
 
356
    function SetFill($f=true) {
357
	$this->fill = $f;
358
    }
359
 
360
    function SetColor($aColor,$aFillColor=false) {
361
	$this->color = $aColor;
362
	if( $aFillColor ) {
363
	    $this->SetFillColor($aFillColor);
364
	    $this->fill = true;
365
	}
366
    }
367
 
368
    function GetCSIMareas() {
369
	JpGraphError::RaiseL(18001);
370
//("Client side image maps not supported for RadarPlots.");
371
    }
372
 
373
    function Stroke(&$img, $pos, &$scale, $startangle) {
374
	$nbrpnts = count($this->data);
375
	$astep=2*M_PI/$nbrpnts;
376
	$a=$startangle;
377
 
378
	// Rotate each point to the correct axis-angle
379
	// TODO: Update for LogScale
380
	for($i=0; $i<$nbrpnts; ++$i) {
381
	    //$c=$this->data[$i];
382
	    $cs=$scale->RelTranslate($this->data[$i]);
383
	    $x=round($cs*cos($a)+$scale->scale_abs[0]);
384
	    $y=round($pos-$cs*sin($a));
385
	    /*
386
	      $c=log10($c);
387
	      $x=round(($c-$scale->scale[0])*$scale->scale_factor*cos($a)+$scale->scale_abs[0]);
388
	      $y=round($pos-($c-$scale->scale[0])*$scale->scale_factor*sin($a));
389
	    */
390
	    $pnts[$i*2]=$x;
391
	    $pnts[$i*2+1]=$y;
392
	    $a += $astep;
393
	}
394
	if( $this->fill ) {
395
	    $img->SetColor($this->fill_color);
396
	    $img->FilledPolygon($pnts);
397
	}
398
	$img->SetLineWeight($this->weight);
399
	$img->SetColor($this->color);
400
	$img->SetLineStyle($this->linestyle);
401
	$pnts[]=$pnts[0];
402
	$pnts[]=$pnts[1];
403
	$img->Polygon($pnts);
404
	$img->SetLineStyle('solid'); // Reset line style to default
405
	// Add plotmarks on top
406
	if( $this->mark->show ) {
407
	    for($i=0; $i < $nbrpnts; ++$i) {
408
		$this->mark->Stroke($img,$pnts[$i*2],$pnts[$i*2+1]);
409
	    }
410
	}
411
 
412
    }
413
 
414
//---------------
415
// PRIVATE METHODS
416
    function GetCount() {
417
	return count($this->data);
418
    }
419
 
420
    function Legend(&$graph) {
421
	if( $this->legend=="" ) return;
422
	if( $this->fill )
423
	    $graph->legend->Add($this->legend,$this->fill_color,$this->mark);
424
	else
425
	    $graph->legend->Add($this->legend,$this->color,$this->mark);
426
    }
427
 
428
} // Class
429
 
430
//===================================================
431
// CLASS RadarGraph
432
// Description: Main container for a radar graph
433
//===================================================
434
class RadarGraph extends Graph {
435
    var $posx;
436
    var $posy;
437
    var $len;
438
    var $plots=null, $axis_title=null;
439
    var $grid,$axis=null;
440
//---------------
441
// CONSTRUCTOR
442
    function RadarGraph($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) {
443
	$this->Graph($width,$height,$cachedName,$timeout,$inline);
444
	$this->posx=$width/2;
445
	$this->posy=$height/2;
446
	$this->len=min($width,$height)*0.35;
447
	$this->SetColor(array(255,255,255));
448
	$this->SetTickDensity(TICKD_NORMAL);
449
	$this->SetScale("lin");
450
	$this->SetGridDepth(DEPTH_FRONT);
451
 
452
    }
453
 
454
//---------------
455
// PUBLIC METHODS
456
    function SupressTickMarks($f=true) {
457
    	if( ERR_DEPRECATED )
458
	    JpGraphError::RaiseL(18002);
459
//('RadarGraph::SupressTickMarks() is deprecated. Use HideTickMarks() instead.');
460
	$this->axis->scale->ticks->SupressTickMarks($f);
461
    }
462
 
463
    function HideTickMarks($aFlag=true) {
464
		$this->axis->scale->ticks->SupressTickMarks($aFlag);
465
    }
466
 
467
    function ShowMinorTickmarks($aFlag=true) {
468
    	$this->yscale->ticks->SupressMinorTickMarks(!$aFlag);
469
    }
470
 
471
    function SetScale($axtype,$ymin=1,$ymax=1) {
472
	if( $axtype != "lin" && $axtype != "log" ) {
473
	    JpGraphError::RaiseL(18003,$axtype);
474
//("Illegal scale for radarplot ($axtype). Must be \"lin\" or \"log\"");
475
	}
476
	if( $axtype=="lin" ) {
477
	    $this->yscale = & new LinearScale($ymin,$ymax);
478
	    $this->yscale->ticks = & new RadarLinearTicks();
479
	    $this->yscale->ticks->SupressMinorTickMarks();
480
	}
481
	elseif( $axtype=="log" ) {
482
	    $this->yscale = & new LogScale($ymin,$ymax);
483
	    $this->yscale->ticks = & new RadarLogTicks();
484
	}
485
 
486
	$this->axis = & new RadarAxis($this->img,$this->yscale);
487
	$this->grid = & new RadarGrid();
488
    }
489
 
490
    function SetSize($aSize) {
491
	if( $aSize < 0.1 || $aSize>1 )
492
	    JpGraphError::RaiseL(18004,$aSize);
493
//("Radar Plot size must be between 0.1 and 1. (Your value=$s)");
494
	$this->len=min($this->img->width,$this->img->height)*$aSize/2;
495
    }
496
 
497
    function SetPlotSize($aSize) {
498
	$this->SetSize($aSize);
499
    }
500
 
501
    function SetTickDensity($densy=TICKD_NORMAL) {
502
	$this->ytick_factor=25;
503
	switch( $densy ) {
504
	    case TICKD_DENSE:
505
		$this->ytick_factor=12;
506
	    break;
507
	    case TICKD_NORMAL:
508
		$this->ytick_factor=25;
509
	    break;
510
	    case TICKD_SPARSE:
511
		$this->ytick_factor=40;
512
	    break;
513
	    case TICKD_VERYSPARSE:
514
		$this->ytick_factor=70;
515
	    break;
516
	    default:
517
		JpGraphError::RaiseL(18005,$densy);
518
//("RadarPlot Unsupported Tick density: $densy");
519
	}
520
    }
521
 
522
    function SetPos($px,$py=0.5) {
523
	$this->SetCenter($px,$py);
524
    }
525
 
526
    function SetCenter($px,$py=0.5) {
527
	assert($px > 0 && $py > 0 );
528
	$this->posx=$this->img->width*$px;
529
	$this->posy=$this->img->height*$py;
530
    }
531
 
532
    function SetColor($c) {
533
	$this->SetMarginColor($c);
534
    }
535
 
536
    function SetTitles($title) {
537
	$this->axis_title = $title;
538
    }
539
 
540
    function Add(&$splot) {
541
	$this->plots[]=$splot;
542
    }
543
 
544
    function GetPlotsYMinMax() {
545
	$min=$this->plots[0]->Min();
546
	$max=$this->plots[0]->Max();
547
	foreach( $this->plots as $p ) {
548
	    $max=max($max,$p->Max());
549
	    $min=min($min,$p->Min());
550
	}
551
	if( $min < 0 )
552
	    JpGraphError::RaiseL(18006,$min);
553
//("Minimum data $min (Radar plots should only be used when all data points > 0)");
554
	return array($min,$max);
555
    }
556
 
557
    // Stroke the Radar graph
558
    function Stroke($aStrokeFileName="") {
559
	$n = count($this->plots);
560
	// Set Y-scale
561
	if( !$this->yscale->IsSpecified() && count($this->plots)>0 ) {
562
	    list($min,$max) = $this->GetPlotsYMinMax();
563
	    $this->yscale->AutoScale($this->img,0,$max,$this->len/$this->ytick_factor);
564
	}
565
	elseif( $this->yscale->IsSpecified() &&
566
		( $this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified()) ) {
567
	    // The tick calculation will use the user suplied min/max values to determine
568
	    // the ticks. If auto_ticks is false the exact user specifed min and max
569
	    // values will be used for the scale.
570
	    // If auto_ticks is true then the scale might be slightly adjusted
571
	    // so that the min and max values falls on an even major step.
572
	    $min = $this->yscale->scale[0];
573
	    $max = $this->yscale->scale[1];
574
	    $this->yscale->AutoScale($this->img,$min,$max,
575
				     $this->len/$this->ytick_factor,
576
				     $this->yscale->auto_ticks);
577
	}
578
 
579
	// Set start position end length of scale (in absolute pixels)
580
	$this->yscale->SetConstants($this->posx,$this->len);
581
 
582
	// We need as many axis as there are data points
583
	$nbrpnts=$this->plots[0]->GetCount();
584
 
585
	// If we have no titles just number the axis 1,2,3,...
586
	if( $this->axis_title==null ) {
587
	    for($i=0; $i < $nbrpnts; ++$i )
588
		$this->axis_title[$i] = $i+1;
589
	}
590
	elseif(count($this->axis_title)<$nbrpnts)
591
	    JpGraphError::RaiseL(18007);
592
//("Number of titles does not match number of points in plot.");
593
	for($i=0; $i < $n; ++$i )
594
	    if( $nbrpnts != $this->plots[$i]->GetCount() )
595
		JpGraphError::RaiseL(18008);
596
//("Each radar plot must have the same number of data points.");
597
 
598
	if( $this->background_image != "" ) {
599
	    $this->StrokeFrameBackground();
600
	}
601
	else {
602
	    $this->StrokeFrame();
603
	}
604
	$astep=2*M_PI/$nbrpnts;
605
 
606
	// Prepare legends
607
	for($i=0; $i < $n; ++$i)
608
	    $this->plots[$i]->Legend($this);
609
	$this->legend->Stroke($this->img);
610
	$this->footer->Stroke($this->img);
611
 
612
	if( $this->grid_depth == DEPTH_BACK ) {
613
	    // Draw axis and grid
614
	    for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) {
615
		$this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0);
616
	    }
617
	}
618
 
619
	// Plot points
620
	$a=M_PI/2;
621
	for($i=0; $i < $n; ++$i )
622
	    $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a);
623
 
624
	if( $this->grid_depth != DEPTH_BACK ) {
625
	    // Draw axis and grid
626
	    for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) {
627
		$this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0);
628
	    }
629
	}
630
	$this->grid->Stroke($this->img,$grid);
631
	$this->StrokeTitles();
632
 
633
	// Stroke texts
634
	if( $this->texts != null ) {
635
	    foreach( $this->texts as $t)
636
		$t->Stroke($this->img);
637
	}
638
 
639
	// Should we do any final image transformation
640
	if( $this->iImgTrans ) {
641
	    if( !class_exists('ImgTrans') ) {
642
		require_once('jpgraph_imgtrans.php');
643
	    }
644
 
645
	    $tform = new ImgTrans($this->img->img);
646
	    $this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist,
647
					     $this->iImgTransDirection,$this->iImgTransHighQ,
648
					     $this->iImgTransMinSize,$this->iImgTransFillColor,
649
					     $this->iImgTransBorder);
650
	}
651
 
652
	// If the filename is given as the special "__handle"
653
	// then the image handler is returned and the image is NOT
654
	// streamed back
655
	if( $aStrokeFileName == _IMG_HANDLER ) {
656
	    return $this->img->img;
657
	    }
658
	else {
659
	    // Finally stream the generated picture
660
	    $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,
661
				       $aStrokeFileName);
662
	}
663
    }
664
} // Class
665
 
666
/* EOF */
667
?>