Passed
Branch master (380e00)
by Greg
20:17
created

statisticsplot.php (8 issues)

1
<?php
2
/**
3
 * webtrees: online genealogy
4
 * Copyright (C) 2017 webtrees development team
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 * GNU General Public License for more details.
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15
 */
16
namespace Fisharebest\Webtrees;
17
18
use Fisharebest\Webtrees\Date\GregorianDate;
19
20
/** @global Tree $WT_TREE */
21
22
global $WT_TREE;
23
24
require 'includes/session.php';
25
26
/**
27
 * Month of birth
28
 *
29
 * @param int   $z_axis
30
 * @param int[] $z_boundaries
31
 * @param Stats $stats
32
 *
33
 * @return int
34
 */
35 View Code Duplication
function month_of_birth($z_axis, array $z_boundaries, Stats $stats) {
36
	$total = 0;
37
38
	if ($z_axis === 300) {
39
		$num = $stats->statsBirthQuery(false);
40
		foreach ($num as $values) {
41
			foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
42
				if ($month === $values['d_month']) {
43
					fill_y_data(0, $key, $values['total']);
44
					$total += $values['total'];
45
				}
46
			}
47
		}
48
	} elseif ($z_axis === 301) {
49
		$num = $stats->statsBirthQuery(false, true);
50
		foreach ($num as $values) {
51
			foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
52
				if ($month === $values['d_month']) {
53
					if ($values['i_sex'] === 'M') {
54
						fill_y_data(0, $key, $values['total']);
55
						$total += $values['total'];
56
					} elseif ($values['i_sex'] === 'F') {
57
						fill_y_data(1, $key, $values['total']);
58
						$total += $values['total'];
59
					}
60
				}
61
			}
62
		}
63
	} else {
64
		$zstart = 0;
65
		foreach ($z_boundaries as $boundary) {
66
			$num = $stats->statsBirthQuery(false, false, $zstart, $boundary);
67
			foreach ($num as $values) {
68
				foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
69
					if ($month === $values['d_month']) {
70
						fill_y_data($boundary, $key, $values['total']);
71
						$total += $values['total'];
72
					}
73
				}
74
			}
75
			$zstart = $boundary + 1;
76
		}
77
	}
78
79
	return $total;
80
}
81
82
/**
83
 * Month of birth of first child in a relation
84
 *
85
 * @param int   $z_axis
86
 * @param int[] $z_boundaries
87
 * @param Stats $stats
88
 *
89
 * @return int
90
 */
91 View Code Duplication
function month_of_birth_of_first_child($z_axis, array $z_boundaries, Stats $stats) {
92
	$total = 0;
93
94
	if ($z_axis === 300) {
95
		$num = $stats->monthFirstChildQuery(false);
96
		foreach ($num as $values) {
97
			foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
98
				if ($month === $values['d_month']) {
99
					fill_y_data(0, $key, $values['total']);
100
					$total += $values['total'];
101
				}
102
			}
103
		}
104
	} elseif ($z_axis === 301) {
105
		$num = $stats->monthFirstChildQuery(false, true);
106
		foreach ($num as $values) {
107
			foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
108
				if ($month === $values['d_month']) {
109
					if ($values['i_sex'] === 'M') {
110
						fill_y_data(0, $key, $values['total']);
111
						$total += $values['total'];
112
					} elseif ($values['i_sex'] === 'F') {
113
						fill_y_data(1, $key, $values['total']);
114
						$total += $values['total'];
115
					}
116
				}
117
			}
118
		}
119
	} else {
120
		$zstart = 0;
121
		foreach ($z_boundaries as $boundary) {
122
			$num = $stats->monthFirstChildQuery(false, false, $zstart, $boundary);
123
			foreach ($num as $values) {
124
				foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
125
					if ($month === $values['d_month']) {
126
						fill_y_data($boundary, $key, $values['total']);
127
						$total += $values['total'];
128
					}
129
				}
130
			}
131
			$zstart = $boundary + 1;
132
		}
133
	}
134
135
	return $total;
136
}
137
138
/**
139
 * Month of death
140
 *
141
 * @param int   $z_axis
142
 * @param int[] $z_boundaries
143
 * @param Stats $stats
144
 *
145
 * @return int
146
 */
147 View Code Duplication
function month_of_death($z_axis, array $z_boundaries, Stats $stats) {
148
	$total = 0;
149
150
	if ($z_axis === 300) {
151
		$num = $stats->statsDeathQuery(false);
152
		foreach ($num as $values) {
153
			foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
154
				if ($month === $values['d_month']) {
155
					fill_y_data(0, $key, $values['total']);
156
					$total += $values['total'];
157
				}
158
			}
159
		}
160
	} elseif ($z_axis === 301) {
161
		$num = $stats->statsDeathQuery(false, true);
162
		foreach ($num as $values) {
163
			foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
164
				if ($month === $values['d_month']) {
165
					if ($values['i_sex'] === 'M') {
166
						fill_y_data(0, $key, $values['total']);
167
						$total += $values['total'];
168
					} elseif ($values['i_sex'] === 'F') {
169
						fill_y_data(1, $key, $values['total']);
170
						$total += $values['total'];
171
					}
172
				}
173
			}
174
		}
175
	} else {
176
		$zstart = 0;
177
		foreach ($z_boundaries as $boundary) {
178
			$num = $stats->statsDeathQuery(false, false, $zstart, $boundary);
179
			foreach ($num as $values) {
180
				foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
181
					if ($month === $values['d_month']) {
182
						fill_y_data($boundary, $key, $values['total']);
183
						$total += $values['total'];
184
					}
185
				}
186
			}
187
			$zstart = $boundary + 1;
188
		}
189
	}
190
191
	return $total;
