Project

General

Profile

1
import { Component, OnInit } from '@angular/core';
2
import { ActivatedRoute } from '@angular/router';
3
import { DomSanitizer } from '@angular/platform-browser';
4
import { DataService } from '../../services/data.service';
5
import { DataHandlerService } from '../../services/data-handler.service';
6
import { EuropeData } from '../../domain/overview-map-data';
7

    
8
@Component({
9
  selector: 'app-continent-overview',
10
  templateUrl: './continent-overview.component.html',
11
})
12

    
13
export class ContinentOverviewComponent implements OnInit {
14

    
15
  continentName: string;
16

    
17
  europeOverviewData: EuropeData;
18

    
19
  constructor(private dataService: DataService,
20
              private dataHandlerService: DataHandlerService,
21
              private route: ActivatedRoute,
22
              private sanitizer: DomSanitizer) { }
23

    
24
  ngOnInit(): void {
25
    this.continentName = this.route.snapshot.paramMap.get('continentName');
26

    
27
    this.dataService.getEuropeOAPercentages().subscribe(
28
      rawData => {
29
        this.europeOverviewData = this.dataHandlerService.convertRawDataToEuropeOverviewData(rawData);
30
      }, error => {
31
        console.log(error);
32
      }
33
    );
34
  }
35

    
36
  getHeight(percentage: number) {
37
    if (percentage < 50) {
38
      return Math.round(percentage) * 1.5;
39
    } else {
40
      return Math.round(percentage);
41
    }
42
  }
43

    
44
  getNumberFontSize(percentage: number) {
45
    if (percentage < 50) {
46
      return Math.round(percentage * 45 / 100) * 1.5;
47
    } else {
48
      return Math.round(percentage * 45 / 100);
49
    }
50
  }
51

    
52
  getEntityNameFontSize(percentage: number) {
53
    if (percentage < 50) {
54
      return Math.round(percentage * 30 / 100) * 1.5;
55
    } else {
56
      return Math.round(percentage * 30 / 100);
57
    }
58
  }
59

    
60
  getPublicationsIconWidth(percentage: number) {
61
    if (percentage < 50) {
62
      return Math.round(percentage * 60 / 100) * 1.5;
63
    } else {
64
      return Math.round(percentage * 60 / 100);
65
    }
66
  }
67

    
68
  getDatasetsIconWidth(percentage: number) {
69
    if (percentage < 50) {
70
      return Math.round(percentage * 45 / 100) * 1.5;
71
    } else {
72
      return Math.round(percentage * 45 / 100);
73
    }
74
  }
75

    
76
  getSoftwareIconWidth(percentage: number) {
77
    if (percentage < 50) {
78
      return Math.round(percentage * 50 / 100) * 1.5;
79
    } else {
80
      return Math.round(percentage * 50 / 100);
81
    }
82
  }
83

    
84
  getOtherIconWidth(percentage: number) {
85
    if (percentage < 50) {
86
      return Math.round(percentage * 45 / 100) * 1.5;
87
    } else {
88
      return Math.round(percentage * 45 / 100);
89
    }
90
  }
91

    
92
}
(2-2/2)