app/Statistics/Google/ChartDistribution.php
private function getSurnameChartData(string $surname): array
    {
        if ($surname === '') {
            $surname = $this->individualRepository->getCommonSurname();
        }

        // Count how many people are events in each country
        $surn_countries = [];
        $records        = $this->queryRecords($surname);

        foreach ($records as $row) {
            /** @var string[][] $matches */
            if (preg_match_all('/^2 PLAC (?:.*, *)*(.*)/m', $row->i_gedcom, $matches)) {
                // webtrees uses 3 letter country codes and localised country names,
                // but google uses 2 letter codes.
                foreach ($matches[1] as $country) {
                    // Consolidate places (Germany, DEU => DE)
                    if (array_key_exists($country, $this->country_to_iso3166)) {
                        $country_code = $this->country_to_iso3166[$country];

                        if (array_key_exists($country_code, $surn_countries)) {
                            $surn_countries[$country_code]++;
                        } else {
                            $surn_countries[$country_code] = 1;
                        }
                    }
                }
            }
        }

        return $this->createChartData($surn_countries);
    }
private function getSurnameChartData(string $surname): array
    {
        if ($surname === '') {
            $surname = $this->individualRepository->getCommonSurname();
        }

        // Count how many people are events in each country
        $surn_countries = [];
        $records        = $this->queryRecords($surname);

        foreach ($records as $row) {
            /** @var string[][] $matches */
            if (preg_match_all('/^2 PLAC (?:.*, *)*(.*)/m', $row->i_gedcom, $matches)) {
                // webtrees uses 3 letter country codes and localised country names,
                // but google uses 2 letter codes.
                foreach ($matches[1] as $country) {
                    // Consolidate places (Germany, DEU => DE)
                    if (array_key_exists($country, $this->country_to_iso3166)) {
                        $country_code = $this->country_to_iso3166[$country];

                        if (array_key_exists($country_code, $surn_countries)) {
                            $surn_countries[$country_code]++;
                        } else {
                            $surn_countries[$country_code] = 1;
                        }
                    }
                }
            }
        }

        return $this->createChartData($surn_countries);
    }
private function getSurnameChartData ( string $ surname ) : array { if ( $ surname === '' ) { $ surname = $ this -> individualRepository -> getCommonSurname ( ) ; } // Count how many people are events in each country $ surn_countries = [ ] ; $ records = $ this -> queryRecords ( $ surname ) ; foreach ( $ records as $ row ) { /** @var string[][] $matches */ if ( preg_match_all ( '/^2 PLAC (?:.*, *)*(.*)/m' , $ row -> i_gedcom , $ matches ) ) { // webtrees uses 3 letter country codes and localised country names, // but google uses 2 letter codes. foreach ( $ matches [ 1 ] as $ country ) { // Consolidate places (Germany, DEU => DE) if ( array_key_exists ( $ country , $ this -> country_to_iso3166 ) ) { $ country_code = $ this -> country_to_iso3166 [ $ country ] ; if ( array_key_exists ( $ country_code , $ surn_countries ) ) { $ surn_countries [ $ country_code ] ++ ; } else { $ surn_countries [ $ country_code ] = 1 ; } } } } } return $ this -> createChartData ( $ surn_countries ) ; }
Returns the google geochart data for surnames.

@param string $surname The surname used to create the chart

@return array
Returns the google geochart data for surnames .