1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { printPage } from '../../shared/reusablecomponents/print-function';
|
3
|
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
4
|
import { DataService } from '../../services/data.service';
|
5
|
import { DataHandlerService } from '../../services/data-handler.service';
|
6
|
import { CountryTableData, EuropeData } from '../../domain/overview-map-data';
|
7
|
import { environment } from '../../../environments/environment';
|
8
|
import { TreemapHighchartsData } from '../../domain/treemap-highcharts-data';
|
9
|
import { publicationPalette, datasetPalette, softwarePalette, otherResearchProductsPalette, resultColor } from '../../chart-palettes';
|
10
|
|
11
|
@Component({
|
12
|
selector: 'app-data-view',
|
13
|
templateUrl: './data-view.component.html',
|
14
|
})
|
15
|
|
16
|
export class DataViewComponent implements OnInit {
|
17
|
|
18
|
// @Input() type: string;
|
19
|
// @Input() countries: CountryOverview[];
|
20
|
|
21
|
private chartsURL = environment.API_ENDPOINT + 'chart?json=';
|
22
|
private profileName = environment.profileName;
|
23
|
|
24
|
private publicationPalette = publicationPalette;
|
25
|
private datasetPalette = datasetPalette;
|
26
|
private softwarePalette = softwarePalette;
|
27
|
private otherResearchProductsPalette = otherResearchProductsPalette;
|
28
|
private resultColor = resultColor;
|
29
|
|
30
|
activeView: string = 'absolute';
|
31
|
contentAbsoluteSelection: string = 'affiliated';
|
32
|
contentPercentageSelection: string = 'affiliated';
|
33
|
|
34
|
tableAbsoluteData: CountryTableData[];
|
35
|
tablePercentageData: CountryTableData[];
|
36
|
|
37
|
loadingAbsoluteTable: boolean = true;
|
38
|
loadingPercentageTable: boolean = true;
|
39
|
|
40
|
europeOverviewData: EuropeData;
|
41
|
|
42
|
oaNoaPublicationsTimelineURL: SafeResourceUrl;
|
43
|
oaNoaDatasetsTimelineURL: SafeResourceUrl;
|
44
|
oaNoaSoftwareTimelineURL: SafeResourceUrl;
|
45
|
oaNoaOtherTimelineURL: SafeResourceUrl;
|
46
|
|
47
|
fundersResultsData: TreemapHighchartsData[];
|
48
|
|
49
|
constructor(private sanitizer: DomSanitizer,
|
50
|
private dataService: DataService,
|
51
|
private dataHandlerService: DataHandlerService) {}
|
52
|
|
53
|
ngOnInit(): void {
|
54
|
this.getAbsoluteData();
|
55
|
this.getPercentageData();
|
56
|
this.getEuropeOverviewData();
|
57
|
this.getFundersResults();
|
58
|
}
|
59
|
|
60
|
getAbsoluteData() {
|
61
|
this.loadingAbsoluteTable = true;
|
62
|
this.dataService.getOverviewTableAbsoluteData(this.contentAbsoluteSelection).subscribe(
|
63
|
rawData => {
|
64
|
this.tableAbsoluteData = this.dataHandlerService.convertRawDataToAbsoluteTableData(rawData);
|
65
|
this.loadingAbsoluteTable = false;
|
66
|
}, error => {
|
67
|
console.log(error);
|
68
|
this.loadingAbsoluteTable = false;
|
69
|
}
|
70
|
);
|
71
|
}
|
72
|
|
73
|
getPercentageData() {
|
74
|
this.loadingPercentageTable = true;
|
75
|
this.dataService.getOverviewTablePercentageData(this.contentPercentageSelection).subscribe(
|
76
|
rawData => {
|
77
|
this.tablePercentageData = this.dataHandlerService.convertRawDataToPercentageTableData(rawData);
|
78
|
this.loadingPercentageTable = false;
|
79
|
}, error => {
|
80
|
console.log(error);
|
81
|
this.loadingPercentageTable = false;
|
82
|
}
|
83
|
);
|
84
|
}
|
85
|
|
86
|
getEuropeOverviewData() {
|
87
|
this.dataService.getEuropeOAPercentages().subscribe(
|
88
|
rawData => {
|
89
|
this.europeOverviewData = this.dataHandlerService.convertRawDataToEuropeOverviewData(rawData);
|
90
|
}, error => {
|
91
|
console.log(error);
|
92
|
}
|
93
|
);
|
94
|
}
|
95
|
|
96
|
getFundersResults() {
|
97
|
this.dataService.getFundersResults().subscribe(
|
98
|
rawData => {
|
99
|
this.fundersResultsData = this.dataHandlerService.convertRawDataToTreemapHighchartsData(rawData);
|
100
|
}, error => {
|
101
|
console.log(error);
|
102
|
}
|
103
|
);
|
104
|
}
|
105
|
|
106
|
getContentAbsolute(contentSelection: string): void {
|
107
|
this.contentAbsoluteSelection = contentSelection;
|
108
|
this.getAbsoluteData();
|
109
|
}
|
110
|
|
111
|
getContentPercentage(contentSelection: string): void {
|
112
|
this.contentPercentageSelection = contentSelection;
|
113
|
this.getPercentageData();
|
114
|
}
|
115
|
|
116
|
changeView(view: string) {
|
117
|
this.activeView = view;
|
118
|
if (view === 'graph') {
|
119
|
|
120
|
if (!this.oaNoaPublicationsTimelineURL) {
|
121
|
this.oaNoaPublicationsTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA","type":"column","query":{"name":"oso.result_timeline.results.oa","parameters":["publication"],"profile":"${this.profileName}"}},{"name":"Non-OA","type":"column","query":{"name":"oso.result_timeline.results.non_oa","parameters":["publication"],"profile":"${this.profileName}"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Publications","align":"left","margin":50},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{"text":""}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false},"stacking":"normal"}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":false},"colors":[\"${this.publicationPalette.join('","')}\"]}}`));
|
122
|
}
|
123
|
if (!this.oaNoaDatasetsTimelineURL) {
|
124
|
this.oaNoaDatasetsTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA","type":"column","query":{"name":"oso.result_timeline.results.oa","parameters":["dataset"],"profile":"${this.profileName}"}},{"name":"Non-OA","type":"column","query":{"name":"oso.result_timeline.results.non_oa","parameters":["dataset"],"profile":"${this.profileName}"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Datasets","align":"left","margin":50},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{"text":""}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false},"stacking":"normal"}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":false},"colors":[\"${this.datasetPalette.join('","')}\"]}}`));
|
125
|
}
|
126
|
if (!this.oaNoaSoftwareTimelineURL) {
|
127
|
this.oaNoaSoftwareTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA","type":"column","query":{"name":"oso.result_timeline.results.oa","parameters":["software"],"profile":"${this.profileName}"}},{"name":"Non-OA","type":"column","query":{"name":"oso.result_timeline.results.non_oa","parameters":["software"],"profile":"${this.profileName}"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Software","align":"left","margin":50},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{"text":""}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false},"stacking":"normal"}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":false},"colors":[\"${this.softwarePalette.join('","')}\"]}}`));
|
128
|
}
|
129
|
if (!this.oaNoaOtherTimelineURL) {
|
130
|
this.oaNoaOtherTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA Other Research Products","type":"column","query":{"name":"oso.result_timeline.results.oa","parameters":["other"],"profile":"${this.profileName}"}},{"name":"Non-OA Other Research Products","type":"column","query":{"name":"oso.result_timeline.results.non_oa","parameters":["other"],"profile":"${this.profileName}"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Other Research Products","align":"left","margin":50},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{"text":""}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false},"stacking":"normal"}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":false},"colors":[\"${this.otherResearchProductsPalette.join('","')}\"]}}`));
|
131
|
}
|
132
|
}
|
133
|
}
|
134
|
|
135
|
printOverviewData(sectionID: string) {
|
136
|
printPage(sectionID);
|
137
|
}
|
138
|
}
|