Skip to content

Commit

Permalink
Merge pull request #224 from ilri/enhancements-Oct-2023
Browse files Browse the repository at this point in the history
Fix map chart countries mapping
  • Loading branch information
alanorth authored Dec 17, 2023
2 parents 40fd205 + d31815e commit b3548fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 255 deletions.
7 changes: 7 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@auth0/angular-jwt": "^5.2.0",
"@highcharts/map-collection": "^2.1.0",
"@material-extended/mde": "^3.0.3",
"@mohammad231/iso_3166-1": "^1.0.2",
"@ng-select/ng-select": "^10.0.4",
"@ngrx/effects": "^15.4.0",
"@ngrx/store": "^15.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ const mapWorld = require('@highcharts/map-collection/custom/world-robinson-highr
import * as Highcharts from 'highcharts';
import { ParentChart } from '../parent-chart';
import { Bucket } from 'src/app/explorer/filters/services/interfaces';
import { getCountryCode } from '../services/countryList.helper';
import { ComponentLookup } from '../dynamic/lookup.registry';
import { SelectService } from 'src/app/explorer/filters/services/select/select.service';
import { BodyBuilderService } from 'src/app/explorer/filters/services/bodyBuilder/body-builder.service';
import { Store } from '@ngrx/store';
import * as fromStore from '../../../store';
import { ComponentFilterConfigs } from 'src/app/explorer/configs/generalConfig.interface';
import { ActivatedRoute } from '@angular/router';
import CountryISO from '@mohammad231/iso_3166-1';
import { Country } from '@mohammad231/iso_3166-1/iso_3166-1';
@ComponentLookup('MapComponent')
@Component({
selector: 'app-map',
Expand Down Expand Up @@ -96,7 +97,7 @@ export class MapComponent extends ParentChart implements OnInit {
series: [
{
data: buckets.map((b: Bucket) => [
getCountryCode(b.key),
this.mapCountryToIsoAlpha2(b.key),
b.doc_count,
]),
mapData: mapWorld,
Expand Down Expand Up @@ -126,4 +127,13 @@ export class MapComponent extends ParentChart implements OnInit {
...this.cms.commonProperties(),
} as Highcharts.Options;
}

mapCountryToIsoAlpha2(value: string) {
const country = CountryISO.get({
name: value,
common_name: value,
official_name: value,
}) as Country;
return country ? country.alpha_2.toLowerCase() : undefined;
}
}

This file was deleted.

0 comments on commit b3548fc

Please sign in to comment.