scenario-factor-year-graph.component.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {Component, OnInit} from '@angular/core';
  2. import domain2scenario from '../../../assets/data/domain-scenario.json';
  3. import {DiscsChartBaseService} from '../discs-chart-base.service';
  4. import {SdmDihService} from '../../sdm-dih.service';
  5. @Component({
  6. selector: 'scenario-factor-year-graph',
  7. templateUrl: './scenario-factor-year-graph.component.html',
  8. styleUrls: ['./scenario-factor-year-graph.component.scss'],
  9. })
  10. export class ScenarioFactorYearGraphComponent implements OnInit {
  11. filteredScenarios = [];
  12. selectedRegion = 'Apulia';
  13. selectedDomain = 'INFR';
  14. constructor(
  15. public sdmDihService: SdmDihService,
  16. public yearGraphService: DiscsChartBaseService
  17. ) {}
  18. ngOnInit() {
  19. this.sdmDihService.dataLoads.subscribe((loaded) => {
  20. if (!loaded) {
  21. return;
  22. }
  23. this.filterScenarios();
  24. });
  25. this.yearGraphService.graphRefreshes.subscribe(() => {
  26. this.filterScenarios();
  27. });
  28. }
  29. filterScenarios(): void {
  30. this.filteredScenarios = this.sdmDihService.scenarios.filter((scenario) => {
  31. return domain2scenario[this.selectedDomain].includes(scenario);
  32. });
  33. }
  34. baselineFilter = (item): boolean => {
  35. return item !== 'baseline';
  36. };
  37. /*animateGraphs() {
  38. const MILLISECONDS_TO_ANIMATE = 100 as const;
  39. let i = 1;
  40. for (const year of this.sdmDihService.years) {
  41. setTimeout(() => {
  42. this.yearGraphService.selectedYear = year;
  43. this.yearGraphService.redrawGraphs();
  44. }, MILLISECONDS_TO_ANIMATE * i);
  45. i++;
  46. }
  47. }*/
  48. /*nextYear() {
  49. const selectedYearIndex = this.sdmDihService.years.findIndex(
  50. (val) => val == this.yearGraphService.selectedYear
  51. );
  52. this.yearGraphService.selectedYear =
  53. this.sdmDihService.years[selectedYearIndex + 1] ??
  54. this.yearGraphService.selectedYear;
  55. this.yearGraphService.redrawGraphs();
  56. }*/
  57. /*prevYear() {
  58. const selectedYearIndex = this.sdmDihService.years.findIndex(
  59. (val) => val == this.yearGraphService.selectedYear
  60. );
  61. this.yearGraphService.selectedYear =
  62. this.sdmDihService.years[selectedYearIndex - 1] ??
  63. this.yearGraphService.selectedYear;
  64. this.yearGraphService.redrawGraphs();
  65. }*/
  66. }