|
|
@@ -1,6 +1,6 @@
|
|
|
+import {BehaviorSubject} from 'rxjs';
|
|
|
import {HttpClient} from '@angular/common/http';
|
|
|
import {Injectable} from '@angular/core';
|
|
|
-import {Subject} from 'rxjs';
|
|
|
import {csv} from 'd3';
|
|
|
|
|
|
import vars2facts from '../assets/data/variables2factors.json';
|
|
|
@@ -16,24 +16,28 @@ export class SdmDihService {
|
|
|
selectedYear = '';
|
|
|
years = [];
|
|
|
yearsLoaded = false;
|
|
|
- dataLoads: Subject<void> = new Subject();
|
|
|
+ dataLoads: BehaviorSubject<boolean> = new BehaviorSubject(false);
|
|
|
|
|
|
constructor(private httpClient: HttpClient) {
|
|
|
- this.loadData().then(() => {
|
|
|
- this.years = Object.keys(this.sdmData);
|
|
|
- this.yearsLoaded = true;
|
|
|
- console.log(this.years);
|
|
|
- this.firstYear = this.years[0];
|
|
|
- this.lastYear = this.years[this.years.length - 1];
|
|
|
- this.regions = [
|
|
|
- ...new Set(
|
|
|
- this.sdmData[this.firstYear].map((yearData) => yearData['MODEL'])
|
|
|
- ),
|
|
|
- ];
|
|
|
- console.log(this.regions);
|
|
|
- this.selectedYear = this.firstYear;
|
|
|
- this.dataLoads.next();
|
|
|
- });
|
|
|
+ this.loadData()
|
|
|
+ .then(() => {
|
|
|
+ this.years = Object.keys(this.sdmData);
|
|
|
+ this.yearsLoaded = true;
|
|
|
+ console.log(this.years);
|
|
|
+ this.firstYear = this.years[0];
|
|
|
+ this.lastYear = this.years[this.years.length - 1];
|
|
|
+ this.regions = [
|
|
|
+ ...new Set(
|
|
|
+ this.sdmData[this.firstYear].map((yearData) => yearData['MODEL'])
|
|
|
+ ),
|
|
|
+ ];
|
|
|
+ console.log(this.regions);
|
|
|
+ this.selectedYear = this.firstYear;
|
|
|
+ this.dataLoads.next(true);
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.warn('shit happened', err);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
calcAggregatedIndex(regionData) {
|