192
}
193
194
/**
195
 * Month of marriage
196
 *
197
 * @param int   $z_axis
198
 * @param int[] $z_boundaries
199
 * @param Stats $stats
200
 *
201
 * @return int
202
 */
203
function month_of_marriage($z_axis, array $z_boundaries, Stats $stats) {
204
	$total = 0;
205
206
	if ($z_axis === 300) {
207
		$num = $stats->statsMarrQuery(false, false);
208
		foreach ($num as $values) {
0 ignored issues
show
The expression $num of type string is not traversable.
Loading history...
209
			foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
210
				if ($month === $values['d_month']) {
211
					fill_y_data(0, $key, $values['total']);
212
					$total += $values['total'];
213
				}
214
			}
215
		}
216
	} else {
217
		$zstart = 0;
218
		foreach ($z_boundaries as $boundary) {
219
			$num = $stats->statsMarrQuery(false, false, $zstart, $boundary);
220
			foreach ($num as $values) {
0 ignored issues
show
The expression $num of type string is not traversable.
Loading history...
221
				foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
222
					if ($month === $values['d_month']) {
223
						fill_y_data($boundary, $key, $values['total']);
224
						$total += $values['total'];
225
					}
226
				}
227
			}
228
			$zstart = $boundary + 1;
229
		}
230
	}
231
232
	return $total;
233
}
234
235
/**
236
 * Month of first marriage
237
 *
238
 * @param int   $z_axis
239
 * @param int[] $z_boundaries
240
 * @param Stats $stats
241
 *
242
 * @return int
243
 */
244
function month_of_first_marriage($z_axis, array $z_boundaries, Stats $stats) {
245
	$total = 0;
246
247
	if ($z_axis === 300) {
248
		$num  = $stats->statsMarrQuery(false, true);
249
		$indi = [];
250
		$fam  = [];
251 View Code Duplication
		foreach ($num as $values) {
0 ignored issues
show
The expression $num of type string is not traversable.
Loading history...
252
			if (!in_array($values['indi'], $indi) && !in_array($values['fams'], $fam)) {
253
				foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
254
					if ($month === $values['month']) {
255
						fill_y_data(0, $key, 1);
256
						$total++;
257
					}
258
				}
259
				$indi[] = $values['indi'];
260
				$fam[]  = $values['fams'];
261
			}
262
		}
263
	} else {
264
		$zstart = 0;
265
		$indi   = [];
266
		$fam    = [];
267
		foreach ($z_boundaries as $boundary) {
268
			$num = $stats->statsMarrQuery(false, true, $zstart, $boundary);
269 View Code Duplication
			foreach ($num as $values) {
0 ignored issues
show
The expression $num of type string is not traversable.
Loading history...
270
				if (!in_array($values['indi'], $indi) && !in_array($values['fams'], $fam)) {
271
					foreach (['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] as $key => $month) {
272
						if ($month === $values['month']) {
273
							fill_y_data($boundary, $key, 1);
274
							$total++;
275
						}
276
					}
277
					$indi[] = $values['indi'];
278
					$fam[]  = $values['fams'];
279
				}
280
			}
281
			$zstart = $boundary + 1;
282
		}
283
	}
284
285
	return $total;
286
}
287
288
/**
289
 * Longevity versus time
290
 *
291
 * @param int   $z_axis
292
 * @param int[] $z_boundaries
293
 * @param Stats $stats
294
 *
295
 * @return int
296
 */
297
function longevity_versus_time($z_axis, array $z_boundaries, Stats $stats) {
298
	$total = 0;
299
300
	if ($z_axis === 300) {
301
		$num = $stats->statsAgeQuery(false, 'DEAT');
302
		foreach ($num as $values) {
303
			foreach ($values as $age_value) {
304
				fill_y_data(0, (int) ($age_value / 365.25), 1);
305
				$total++;
306
			}
307
		}
308
	} elseif ($z_axis === 301) {
309
		$num = $stats->statsAgeQuery(false, 'DEAT', 'M');
310
		foreach ($num as $values) {
311
			foreach ($values as $age_value) {
312
				fill_y_data(0, (int) ($age_value / 365.25), 1);
313
				$total++;
314
			}
315
		}
316
		$num = $stats->statsAgeQuery(false, 'DEAT', 'F');
317
		foreach ($num as $values) {
318
			foreach ($values as $age_value) {
319
				fill_y_data(1, (int) ($age_value / 365.25), 1);
320
				$total++;
321
			}
322
		}
323
	} else {
324
		$zstart = 0;
325
		foreach ($z_boundaries as $boundary) {
326
			$num = $stats->statsAgeQuery(false, 'DEAT', 'BOTH', $zstart, $boundary);
327
			foreach ($num as $values) {
328
				foreach ($values as $age_value) {
329
					fill_y_data($boundary, (int) ($age_value / 365.25), 1);
330
					$total++;
331
				}
332
			}
333
			$zstart = $boundary + 1;
334
		}
335
	}
336
337
	return $total;
338
}
339
340
/**
341
 * Age in year of marriage
342
 *
343
 * @param int   $z_axis
344
 * @param int[] $z_boundaries
345
 * @param Stats $stats
346
 *
347
 * @return int
348
 */
