|
@@ -1,13 +1,47 @@
|
|
|
-import { Component, OnInit } from '@angular/core';
|
|
|
|
|
|
|
+import { Component, OnInit } from "@angular/core";
|
|
|
|
|
+import { select } from "d3";
|
|
|
|
|
|
|
|
-import { SdmDihService } from '../sdm-dih.service';
|
|
|
|
|
|
|
+import { SdmDihService } from "../sdm-dih.service";
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
|
- selector: 'year-graph',
|
|
|
|
|
- templateUrl: 'year-graph.component.html',
|
|
|
|
|
|
|
+ selector: "year-graph",
|
|
|
|
|
+ templateUrl: "year-graph.component.html",
|
|
|
})
|
|
})
|
|
|
export class YearGraphComponent implements OnInit {
|
|
export class YearGraphComponent implements OnInit {
|
|
|
- constructor(private sdmDihService: SdmDihService) { }
|
|
|
|
|
|
|
+ years = [];
|
|
|
|
|
+ regions = [];
|
|
|
|
|
+ yearsLoaded = false;
|
|
|
|
|
+ selectedYear = "";
|
|
|
|
|
|
|
|
- ngOnInit() { }
|
|
|
|
|
|
|
+ constructor(private sdmDihService: SdmDihService) {
|
|
|
|
|
+ this.sdmDihService.dataLoads.subscribe(() => {
|
|
|
|
|
+ this.years = Object.keys(this.sdmDihService.sdmData);
|
|
|
|
|
+ this.yearsLoaded = true;
|
|
|
|
|
+ console.log(this.years);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ngOnInit() {}
|
|
|
|
|
+
|
|
|
|
|
+ drawGraph() {
|
|
|
|
|
+ const width = 200;
|
|
|
|
|
+ const height = 200;
|
|
|
|
|
+ select("#year-graph-place").select("svg")?.remove();
|
|
|
|
|
+ // append the svg object to the div called 'year-graph-place'
|
|
|
|
|
+ const svg = select("#year-graph-place")
|
|
|
|
|
+ .append("svg")
|
|
|
|
|
+ .attr("width", width)
|
|
|
|
|
+ .attr("height", height)
|
|
|
|
|
+ .append("g")
|
|
|
|
|
+ .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
|
|
|
|
|
+ const yearData = this.sdmDihService.aggregatedData[this.selectedYear];
|
|
|
|
|
+ const color = `rgba(100, 200, 100, ${yearData[0]['Natural_Capital']})`;
|
|
|
|
|
+ svg
|
|
|
|
|
+ .append("circle")
|
|
|
|
|
+ .attr("cx", 0)
|
|
|
|
|
+ .attr("cy", 0)
|
|
|
|
|
+ .attr("r", 50)
|
|
|
|
|
+ .attr("stroke", "black")
|
|
|
|
|
+ .attr("fill", color);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|