1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2019 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 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Statistics\Google; 19 20use Fisharebest\Webtrees\I18N; 21use Fisharebest\Webtrees\Statistics\AbstractGoogle; 22 23/** 24 * 25 */ 26class ChartMortality extends AbstractGoogle 27{ 28 /** 29 * Create a chart showing mortality. 30 * 31 * @param int $tot_l 32 * @param int $tot_d 33 * @param string|null $color_living 34 * @param string|null $color_dead 35 * 36 * @return string 37 */ 38 public function chartMortality( 39 int $tot_l, 40 int $tot_d, 41 string $color_living = null, 42 string $color_dead = null 43 ): string { 44 $color_living = $color_living ?? '#ffffff'; 45 $color_dead = $color_dead ?? '#cccccc'; 46 47 $data = [ 48 [ 49 I18N::translate('Century'), 50 I18N::translate('Total') 51 ] 52 ]; 53 54 if ($tot_l || $tot_d) { 55 $data[] = [ 56 I18N::translate('Living'), 57 $tot_l 58 ]; 59 60 $data[] = [ 61 I18N::translate('Dead'), 62 $tot_d 63 ]; 64 } 65 66 $colors = $this->interpolateRgb($color_living, $color_dead, \count($data) - 1); 67 68 return view( 69 'statistics/other/charts/pie', 70 [ 71 'title' => null, 72 'data' => $data, 73 'colors' => $colors, 74 'labeledValueText' => 'percentage', 75 ] 76 ); 77 } 78} 79