349
function age_at_marriage($z_axis, array $z_boundaries, Stats $stats) {
350
	$total = 0;
351
352
	if ($z_axis === 300) {
353
		$num = $stats->statsMarrAgeQuery(false, 'M');
354
		foreach ($num as $values) {
355
			fill_y_data(0, (int) ($values['age'] / 365.25), 1);
356
			$total++;
357
		}
358
		$num = $stats->statsMarrAgeQuery(false, 'F');
359
		foreach ($num as $values) {
360
			fill_y_data(0, (int) ($values['age'] / 365.25), 1);
361
			$total++;
362
		}
363
	} elseif ($z_axis === 301) {
364
		$num = $stats->statsMarrAgeQuery(false, 'M');
365
		foreach ($num as $values) {
366
			fill_y_data(0, (int) ($values['age'] / 365.25), 1);
367
			$total++;
368
		}
369
		$num = $stats->statsMarrAgeQuery(false, 'F');
370
		foreach ($num as $values) {
371
			fill_y_data(1, (int) ($values['age'] / 365.25), 1);
372
			$total++;
373
		}
374
	} else {
375
		$zstart = 0;
376
		foreach ($z_boundaries as $boundary) {
377
			$num = $stats->statsMarrAgeQuery(false, 'M', $zstart, $boundary);
378
			foreach ($num as $values) {
379
				fill_y_data($boundary, (int) ($values['age'] / 365.25), 1);
380
				$total++;
381
			}
382
			$num = $stats->statsMarrAgeQuery(false, 'F', $zstart, $boundary);
383
			foreach ($num as $values) {
384
				fill_y_data($boundary, (int) ($values['age'] / 365.25), 1);
385
				$total++;
386
			}
387
			$zstart = $boundary + 1;
388
		}
389
	}
390
391
	return $total;
392
}
393
394
/**
395
 * Age in year of first marriage
396
 *
397
 * @param int   $z_axis
398
 * @param int[] $z_boundaries
399
 * @param Stats $stats
400
 *
401
 * @return int
402
 */
403
function age_at_first_marriage($z_axis, array $z_boundaries, Stats $stats) {
404
	$total = 0;
405
406
	if ($z_axis === 300) {
407
		$num  = $stats->statsMarrAgeQuery(false, 'M');
408
		$indi = [];
409 View Code Duplication
		foreach ($num as $values) {
410
			if (!in_array($values['d_gid'], $indi)) {
411
				fill_y_data(0, (int) ($values['age'] / 365.25), 1);
412
				$total++;
413
				$indi[] = $values['d_gid'];
414
			}
415
		}
416
		$num  = $stats->statsMarrAgeQuery(false, 'F');
417
		$indi = [];
418 View Code Duplication
		foreach ($num as $values) {
419
			if (!in_array($values['d_gid'], $indi)) {
420
				fill_y_data(0, (int) ($values['age'] / 365.25), 1);
421
				$total++;
422
				$indi[] = $values['d_gid'];
423
			}
424
		}
425
	} elseif ($z_axis === 301) {
426
		$num  = $stats->statsMarrAgeQuery(false, 'M');
427
		$indi = [];
428 View Code Duplication
		foreach ($num as $values) {
429
			if (!in_array($values['d_gid'], $indi)) {
430
				fill_y_data(0, (int) ($values['age'] / 365.25), 1);
431
				$total++;
432
				$indi[] = $values['d_gid'];
433
			}
434
		}
435
		$num  = $stats->statsMarrAgeQuery(false, 'F');
436
		$indi = [];
437 View Code Duplication
		foreach ($num as $values) {
438
			if (!in_array($values['d_gid'], $indi)) {
439
				fill_y_data(1, (int) ($values['age'] / 365.25), 1);
440
				$total++;
441
				$indi[] = $values['d_gid'];
442
			}
443
		}
444
	} else {
445
		$zstart = 0;
446
		$indi   = [];
447
		foreach ($z_boundaries as $boundary) {
448
			$num = $stats->statsMarrAgeQuery(false, 'M', $zstart, $boundary);
449 View Code Duplication
			foreach ($num as $values) {
450
				if (!in_array($values['d_gid'], $indi)) {
451
					fill_y_data($boundary, (int) ($values['age'] / 365.25), 1);
452
					$total++;
453
					$indi[] = $values['d_gid'];
454
				}
455
			}
456
			$num = $stats->statsMarrAgeQuery(false, 'F', $zstart, $boundary);
457 View Code Duplication
			foreach ($num as $values) {
458
				if (!in_array($values['d_gid'], $indi)) {
459
					fill_y_data($boundary, (int) ($values['age'] / 365.25), 1);
460
					$total++;
461
					$indi[] = $values['d_gid'];
462
				}
463
			}
464
			$zstart = $boundary + 1;
465
		}
466
	}
467
468
	return $total;
469
}
470
471
/**
472
 * Number of children
473
 *
474
 * @param int   $z_axis
475
 * @param int[] $z_boundaries
476
 * @param Stats $stats
477
 *
478
 * @return int
479
 */
