1 |
58825
|
stefania.m
|
import { Component, OnInit } from '@angular/core';
|
2 |
57592
|
stefania.m
|
import { printPage } from '../../shared/reusablecomponents/print-function';
|
3 |
|
|
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
4 |
58825
|
stefania.m
|
import { DataService } from '../../services/data.service';
|
5 |
|
|
import { DataHandlerService } from '../../services/data-handler.service';
|
6 |
60835
|
stefania.m
|
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 } from '../../chart-palettes';
|
10 |
57592
|
stefania.m
|
|
11 |
|
|
@Component({
|
12 |
|
|
selector: 'app-data-view',
|
13 |
|
|
templateUrl: './data-view.component.html',
|
14 |
|
|
})
|
15 |
|
|
|
16 |
|
|
export class DataViewComponent implements OnInit {
|
17 |
|
|
|
18 |
58825
|
stefania.m
|
// @Input() type: string;
|
19 |
|
|
// @Input() countries: CountryOverview[];
|
20 |
57592
|
stefania.m
|
|
21 |
58912
|
stefania.m
|
private chartsURL = environment.API_ENDPOINT + 'chart?json=';
|
22 |
60835
|
stefania.m
|
private profileName = environment.profileName;
|
23 |
58912
|
stefania.m
|
|
24 |
60835
|
stefania.m
|
private publicationPalette = publicationPalette;
|
25 |
|
|
private datasetPalette = datasetPalette;
|
26 |
|
|
private softwarePalette = softwarePalette;
|
27 |
|
|
private otherResearchProductsPalette = otherResearchProductsPalette;
|
28 |
|
|
|
29 |
57592
|
stefania.m
|
activeView: string = 'absolute';
|
30 |
58825
|
stefania.m
|
contentAbsoluteSelection: string = 'affiliated';
|
31 |
|
|
contentPercentageSelection: string = 'affiliated';
|
32 |
57592
|
stefania.m
|
|
33 |
58825
|
stefania.m
|
tableAbsoluteData: CountryTableData[];
|
34 |
|
|
tablePercentageData: CountryTableData[];
|
35 |
|
|
|
36 |
58853
|
stefania.m
|
loadingAbsoluteTable: boolean = true;
|
37 |
|
|
loadingPercentageTable: boolean = true;
|
38 |
58825
|
stefania.m
|
|
39 |
58912
|
stefania.m
|
europeOverviewData: EuropeData;
|
40 |
57592
|
stefania.m
|
|
41 |
58912
|
stefania.m
|
oaNoaPublicationsTimelineURL: SafeResourceUrl;
|
42 |
|
|
oaNoaDatasetsTimelineURL: SafeResourceUrl;
|
43 |
|
|
oaNoaSoftwareTimelineURL: SafeResourceUrl;
|
44 |
|
|
oaNoaOtherTimelineURL: SafeResourceUrl;
|
45 |
|
|
|
46 |
|
|
fundersResultsData: TreemapHighchartsData[];
|
47 |
|
|
|
48 |
58825
|
stefania.m
|
constructor(private sanitizer: DomSanitizer,
|
49 |
|
|
private dataService: DataService,
|
50 |
|
|
private dataHandlerService: DataHandlerService) {}
|
51 |
57592
|
stefania.m
|
|
52 |
58825
|
stefania.m
|
ngOnInit(): void {
|
53 |
|
|
this.getAbsoluteData();
|
54 |
58853
|
stefania.m
|
this.getPercentageData();
|
55 |
58912
|
stefania.m
|
this.getEuropeOverviewData();
|
56 |
|
|
this.getFundersResults();
|
57 |
58825
|
stefania.m
|
}
|
58 |
|
|
|
59 |
|
|
getAbsoluteData() {
|
60 |
58853
|
stefania.m
|
this.loadingAbsoluteTable = true;
|
61 |
58825
|
stefania.m
|
this.dataService.getOverviewTableAbsoluteData(this.contentAbsoluteSelection).subscribe(
|
62 |
|
|
rawData => {
|
63 |
|
|
this.tableAbsoluteData = this.dataHandlerService.convertRawDataToAbsoluteTableData(rawData);
|
64 |
58853
|
stefania.m
|
this.loadingAbsoluteTable = false;
|
65 |
58825
|
stefania.m
|
}, error => {
|
66 |
|
|
console.log(error);
|
67 |
58853
|
stefania.m
|
this.loadingAbsoluteTable = false;
|
68 |
58825
|
stefania.m
|
}
|
69 |
|
|
);
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
getPercentageData() {
|
73 |
58853
|
stefania.m
|
this.loadingPercentageTable = true;
|
74 |
|
|
this.dataService.getOverviewTablePercentageData(this.contentPercentageSelection).subscribe(
|
75 |
58825
|
stefania.m
|
rawData => {
|
76 |
58853
|
stefania.m
|
this.tablePercentageData = this.dataHandlerService.convertRawDataToPercentageTableData(rawData);
|
77 |
|
|
this.loadingPercentageTable = false;
|
78 |
58825
|
stefania.m
|
}, error => {
|
79 |
|
|
console.log(error);
|
80 |
58853
|
stefania.m
|
this.loadingPercentageTable = false;
|
81 |
58825
|
stefania.m
|
}
|
82 |
|
|
);
|
83 |
|
|
}
|
84 |
|
|
|
85 |
58912
|
stefania.m
|
getEuropeOverviewData() {
|
86 |
|
|
this.dataService.getEuropeOAPercentages().subscribe(
|
87 |
|
|
rawData => {
|
88 |
|
|
this.europeOverviewData = this.dataHandlerService.convertRawDataToEuropeOverviewData(rawData);
|
89 |
|
|
}, error => {
|
90 |
|
|
console.log(error);
|
91 |
|
|
}
|
92 |
|
|
);
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
getFundersResults() {
|
96 |
|
|
this.dataService.getFundersResults().subscribe(
|
97 |
|
|
rawData => {
|
98 |
|
|
this.fundersResultsData = this.dataHandlerService.convertRawDataToTreemapHighchartsData(rawData);
|
99 |
|
|
}, error => {
|
100 |
|
|
console.log(error);
|
101 |
|
|
}
|
102 |
|
|
);
|
103 |
|
|
}
|
104 |
|
|
|
105 |
58825
|
stefania.m
|
getContentAbsolute(contentSelection: string): void {
|
106 |
|
|
this.contentAbsoluteSelection = contentSelection;
|
107 |
|
|
this.getAbsoluteData();
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
getContentPercentage(contentSelection: string): void {
|
111 |
|
|
this.contentPercentageSelection = contentSelection;
|
112 |
|
|
this.getPercentageData();
|
113 |
|
|
}
|
114 |
|
|
|
115 |
57592
|
stefania.m
|
changeView(view: string) {
|
116 |
|
|
this.activeView = view;
|
117 |
|
|
if (view === 'graph') {
|
118 |
58912
|
stefania.m
|
|
119 |
|
|
if (!this.oaNoaPublicationsTimelineURL) {
|
120 |
60835
|
stefania.m
|
this.oaNoaPublicationsTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA","type":"column","query":{"name":"new.oso.result_timeline.results.oa","parameters":["publication"],"profile":"${this.profileName}"}},{"name":"Non-OA","type":"column","query":{"name":"new.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('","')}\"]}}`));
|
121 |
57592
|
stefania.m
|
}
|
122 |
58912
|
stefania.m
|
if (!this.oaNoaDatasetsTimelineURL) {
|
123 |
60835
|
stefania.m
|
this.oaNoaDatasetsTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA","type":"column","query":{"name":"new.oso.result_timeline.results.oa","parameters":["dataset"],"profile":"${this.profileName}"}},{"name":"Non-OA","type":"column","query":{"name":"new.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('","')}\"]}}`));
|
124 |
57592
|
stefania.m
|
}
|
125 |
58912
|
stefania.m
|
if (!this.oaNoaSoftwareTimelineURL) {
|
126 |
60835
|
stefania.m
|
this.oaNoaSoftwareTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA","type":"column","query":{"name":"new.oso.result_timeline.results.oa","parameters":["software"],"profile":"${this.profileName}"}},{"name":"Non-OA","type":"column","query":{"name":"new.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('","')}\"]}}`));
|
127 |
57592
|
stefania.m
|
}
|
128 |
58912
|
stefania.m
|
if (!this.oaNoaOtherTimelineURL) {
|
129 |
60835
|
stefania.m
|
this.oaNoaOtherTimelineURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.chartsURL + encodeURIComponent(`{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA Other Research Products","type":"column","query":{"name":"new.oso.result_timeline.results.oa","parameters":["other"],"profile":"${this.profileName}"}},{"name":"Non-OA Other Research Products","type":"column","query":{"name":"new.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('","')}\"]}}`));
|
130 |
57592
|
stefania.m
|
}
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
|
134 |
57666
|
stefania.m
|
printOverviewData(sectionID: string) {
|
135 |
|
|
printPage(sectionID);
|
136 |
57592
|
stefania.m
|
}
|
137 |
|
|
}
|