18add1155SRico Sonntag<?php 23976b470SGreg Roach 38add1155SRico Sonntag/** 48add1155SRico Sonntag * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 68add1155SRico Sonntag * This program is free software: you can redistribute it and/or modify 78add1155SRico Sonntag * it under the terms of the GNU General Public License as published by 88add1155SRico Sonntag * the Free Software Foundation, either version 3 of the License, or 98add1155SRico Sonntag * (at your option) any later version. 108add1155SRico Sonntag * This program is distributed in the hope that it will be useful, 118add1155SRico Sonntag * but WITHOUT ANY WARRANTY; without even the implied warranty of 128add1155SRico Sonntag * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138add1155SRico Sonntag * GNU General Public License for more details. 148add1155SRico Sonntag * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 168add1155SRico Sonntag */ 17fcfa147eSGreg Roach 188add1155SRico Sonntagdeclare(strict_types=1); 198add1155SRico Sonntag 208add1155SRico Sonntagnamespace Fisharebest\Webtrees\Statistics\Google; 218add1155SRico Sonntag 228add1155SRico Sonntaguse Fisharebest\Webtrees\I18N; 238add1155SRico Sonntag 248add1155SRico Sonntag/** 2593ccd686SRico Sonntag * A chart showing the distribution of males and females. 268add1155SRico Sonntag */ 2793ccd686SRico Sonntagclass ChartSex 288add1155SRico Sonntag{ 298add1155SRico Sonntag /** 308add1155SRico Sonntag * Generate a chart showing sex distribution. 318add1155SRico Sonntag * 328add1155SRico Sonntag * @param int $tot_m The total number of male individuals 338add1155SRico Sonntag * @param int $tot_f The total number of female individuals 348add1155SRico Sonntag * @param int $tot_u The total number of unknown individuals 358add1155SRico Sonntag * @param string|null $color_female 368add1155SRico Sonntag * @param string|null $color_male 378add1155SRico Sonntag * @param string|null $color_unknown 388add1155SRico Sonntag * 398add1155SRico Sonntag * @return string 408add1155SRico Sonntag */ 418add1155SRico Sonntag public function chartSex( 428add1155SRico Sonntag int $tot_m, 438add1155SRico Sonntag int $tot_f, 448add1155SRico Sonntag int $tot_u, 452c6f1bd5SGreg Roach string|null $color_female = null, 462c6f1bd5SGreg Roach string|null $color_male = null, 47*b50dba3aSGreg Roach string|null $color_unknown = null 488add1155SRico Sonntag ): string { 493529c469SGreg Roach $color_female ??= '#ffd1dc'; 503529c469SGreg Roach $color_male ??= '#84beff'; 513529c469SGreg Roach $color_unknown ??= '#777777'; 528add1155SRico Sonntag 5388de55fdSRico Sonntag $data = [ 5488de55fdSRico Sonntag [ 5588de55fdSRico Sonntag I18N::translate('Type'), 5688de55fdSRico Sonntag I18N::translate('Total') 5788de55fdSRico Sonntag ], 58dd7dd2a1SRico Sonntag ]; 59dd7dd2a1SRico Sonntag 60ef475b14SGreg Roach if ($tot_m > 0 || $tot_f > 0 || $tot_u > 0) { 61dd7dd2a1SRico Sonntag $data[] = [ 6288de55fdSRico Sonntag I18N::translate('Males'), 6388de55fdSRico Sonntag $tot_m 64dd7dd2a1SRico Sonntag ]; 65dd7dd2a1SRico Sonntag 66dd7dd2a1SRico Sonntag $data[] = [ 6788de55fdSRico Sonntag I18N::translate('Females'), 6888de55fdSRico Sonntag $tot_f 69dd7dd2a1SRico Sonntag ]; 70dd7dd2a1SRico Sonntag 71dd7dd2a1SRico Sonntag $data[] = [ 7288de55fdSRico Sonntag I18N::translate('Unknown'), 7388de55fdSRico Sonntag $tot_u 7488de55fdSRico Sonntag ]; 75dd7dd2a1SRico Sonntag } 768add1155SRico Sonntag 7790a2f718SGreg Roach return view('statistics/other/charts/pie', [ 7888de55fdSRico Sonntag 'title' => null, 7988de55fdSRico Sonntag 'data' => $data, 8088de55fdSRico Sonntag 'colors' => [$color_male, $color_female, $color_unknown], 8188de55fdSRico Sonntag 'labeledValueText' => 'percentage', 8265cf5706SGreg Roach 'language' => I18N::languageTag(), 8390a2f718SGreg Roach ]); 848add1155SRico Sonntag } 858add1155SRico Sonntag} 86