480
function number_of_children($z_axis, array $z_boundaries, Stats $stats) {
481
	$total = 0;
482
483
	if ($z_axis === 300) {
484
		$num = $stats->statsChildrenQuery(false);
485 View Code Duplication
		foreach ($num as $values) {
486
			fill_y_data(0, $values['f_numchil'], $values['total']);
0 ignored issues
show
$values['f_numchil'] of type string is incompatible with the type integer expected by parameter $x of fill_y_data(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

486
			fill_y_data(0, /** @scrutinizer ignore-type */ $values['f_numchil'], $values['total']);
Loading history...
$values['total'] of type string is incompatible with the type integer expected by parameter $val of fill_y_data(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

486
			fill_y_data(0, $values['f_numchil'], /** @scrutinizer ignore-type */ $values['total']);
Loading history...
487
			$total += $values['f_numchil'] * $values['total'];
488
		}
489
	} elseif ($z_axis === 301) {
490
		$num = $stats->statsChildrenQuery(false, 'M');
491 View Code Duplication
		foreach ($num as $values) {
492
			fill_y_data(0, $values['num'], $values['total']);
493
			$total += $values['num'] * $values['total'];
494
		}
495
		$num = $stats->statsChildrenQuery(false, 'F');
496 View Code Duplication
		foreach ($num as $values) {
497
			fill_y_data(1, $values['num'], $values['total']);
498
			$total += $values['num'] * $values['total'];
499
		}
500
	} else {
501
		$zstart = 0;
502
		foreach ($z_boundaries as $boundary) {
503
			$num = $stats->statsChildrenQuery(false, 'BOTH', $zstart, $boundary);
504 View Code Duplication
			foreach ($num as $values) {
505
				fill_y_data($boundary, $values['f_numchil'], $values['total']);
506
				$total += $values['f_numchil'] * $values['total'];
507
			}
508
			$zstart = $boundary + 1;
509
		}
510
	}
511
512
	return $total;
513
}
514
515
/**
516
 * Calculate the Y axis.
517
 *
518
 * @param int $z
519
 * @param int $x
520
 * @param int $val
521
 */
522
function fill_y_data($z, $x, $val) {
523
	global $ydata, $xmax, $x_boundaries, $zmax, $z_boundaries, $xgiven, $zgiven;
524
	//-- calculate index $i out of given z value
525
	//-- calculate index $j out of given x value
526
	if ($xgiven) {
527
		$j = $x;
528
	} else {
529
		$j = 0;
530
		while (($x > $x_boundaries[$j]) && ($j < $xmax)) {
531
			$j++;
532
		}
533
	}
534
	if ($zgiven) {
535
		$i = $z;
536
	} else {
537
		$i = 0;
538
		while (($z > $z_boundaries[$i]) && ($i < $zmax)) {
539
			$i++;
540
		}
541
	}
542
	if (isset($ydata[$i][$j])) {
543
		$ydata[$i][$j] += $val;
544
	} else {
545
		$ydata[$i][$j] = $val;
546
	}
547
}
548
549
/**
550
 * Plot the data.
551
 *
552
 * @param string      $chart_title
553
 * @param integer[][] $xdata
554
 * @param string      $xtitle
555
 * @param integer[][] $ydata
556
 * @param string      $ytitle
557
 * @param string[]    $legend
558
 */
559
function my_plot($chart_title, $xdata, $xtitle, $ydata, $ytitle, $legend) {
560
	global $percentage, $male_female, $ymax, $scalefactor, $datastring, $imgurl;
561
562
	// Google Chart API only allows text encoding for numbers less than 100
563
	// and it does not allow adjusting the y-axis range, so we must find the maximum y-value
564
	// in order to adjust beforehand by changing the numbers
565
566
	if ($male_female) {
567
		$stop = 2;
568
	} else {
569
		$stop = count($ydata);
570
	}
571
	if ($percentage) {
572
		$ypercentmax = 0;
573
		$yt          = [];
574
		for ($i = 0; $i < $stop; $i++) {
575
			if (isset($ydata[$i])) {
576
				$ymax   = max($ydata[$i]);
577
				$yt[$i] = array_sum($ydata[$i]);
578
				if ($yt[$i] > 0) {
579
					$ypercent    = round($ymax / $yt[$i] * 100, 1);
580
					$ypercentmax = max($ypercentmax, $ypercent);
581
				}
582
			}
583
		}
584
		$ymax = $ypercentmax;
585
		if ($ymax > 0) {
586
			$scalefactor = 100.0 / $ymax;
587
		} else {
588
			$scalefactor = 0;
589
		}
590
		$datastring = 'chd=t:';
591
		for ($i = 0; $i < $stop; $i++) {
592
			if (isset($ydata[$i])) {
593
				foreach ($ydata[$i] as $j => $data) {
594
					if ($j > 0) {
595
						$datastring .= ',';
596
					}
597
					if ($yt[$i] > 0) {
598
						$datastring .= round($data / $yt[$i] * 100 * $scalefactor, 1);
599
					} else {
600
						$datastring .= '0';
601
					}
602
				}
603
				if ($i !== $stop - 1) {
604
					$datastring .= '|';
605
				}
606
			}
607
		}
608
	} else {
609
		for ($i = 0; $i < $stop; $i++) {
610
			$ymax = max($ymax, max($ydata[$i]));
611
		}
612
		if ($ymax > 0) {
613
			$scalefactor = 100.0 / $ymax;
614
		} else {
615
			$scalefactor = 0;
616
		}
617
		$datastring = 'chd=t:';
618
		for ($i = 0; $i < $stop; $i++) {
619
			foreach ($ydata[$i] as $j => $data) {
620
				if ($j > 0) {
621
					$datastring .= ',';
622
				}
623
				$datastring .= round($data * $scalefactor, 1);
624
			}
625
			if ($i !== $stop - 1) {
626
				$datastring .= '|';
627
			}
628
		}
629
	}
630
	$colors      = ['0000FF', 'FFA0CB', '9F00FF', 'FF7000', '905030', 'FF0000', '00FF00', 'F0F000'];
631
	$colorstring = 'chco=';
632
	for ($i = 0; $i < $stop; $i++) {
633
		if (isset($colors[$i])) {
634
			$colorstring .= $colors[$i];
635
			if ($i !== ($stop - 1)) {
636
				$colorstring .= ',';
637
			}
638
		}
639
	}
640
641
	$imgurl = 'https://chart.googleapis.com/chart?cht=bvg&amp;chs=950x300&amp;chf=bg,s,ffffff00|c,s,ffffff00&amp;chtt=' . rawurlencode($chart_title) . '&amp;' . $datastring . '&amp;' . $colorstring . '&amp;chbh=';
642
	if (count($ydata) > 3) {
643
		$imgurl .= '5,1';
644
	} elseif (count($ydata) < 2) {
645
		$imgurl .= '45,1';
646
	} else {
647
		$imgurl .= '20,3';
648
	}
649
	$imgurl .= '&amp;chxt=x,x,y,y&amp;chxl=0:|';
650
	foreach ($xdata as $data) {
651
		$imgurl .= rawurlencode($data) . '|';
0 ignored issues
show
$data of type integer[] is incompatible with the type string expected by parameter $str of rawurlencode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

651
		$imgurl .= rawurlencode(/** @scrutinizer ignore-type */ $data) . '|';
Loading history...
652
	}
653
654
	$imgurl .= '1:||||' . rawurlencode($xtitle) . '|2:|';
655
	$imgurl .= '0|';
656
	if ($percentage) {
657
		for ($i = 1; $i < 11; $i++) {
658
			if ($ymax < 11) {
659
				$imgurl .= round($ymax * $i / 10, 1) . '|';
660
			} else {
661
				$imgurl .= round($ymax * $i / 10, 0) . '|';
662
			}
663
		}
664
		$imgurl .= '3:||%|';
665
	} else {
666
		if ($ymax < 11) {
667 View Code Duplication
			for ($i = 1; $i < $ymax + 1; $i++) {
668
				$imgurl .= round($ymax * $i / ($ymax), 0) . '|';
669
			}
670
		} else {
671 View Code Duplication
			for ($i = 1; $i < 11; $i++) {
672
				$imgurl .= round($ymax * $i / 10, 0) . '|';
673
			}
674
		}
675
		$imgurl .= '3:||' . rawurlencode($ytitle) . '|';
676
	}
677
	// Only show legend if y-data is non-2-dimensional
678
	if (count($ydata) > 1) {
679
		$imgurl .= '&amp;chdl=';
680
		foreach ($legend as $i => $data) {
681
			if ($i > 0) {
682
				$imgurl .= '|';
683
			}
684
			$imgurl .= rawurlencode($data);
685
		}
686
	}
687
	echo '<img src="', $imgurl, '" width="950" height="300" alt="', Html::escape($chart_title), '">';
688
}
689
690
/**
691
 * Create the X azxs.
692
 *
693
 * @param string $x_axis_boundaries
694
 */
695
function calculate_axis($x_axis_boundaries) {
696
	global $x_axis, $xdata, $xmax, $x_boundaries;
697
698
	// Calculate xdata and zdata elements out of chart values
699
	$hulpar = explode(',', $x_axis_boundaries);
700
	$i      = 1;
701
	if ($x_axis === 21 && $hulpar[0] == 1) {
702
		$xdata[0] = 0;
703
	} else {
704
		$xdata[0] = format_range_of_numbers(0, $hulpar[0]);
705
	}
706
	$x_boundaries[0] = $hulpar[0] - 1;
707
	while (isset($hulpar[$i])) {
708
		$i1 = $i - 1;
709
		if (($hulpar[$i] - $hulpar[$i1]) === 1) {
710
			$xdata[$i]        = $hulpar[$i1];
711
			$x_boundaries[$i] = $hulpar[$i1];
712
		} elseif ($hulpar[$i1] === $hulpar[0]) {
713
			$xdata[$i]        = format_range_of_numbers($hulpar[$i1], $hulpar[$i]);
714
			$x_boundaries[$i] = $hulpar[$i];
715
		} else {
716
			$xdata[$i]        = format_range_of_numbers($hulpar[$i1] + 1, $hulpar[$i]);
717
			$x_boundaries[$i] = $hulpar[$i];
718
		}
719
		$i++;
720
	}
721
	$xdata[$i]        = $hulpar[$i - 1];
722
	$x_boundaries[$i] = $hulpar[$i - 1];
723
	if ($hulpar[$i - 1] === $i) {
724
		$xmax = $i + 1;
725
	} else {
726
		$xmax = $i;
727
	}
728
	$xdata[$xmax]        = /* I18N: Label on a graph; 40+ means 40 or more */ I18N::translate('%s+', I18N::number($hulpar[$i - 1]));
729
	$x_boundaries[$xmax] = 10000;
730
	$xmax                = $xmax + 1;
731
	if ($xmax > 20) {
732
		$xmax = 20;
733
	}
734
}
735
736
/**
737
 * A range of integers.
738
 *
739
 * @param int $x
740
 * @param int $y
741
 *
742
 * @return string
743
 */
744
function format_range_of_numbers($x, $y) {
745
	return /* I18N: A range of numbers */ I18N::translate(
746
		'%1$s–%2$s',
747
		I18N::number($x),
748
		I18N::number($y)
749
	);
750
}
751
752
/**
753
 * Calculate the Z axis.
754
 *
755
 * @param string $boundaries_z_axis
756
 */
757
function calculate_legend($boundaries_z_axis) {
758
	global $legend, $zmax, $z_boundaries;
759
760
	// calculate the legend values
761
	$hulpar          = explode(',', $boundaries_z_axis);
762
	$i               = 1;
763
	$date            = new Date('BEF ' . $hulpar[0]);
764
	$legend[0]       = strip_tags($date->display());
765
	$z_boundaries[0] = $hulpar[0] - 1;
766
	while (isset($hulpar[$i])) {
767
		$i1               = $i - 1;
768
		$date             = new Date('BET ' . $hulpar[$i1] . ' AND ' . ($hulpar[$i] - 1));
769
		$legend[$i]       = strip_tags($date->display());
770
		$z_boundaries[$i] = $hulpar[$i] - 1;
771
		$i++;
772
	}
773
	$zmax                = $i;
774
	$zmax1               = $zmax - 1;
775
	$date                = new Date('AFT ' . $hulpar[$zmax1]);
776
	$legend[$zmax]       = strip_tags($date->display());
777
	$z_boundaries[$zmax] = 10000;
778
	$zmax                = $zmax + 1;
779
	if ($zmax > 8) {
780
		$zmax = 8;
781
	}
782
}
783
784
global $legend, $xdata, $ydata, $xmax, $zmax, $z_boundaries, $xgiven, $zgiven, $percentage, $male_female;
785
786
$x_axis       = Filter::getInteger('x-as', 1, 21, 11);
787
$y_axis       = Filter::getInteger('y-as', 201, 202, 201);
788
$z_axis       = Filter::getInteger('z-as', 300, 302, 302);
789
$stats        = new Stats($WT_TREE);
790
$z_boundaries = [];
791
792
echo '<div class="statistics_chart" title="', I18N::translate('Statistics chart'), '">';
793
794
switch ($x_axis) {
795
case '1':
796
	echo $stats->chartDistribution([Filter::get('chart_shows'), Filter::get('chart_type'), Filter::get('SURN')]);
797
	break;
798
case '2':
799
	echo $stats->chartDistribution([Filter::get('chart_shows'), 'birth_distribution_chart']);
800
	break;
801
case '3':
802
	echo $stats->chartDistribution([Filter::get('chart_shows'), 'death_distribution_chart']);
803
	break;
804
case '4':
805
	echo $stats->chartDistribution([Filter::get('chart_shows'), 'marriage_distribution_chart']);
806
	break;
807 View Code Duplication
case '11':
808
	$monthdata = [];
809
	for ($i = 0; $i < 12; ++$i) {
810
		$monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false);
811
	}
812
	$xgiven            = true;
813
	$zgiven            = false;
814
	$title             = I18N::translate('Month of birth');
815
	$xtitle            = I18N::translate('Month');
816
	$ytitle            = I18N::translate('numbers');
817
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
818
	$xdata             = $monthdata;
819
	$xmax              = 12;
820
	if ($z_axis !== 300 && $z_axis !== 301) {
821
		calculate_legend($boundaries_z_axis);
822
	}
823
	$percentage = false;
824
	if ($y_axis === 201) {
825
		$percentage = false;
826
		$ytitle     = I18N::translate('Individuals');
827
	} elseif ($y_axis === 202) {
828
		$percentage = true;
829
		$ytitle     = I18N::translate('percentage');
830
	}
831
	$male_female = false;
832
	if ($z_axis === 300) {
833
		$zgiven          = false;
834
		$legend[0]       = 'all';
835
		$zmax            = 1;
836
		$z_boundaries[0] = 100000;
837
	} elseif ($z_axis === 301) {
838
		$male_female = true;
839
		$zgiven      = true;
840
		$legend[0]   = I18N::translate('Male');
841
		$legend[1]   = I18N::translate('Female');
842
		$zmax        = 2;
843
	}
844
	//-- reset the data array
845
	for ($i = 0; $i < $zmax; $i++) {
846
		for ($j = 0; $j < $xmax; $j++) {
847
			$ydata[$i][$j] = 0;
848
		}
849
	}
850
	$total = month_of_birth($z_axis, $z_boundaries, $stats);
851
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
0 ignored issues
show
It seems like $xdata can also be of type string[]; however, parameter $xdata of my_plot() does only seem to accept array<mixed,integer[]>, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

851
	my_plot($title, /** @scrutinizer ignore-type */ $xdata, $xtitle, $ydata, $ytitle, $legend);
Loading history...
852
	break;
853 View Code Duplication
case '12':
854
	$monthdata = [];
855
	for ($i = 0; $i < 12; ++$i) {
856
		$monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false);
857
	}
858
	$xgiven            = true;
859
	$zgiven            = false;
860
	$title             = I18N::translate('Month of death');
861
	$xtitle            = I18N::translate('Month');
862
	$ytitle            = I18N::translate('numbers');
863
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
864
	$xdata             = $monthdata;
865
	$xmax              = 12;
866
	if ($z_axis !== 300 && $z_axis !== 301) {
867
		calculate_legend($boundaries_z_axis);
868
	}
869
	$percentage = false;
870
	if ($y_axis === 201) {
871
		$percentage = false;
872
		$ytitle     = I18N::translate('Individuals');
873
	} elseif ($y_axis === 202) {
874
		$percentage = true;
875
		$ytitle     = I18N::translate('percentage');
876
	}
877
	$male_female = false;
878
	if ($z_axis === 300) {
879
		$zgiven          = false;
880
		$legend[0]       = 'all';
881
		$zmax            = 1;
882
		$z_boundaries[0] = 100000;
883
	} elseif ($z_axis === 301) {
884
		$male_female = true;
885
		$zgiven      = true;
886
		$legend[0]   = I18N::translate('Male');
887
		$legend[1]   = I18N::translate('Female');
888
		$zmax        = 2;
889
	}
890
	//-- reset the data array
891
	for ($i = 0; $i < $zmax; $i++) {
892
		for ($j = 0; $j < $xmax; $j++) {
893
			$ydata[$i][$j] = 0;
894
		}
895
	}
896
	$total = month_of_death($z_axis, $z_boundaries, $stats);
897
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
898
	break;
899 View Code Duplication
case '13':
900
	$monthdata = [];
901
	for ($i = 0; $i < 12; ++$i) {
902
		$monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false);
903
	}
904
905
	if ($z_axis === 301) {
906
		$z_axis = 300;
907
	}
908
	$xgiven            = true;
909
	$zgiven            = false;
910
	$title             = I18N::translate('Month of marriage');
911
	$xtitle            = I18N::translate('Month');
912
	$ytitle            = I18N::translate('numbers');
913
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
914
	$xdata             = $monthdata;
915
	$xmax              = 12;
916
	if ($z_axis !== 300 && $z_axis !== 301) {
917
		calculate_legend($boundaries_z_axis);
918
	}
919
	$percentage = false;
920
	if ($y_axis === 201) {
921
		$percentage = false;
922
		$ytitle     = I18N::translate('Families');
923
	} elseif ($y_axis === 202) {
924
		$percentage = true;
925
		$ytitle     = I18N::translate('percentage');
926
	}
927
	$male_female = false;
928
	if ($z_axis === 300) {
929
		$zgiven          = false;
930
		$legend[0]       = 'all';
931
		$zmax            = 1;
932
		$z_boundaries[0] = 100000;
933
	} elseif ($z_axis === 301) {
934
		$male_female = true;
935
		$zgiven      = true;
936
		$legend[0]   = I18N::translate('Male');
937
		$legend[1]   = I18N::translate('Female');
938
		$zmax        = 2;
939
	}
940
	//-- reset the data array
941
	for ($i = 0; $i < $zmax; $i++) {
942
		for ($j = 0; $j < $xmax; $j++) {
943
			$ydata[$i][$j] = 0;
944
		}
945
	}
946
	$total = month_of_marriage($z_axis, $z_boundaries, $stats);
947
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
948
	break;
949 View Code Duplication
case '14':
950
	$monthdata = [];
951
	for ($i = 0; $i < 12; ++$i) {
952
		$monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false);
953
	}
954
	$xgiven            = true;
955
	$zgiven            = false;
956
	$title             = I18N::translate('Month of birth of first child in a relation');
957
	$xtitle            = I18N::translate('Month');
958
	$ytitle            = I18N::translate('numbers');
959
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
960
	$xdata             = $monthdata;
961
	$xmax              = 12;
962
	if ($z_axis !== 300 && $z_axis !== 301) {
963
		calculate_legend($boundaries_z_axis);
964
	}
965
	$percentage = false;
966
	if ($y_axis === 201) {
967
		$percentage = false;
968
		$ytitle     = I18N::translate('Children');
969
	} elseif ($y_axis === 202) {
970
		$percentage = true;
971
		$ytitle     = I18N::translate('percentage');
972
	}
973
	$male_female = false;
974
	if ($z_axis === 300) {
975
		$zgiven          = false;
976
		$legend[0]       = 'all';
977
		$zmax            = 1;
978
		$z_boundaries[0] = 100000;
979
	} elseif ($z_axis === 301) {
980
		$male_female = true;
981
		$zgiven      = true;
982
		$legend[0]   = I18N::translate('Male');
983
		$legend[1]   = I18N::translate('Female');
984
		$zmax        = 2;
985
	}
986
	//-- reset the data array
987
	for ($i = 0; $i < $zmax; $i++) {
988
		for ($j = 0; $j < $xmax; $j++) {
989
			$ydata[$i][$j] = 0;
990
		}
991
	}
992
	$total = month_of_birth_of_first_child($z_axis, $z_boundaries, $stats);
993
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
994
	break;
995 View Code Duplication
case '15':
996
	$monthdata = [];
997
	for ($i = 0; $i < 12; ++$i) {
998
		$monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false);
999
	}
1000
1001
	if ($z_axis === 301) {
1002
		$z_axis = 300;
1003
	}
1004
	$xgiven            = true;
1005
	$zgiven            = false;
1006
	$title             = I18N::translate('Month of first marriage');
1007
	$xtitle            = I18N::translate('Month');
1008
	$ytitle            = I18N::translate('numbers');
1009
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
1010
	$xdata             = $monthdata;
1011
	$xmax              = 12;
1012
	if ($z_axis !== 300 && $z_axis !== 301) {
1013
		calculate_legend($boundaries_z_axis);
1014
	}
1015
	$percentage = false;
1016
	if ($y_axis === 201) {
1017
		$percentage = false;
1018
		$ytitle     = I18N::translate('Families');
1019
	} elseif ($y_axis === 202) {
1020
		$percentage = true;
1021
		$ytitle     = I18N::translate('percentage');
1022
	}
1023
	$male_female = false;
1024
	if ($z_axis === 300) {
1025
		$zgiven          = false;
1026
		$legend[0]       = 'all';
1027
		$zmax            = 1;
1028
		$z_boundaries[0] = 100000;
1029
	} elseif ($z_axis === 301) {
1030
		$male_female = true;
1031
		$zgiven      = true;
1032
		$legend[0]   = I18N::translate('Male');
1033
		$legend[1]   = I18N::translate('Female');
1034
		$zmax        = 2;
1035
	}
1036
	//-- reset the data array
1037
	for ($i = 0; $i < $zmax; $i++) {
1038
		for ($j = 0; $j < $xmax; $j++) {
1039
			$ydata[$i][$j] = 0;
1040
		}
1041
	}
1042
	$total = month_of_first_marriage($z_axis, $z_boundaries, $stats);
1043
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
1044
	break;
1045 View Code Duplication
case '18':
1046
	$xgiven            = false;
1047
	$zgiven            = false;
1048
	$title             = /* I18N: Two axes of a graph */ I18N::translate('Longevity versus time');
1049
	$xtitle            = I18N::translate('age');
1050
	$ytitle            = I18N::translate('numbers');
1051
	$boundaries_x_axis = Filter::get('x-axis-boundaries-ages');
1052
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
1053
	calculate_axis($boundaries_x_axis);
1054
	if ($z_axis !== 300 && $z_axis !== 301) {
1055
		calculate_legend($boundaries_z_axis);
1056
	}
1057
	$percentage = false;
1058
	if ($y_axis === 201) {
1059
		$percentage = false;
1060
		$ytitle     = I18N::translate('Individuals');
1061
	} elseif ($y_axis === 202) {
1062
		$percentage = true;
1063
		$ytitle     = I18N::translate('percentage');
1064
	}
1065
	$male_female = false;
1066
	if ($z_axis === 300) {
1067
		$zgiven          = false;
1068
		$legend[0]       = 'all';
1069
		$zmax            = 1;
1070
		$z_boundaries[0] = 100000;
1071
	} elseif ($z_axis === 301) {
1072
		$male_female = true;
1073
		$zgiven      = true;
1074
		$legend[0]   = I18N::translate('Male');
1075
		$legend[1]   = I18N::translate('Female');
1076
		$zmax        = 2;
1077
	}
1078
	//-- reset the data array
1079
	for ($i = 0; $i < $zmax; $i++) {
1080
		for ($j = 0; $j < $xmax; $j++) {
1081
			$ydata[$i][$j] = 0;
1082
		}
1083
	}
1084
	$total = longevity_versus_time($z_axis, $z_boundaries, $stats);
1085
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
1086
	break;
1087 View Code Duplication
case '19':
1088
	$xgiven            = false;
1089
	$zgiven            = false;
1090
	$title             = I18N::translate('Age in year of marriage');
1091
	$xtitle            = I18N::translate('age');
1092
	$ytitle            = I18N::translate('numbers');
1093
	$boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m');
1094
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
1095
	calculate_axis($boundaries_x_axis);
1096
	if ($z_axis !== 300 && $z_axis !== 301) {
1097
		calculate_legend($boundaries_z_axis);
1098
	}
1099
	$percentage = false;
1100
	if ($y_axis === 201) {
1101
		$percentage = false;
1102
		$ytitle     = I18N::translate('Individuals');
1103
	} elseif ($y_axis === 202) {
1104
		$percentage = true;
1105
		$ytitle     = I18N::translate('percentage');
1106
	}
1107
	$male_female     = false;
1108
	$z_boundaries[0] = 100000;
1109
	if ($z_axis === 300) {
1110
		$zgiven    = false;
1111
		$legend[0] = 'all';
1112
		$zmax      = 1;
1113
	} elseif ($z_axis === 301) {
1114
		$male_female = true;
1115
		$zgiven      = true;
1116
		$legend[0]   = I18N::translate('Male');
1117
		$legend[1]   = I18N::translate('Female');
1118
		$zmax        = 2;
1119
	}
1120
	//-- reset the data array
1121
	for ($i = 0; $i < $zmax; $i++) {
1122
		for ($j = 0; $j < $xmax; $j++) {
1123
			$ydata[$i][$j] = 0;
1124
		}
1125
	}
1126
	$total = age_at_marriage($z_axis, $z_boundaries, $stats);
1127
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
1128
	break;
1129 View Code Duplication
case '20':
1130
	$xgiven            = false;
1131
	$zgiven            = false;
1132
	$title             = I18N::translate('Age in year of first marriage');
1133
	$xtitle            = I18N::translate('age');
1134
	$ytitle            = I18N::translate('numbers');
1135
	$boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m');
1136
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
1137
	calculate_axis($boundaries_x_axis);
1138
	if ($z_axis !== 300 && $z_axis !== 301) {
1139
		calculate_legend($boundaries_z_axis);
1140
	}
1141
	$percentage = false;
1142
	if ($y_axis === 201) {
1143
		$percentage = false;
1144
		$ytitle     = I18N::translate('Individuals');
1145
	} elseif ($y_axis === 202) {
1146
		$percentage = true;
1147
		$ytitle     = I18N::translate('percentage');
1148
	}
1149
	$male_female = false;
1150
	if ($z_axis === 300) {
1151
		$zgiven          = false;
1152
		$legend[0]       = 'all';
1153
		$zmax            = 1;
1154
		$z_boundaries[0] = 100000;
1155
	} elseif ($z_axis === 301) {
1156
		$male_female = true;
1157
		$zgiven      = true;
1158
		$legend[0]   = I18N::translate('Male');
1159
		$legend[1]   = I18N::translate('Female');
1160
		$zmax        = 2;
1161
	}
1162
	//-- reset the data array
1163
	for ($i = 0; $i < $zmax; $i++) {
1164
		for ($j = 0; $j < $xmax; $j++) {
1165
			$ydata[$i][$j] = 0;
1166
		}
1167
	}
1168
	$total = age_at_first_marriage($z_axis, $z_boundaries, $stats);
1169
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
1170
	break;
1171 View Code Duplication
case '21':
1172
	$xgiven            = false;
1173
	$zgiven            = false;
1174
	$title             = I18N::translate('Number of children');
1175
	$xtitle            = I18N::translate('children');
1176
	$ytitle            = I18N::translate('numbers');
1177
	$boundaries_x_axis = Filter::get('x-axis-boundaries-numbers');
1178
	$boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0');
1179
	calculate_axis($boundaries_x_axis);
1180
	if ($z_axis !== 300 && $z_axis !== 301) {
1181
		calculate_legend($boundaries_z_axis);
1182
	}
1183
	$percentage = false;
1184
	if ($y_axis === 201) {
1185
		$percentage = false;
1186
		$ytitle     = I18N::translate('Families');
1187
	} elseif ($y_axis === 202) {
1188
		$percentage = true;
1189
		$ytitle     = I18N::translate('percentage');
1190
	}
1191
	$male_female = false;
1192
	if ($z_axis === 300) {
1193
		$zgiven          = false;
1194
		$legend[0]       = 'all';
1195
		$zmax            = 1;
1196
		$z_boundaries[0] = 100000;
1197
	} elseif ($z_axis === 301) {
1198
		$male_female = true;
1199
		$zgiven      = true;
1200
		$legend[0]   = I18N::translate('Male');
1201
		$legend[1]   = I18N::translate('Female');
1202
		$zmax        = 2;
1203
	}
1204
	//-- reset the data array
1205
	for ($i = 0; $i < $zmax; $i++) {
1206
		for ($j = 0; $j < $xmax; $j++) {
1207
			$ydata[$i][$j] = 0;
1208
		}
1209
	}
1210
	$total = number_of_children($z_axis, $z_boundaries, $stats);
1211
	my_plot($title, $xdata, $xtitle, $ydata, $ytitle, $legend);
1212
	break;
1213
default:
1214
	break;
1215
}
1216
echo '</div>';
1217