+
+ @if (activeConfig().showLocationSelector) {
+
+ }
-
- @if (activeConfig().showAuthorSelector) {
-
-
- }
+
+ @if (activeConfig().showAuthorSelector) {
+
+ }
+
+
+ @if (activeConfig().showInstitutionSelector) {
+
+ }
+
+
+ @if (activeConfig().showAuthorSelector) {
+
+ }
+
} @else {
trending_up
diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss
index 02e5b1b7..3b8c9181 100644
--- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss
+++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss
@@ -1,185 +1,14 @@
-.trend-layout {
- display: grid;
- grid-template-columns: 300px minmax(0, 1fr);
- gap: 1.5rem;
- margin-top: 1.5rem;
- font-family: 'Inter', sans-serif;
-
- @media (max-width: 1024px) {
- grid-template-columns: 1fr;
- }
-}
-
-.trend-sidebar {
+.trend-layout-wrapper {
display: flex;
flex-direction: column;
gap: 1rem;
-}
-
-.control-card {
- background: white;
- border-radius: 10px;
- padding: 1.25rem;
- border: 1px solid #e5e7eb;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
-
- h3 {
- font-size: 0.8rem;
- font-weight: 600;
- text-transform: uppercase;
- color: #6b7280;
- margin: 0 0 0.75rem 0;
- letter-spacing: 0.05em;
- }
-}
-
-.checkbox-group {
- display: flex;
- flex-direction: column;
- gap: 0.5rem;
-}
-
-.checkbox-label {
- display: flex;
- align-items: center;
- gap: 0.5rem;
- font-size: 0.875rem;
- color: #374151;
- cursor: pointer;
-
- input[type='checkbox'] {
- accent-color: #3b82f6;
- width: 15px;
- height: 15px;
- cursor: pointer;
- }
-}
-
-.empty-list-info {
- font-size: 0.75rem;
- color: #9ca3af;
- text-align: center;
- padding: 8px 0;
- border: 1px dashed #e5e7eb;
- border-radius: 5px;
-}
-
-.trend-main {
- display: flex;
- flex-direction: column;
- gap: 1rem;
-}
-
-.trend-toggles-bar {
- display: flex;
- justify-content: space-between;
- align-items: center;
- background: white;
- border-radius: 10px;
- padding: 0.6rem 1rem;
- border: 1px solid #e5e7eb;
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
-
- .toggle-label {
- font-size: 0.8125rem;
- font-weight: 500;
- color: #4b5563;
- }
-}
-
-.toggle-buttons {
- display: flex;
- background: #f3f4f6;
- border-radius: 6px;
- padding: 2px;
-
- button {
- padding: 0.4rem 0.8rem;
- border: none;
- background: none;
- font-size: 0.75rem;
- font-weight: 500;
- color: #4b5563;
- border-radius: 5px;
- cursor: pointer;
- display: inline-flex;
- align-items: center;
- gap: 6px;
-
- mat-icon {
- font-size: 16px;
- width: 16px;
- height: 16px;
- }
-
- &:hover:not(.active) {
- color: #111827;
- background: rgba(255, 255, 255, 0.5);
- }
- &.active {
- background: white;
- color: #3b82f6;
- font-weight: 600;
- }
- }
-}
-
-.chart-holder-card {
- position: relative;
- background: white;
- border-radius: 10px;
- border: 1px solid #e5e7eb;
- overflow: hidden;
- min-height: 400px;
-}
-
-.chart-topic-tabs {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 0.4rem;
- padding: 0.6rem 1rem;
- background: #f9fafb;
- border-bottom: 1px solid #e5e7eb;
-}
-
-.loader-overlay {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(255, 255, 255, 0.8);
- z-index: 10;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
-
- .spinner {
- width: 32px;
- height: 32px;
- border: 3px solid rgba(59, 130, 246, 0.1);
- border-radius: 50%;
- border-top-color: #3b82f6;
- animation: spin 0.8s linear infinite;
- margin-bottom: 8px;
- }
-
- p {
- font-size: 0.8125rem;
- color: #4b5563;
- margin: 0;
- }
-}
-
-@keyframes spin {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(360deg);
- }
+ width: 100%;
+ box-sizing: border-box;
+ font-family:
+ 'Inter',
+ system-ui,
+ -apple-system,
+ sans-serif;
}
.strategy-toggles-bar {
@@ -190,14 +19,13 @@
border-radius: 12px;
padding: 6px;
border: 1px solid #e2e8f0;
- margin-bottom: 0.5rem;
button {
- padding: 0.5rem 1rem;
+ padding: 0.45rem 0.9rem;
border: none;
background: none;
- font-size: 0.75rem;
- font-weight: 600;
+ font-size: 0.8125rem;
+ font-weight: 500;
color: #64748b;
border-radius: 8px;
cursor: pointer;
@@ -207,41 +35,194 @@
transition: all 0.2s ease;
mat-icon {
- font-size: 16px;
- width: 16px;
- height: 16px;
+ font-size: 18px;
+ width: 18px;
+ height: 18px;
}
&:hover:not(.active):not([disabled]) {
color: #0f172a;
background: #f1f5f9;
}
+
&[disabled] {
- opacity: 0.4;
+ opacity: 0.45;
cursor: not-allowed;
}
+
&.active {
background: white;
- color: #3b82f6;
+ color: #2563eb;
+ font-weight: 600;
box-shadow:
- 0 4px 6px -1px rgba(0, 0, 0, 0.05),
- 0 2px 4px -1px rgba(0, 0, 0, 0.03);
+ 0 2px 4px rgba(0, 0, 0, 0.05),
+ 0 1px 2px rgba(0, 0, 0, 0.03);
}
}
}
+.trend-layout {
+ display: flex;
+ flex-direction: column;
+ gap: 1.25rem;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+/* Combined Top Header Control Bar */
+.trend-top-controls-bar {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 1.5rem;
+ background: white;
+ border-radius: 12px;
+ padding: 0.75rem 1.25rem;
+ border: 1px solid #e5e7eb;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
+ width: 100%;
+ box-sizing: border-box;
+
+ .slider-section {
+ flex: 1;
+ min-width: 280px;
+ }
+
+ .scale-section {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ flex-shrink: 0;
+
+ .toggle-label {
+ font-size: 0.8125rem;
+ font-weight: 600;
+ color: #4b5563;
+ white-space: nowrap;
+ }
+
+ mat-button-toggle-group {
+ border: 1px solid #e2e8f0;
+ border-radius: 8px;
+ overflow: hidden;
+ background: #f8fafc;
+ box-shadow: none;
+
+ mat-button-toggle {
+ font-size: 0.75rem;
+ font-weight: 500;
+ color: #475569;
+
+ mat-icon {
+ font-size: 16px;
+ width: 16px;
+ height: 16px;
+ margin-right: 4px;
+ vertical-align: middle;
+ }
+
+ .toggle-text {
+ white-space: nowrap;
+ }
+ }
+
+ .mat-button-toggle-checked {
+ background-color: white !important;
+ color: #2563eb !important;
+ font-weight: 600;
+ }
+ }
+ }
+
+ @media (max-width: 900px) {
+ flex-direction: column;
+ align-items: stretch;
+ gap: 1rem;
+ }
+}
+
+.trend-main-fullwidth {
+ display: flex;
+ flex-direction: column;
+ gap: 1.25rem;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+.chart-holder-card {
+ position: relative;
+ background: white;
+ border-radius: 12px;
+ border: 1px solid #e5e7eb;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
+ overflow: hidden;
+ min-height: 450px;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+.chart-topic-tabs {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 0.5rem;
+ padding: 0.75rem 1.25rem;
+ background: #f8fafc;
+ border-bottom: 1px solid #e2e8f0;
+}
+
+.loader-overlay {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(255, 255, 255, 0.85);
+ z-index: 10;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ gap: 0.75rem;
+
+ p {
+ font-size: 0.875rem;
+ font-weight: 500;
+ color: #3b82f6;
+ margin: 0;
+ }
+}
+
.pie-charts-row {
display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 1.5rem;
+ grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
+ gap: 1.25rem;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+.comparison-panels-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
+ gap: 1.25rem;
width: 100%;
box-sizing: border-box;
- @media (max-width: 768px) {
- grid-template-columns: 1fr;
+ .full-width-panel {
+ grid-column: 1 / -1;
}
}
+.comparison-panel-card {
+ background: white;
+ border-radius: 12px;
+ border: 1px solid #e5e7eb;
+ padding: 1.25rem;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
+ width: 100%;
+ box-sizing: border-box;
+}
+
.no-data-fallback {
display: flex;
flex-direction: column;
@@ -249,14 +230,21 @@
justify-content: center;
min-height: 400px;
background: white;
- border-radius: 10px;
+ border-radius: 12px;
border: 1px solid #e5e7eb;
color: #9ca3af;
- gap: 0.5rem;
+ gap: 0.75rem;
mat-icon {
- font-size: 48px;
- width: 48px;
- height: 48px;
+ font-size: 56px;
+ width: 56px;
+ height: 56px;
+ }
+
+ p {
+ font-size: 0.9375rem;
+ font-weight: 500;
+ color: #6b7280;
+ margin: 0;
}
}
diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
index b223be24..7a1635eb 100644
--- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
+++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
@@ -11,16 +11,26 @@ import {
} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
-import { ActivatedRoute, Router } from '@angular/router';
+import {
+ ActivatedRoute,
+ Router,
+ ResolveStart,
+ ResolveEnd,
+} from '@angular/router';
import { forkJoin } from 'rxjs';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatButtonModule } from '@angular/material/button';
+import {
+ MatButtonToggleModule,
+ MatButtonToggleChange,
+} from '@angular/material/button-toggle';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
+import { MatTooltipModule } from '@angular/material/tooltip';
import { UniTrendChartComponent } from '../uni-trend-chart/uni-trend-chart.component';
import { UniPieChartComponent } from '../uni-pie-chart/uni-pie-chart.component';
import {
@@ -115,8 +125,10 @@ export const TREND_CONFIGS: Record
= {
UniPieChartComponent,
MatCheckboxModule,
MatButtonModule,
+ MatButtonToggleModule,
MatIconModule,
MatProgressSpinnerModule,
+ MatTooltipModule,
TopicChipComponent,
YearRangeSliderComponent,
LocationSelectorComponent,
@@ -208,6 +220,7 @@ export class UniTrendParentComponent implements OnInit {
readonly fetchedFuzzy = signal(null);
// Results & Loading signals
+ readonly isPageResolving = signal(false);
readonly rawTrendResponse = signal(null);
readonly isTrendLoading = signal(false);
readonly topSuggestions = signal([]);
@@ -263,6 +276,29 @@ export class UniTrendParentComponent implements OnInit {
readonly boundGetTopicColor = this.getTopicColor.bind(this);
+ readonly newsSelectedTopicsPieData = computed(() => {
+ const data = this.trendResponse();
+ if (!data || !data.series || this.selectedSearchType() !== 'news') {
+ return null;
+ }
+ const startYr = this.startYear();
+ const endYr = this.endYear();
+
+ return data.series.map((s) => {
+ const topicName = s.entity_name;
+ const yearlyItems =
+ s.topic_data[topicName] || Object.values(s.topic_data)[0] || [];
+ const totalRaw = yearlyItems
+ .filter((y) => y.year >= startYr && y.year <= endYr)
+ .reduce((sum, item) => sum + (item.raw || 0), 0);
+
+ return {
+ name: topicName,
+ value: totalRaw,
+ };
+ });
+ });
+
// Autocomplete UI state
readonly searchQuery = signal('');
readonly searchResults = signal([]);
@@ -294,6 +330,13 @@ export class UniTrendParentComponent implements OnInit {
}
getEntityColor(entityId: string): string {
+ if (this.selectedSearchType() === 'news') {
+ const topicName = entityId.startsWith('news_topic_')
+ ? entityId.slice('news_topic_'.length)
+ : entityId;
+ return this.getTopicColor(topicName);
+ }
+
const defaultInstId = 'https://openalex.org/I62318514';
const primaryId = this.primaryInstitution() || defaultInstId;
const insts = this.comparisonInstitutions().map((i) => i.id);
@@ -345,17 +388,57 @@ export class UniTrendParentComponent implements OnInit {
readonly boundGetEntityColor = (id: string) => this.getEntityColor(id);
readonly boundIsVisible = (id: string) => this.isVisible(id);
- // Computed: filters out items locally if they were removed from list
+ // Computed: filters out items locally if they were removed from list and normalizes topic_data keys
readonly trendResponse = computed(() => {
const raw = this.rawTrendResponse();
- if (!raw) return null;
+ if (!raw || !raw.series) return null;
+ const topics = this.selectedTrendTopics();
const type = this.selectedSearchType();
+
+ // Map series topic_data keys to display names so they match selectedTrendTopics
+ const normalizeTopicData = (s: TrendSeries): TrendSeries => {
+ if (!s.topic_data) return s;
+ const rawTopicKeys = Object.keys(s.topic_data);
+ if (rawTopicKeys.length === 0) return s;
+
+ const newTopicData: Record = {};
+
+ topics.forEach((topicName, idx) => {
+ const mappedName = this.getMappedTopic(topicName);
+ let matchKey = rawTopicKeys.find(
+ (rk) =>
+ rk.toLowerCase() === topicName.toLowerCase() ||
+ rk.toLowerCase() === mappedName.toLowerCase() ||
+ rk.toLowerCase().includes(topicName.toLowerCase()) ||
+ rk.toLowerCase().includes(mappedName.toLowerCase()),
+ );
+
+ if (!matchKey && rawTopicKeys[idx]) {
+ matchKey = rawTopicKeys[idx];
+ }
+
+ if (matchKey && s.topic_data[matchKey]) {
+ newTopicData[topicName] = s.topic_data[matchKey];
+ } else if (rawTopicKeys[0] && s.topic_data[rawTopicKeys[0]]) {
+ newTopicData[topicName] = s.topic_data[rawTopicKeys[0]];
+ }
+ });
+
+ // Preserve existing keys as well
+ Object.assign(newTopicData, s.topic_data);
+
+ return {
+ ...s,
+ topic_data: newTopicData,
+ };
+ };
+
if (type === 'news' || type === 'all' || type === 'patents') {
return {
...raw,
series: raw.series.map((s) => ({
- ...s,
+ ...normalizeTopicData(s),
visible: this.isVisible(s.entity_id),
})),
};
@@ -368,7 +451,7 @@ export class UniTrendParentComponent implements OnInit {
const filtered = raw.series
.filter((s) => currentAuthorIds.has(s.entity_id.toLowerCase()))
.map((s) => ({
- ...s,
+ ...normalizeTopicData(s),
visible: this.isVisible(s.entity_id),
}));
return {
@@ -428,7 +511,7 @@ export class UniTrendParentComponent implements OnInit {
...countrySeries,
...regionSeries,
].map((s) => ({
- ...s,
+ ...normalizeTopicData(s),
visible: this.isVisible(s.entity_id),
}));
@@ -445,6 +528,36 @@ export class UniTrendParentComponent implements OnInit {
this.availableYears.push(y);
}
+ this.router.events.subscribe((event) => {
+ if (event instanceof ResolveStart) {
+ this.isPageResolving.set(true);
+ } else if (event instanceof ResolveEnd) {
+ this.isPageResolving.set(false);
+ }
+ });
+
+ // Subscribe to route resolver data
+ this.route.data.subscribe((data) => {
+ if (data['trendData']) {
+ const resolved = data['trendData'];
+ const res = resolved.trendResponse ?? resolved;
+ this.rawTrendResponse.set(res);
+ if (resolved.searchType) {
+ this.selectedSearchType.set(resolved.searchType);
+ }
+ if (resolved.topics && resolved.topics.length > 0) {
+ this.selectedTrendTopics.set(resolved.topics);
+ if (
+ !this.activeChartTopic() ||
+ !resolved.topics.includes(this.activeChartTopic())
+ ) {
+ this.activeChartTopic.set(resolved.topics[0]);
+ }
+ }
+ this.isTrendLoading.set(false);
+ }
+ });
+
// Effect: automatically sync checkboxes list whenever input keywords or fuzzy state changes
effect(() => {
const kws = this.keywords();
@@ -762,7 +875,7 @@ export class UniTrendParentComponent implements OnInit {
const end = this.endYear();
const strategy = this.selectedSearchType();
- if (!entity || strategy === 'news' || strategy === 'all') {
+ if (!entity || strategy === 'all') {
this.topTopicsData.set([]);
return;
}
@@ -1311,6 +1424,12 @@ export class UniTrendParentComponent implements OnInit {
this.updateUrlParams();
}
+ onChartModeChange(event: MatButtonToggleChange) {
+ if (event.value) {
+ this.setChartMode(event.value);
+ }
+ }
+
isTopicEmpty(topic: string): boolean {
const data = this.trendResponse();
if (!data || !data.series || data.series.length === 0) {
diff --git a/webapp/src/app/resolvers/uni-trend.resolver.ts b/webapp/src/app/resolvers/uni-trend.resolver.ts
new file mode 100644
index 00000000..0382efef
--- /dev/null
+++ b/webapp/src/app/resolvers/uni-trend.resolver.ts
@@ -0,0 +1,123 @@
+import { inject } from '@angular/core';
+import { ResolveFn } from '@angular/router';
+import { catchError, of, Observable, map } from 'rxjs';
+import { TrendResponse, UniversityRankingsService } from '../api';
+import { SearchResultsStateService } from '../modules/keywords-search/search-results/search-results-state.service';
+
+export interface UniTrendResolvedData {
+ trendResponse: TrendResponse | null;
+ searchType: string;
+ topics: string[];
+ keywords: string[];
+ fuzzy: boolean;
+}
+
+export const uniTrendResolver: ResolveFn = (
+ route,
+ _state,
+): Observable => {
+ const params = route.queryParamMap;
+ const searchState = inject(SearchResultsStateService, { optional: true });
+
+ const searchType = params.get('search_type') || 'publications';
+ const fuzzy = params.get('fuzzy') !== 'false';
+
+ // Extract keywords & topics
+ let keywords = params.getAll('keyword');
+ if (keywords.length === 0) {
+ const rawKeywords = params.get('keywords');
+ if (rawKeywords) {
+ keywords = rawKeywords
+ .split(',')
+ .map((k) => k.trim())
+ .filter((k) => k.length > 0);
+ }
+ }
+ if (keywords.length === 0 && searchState) {
+ keywords = searchState.keywords();
+ }
+
+ let topics = params.getAll('topic');
+ if (topics.length === 0) {
+ const rawTopics = params.get('topics');
+ if (rawTopics) {
+ topics = rawTopics
+ .split(',')
+ .map((t) => t.trim())
+ .filter((t) => t.length > 0);
+ }
+ }
+ if (topics.length === 0 && searchState) {
+ topics = fuzzy ? searchState.topicsList() : searchState.keywords();
+ }
+
+ // Fallback defaults if no topics/keywords present yet
+ if (topics.length === 0 && keywords.length === 0) {
+ topics = ['Artificial Intelligence'];
+ keywords = ['artificial intelligence'];
+ } else if (topics.length === 0) {
+ topics = keywords;
+ } else if (keywords.length === 0) {
+ keywords = topics;
+ }
+
+ // Parse institutions
+ const instParams = params.getAll('institutions');
+ let institutions = instParams.map((i) => {
+ const parts = i.split('|');
+ const cleanId = parts[0].includes('/')
+ ? parts[0].split('/').pop() || parts[0]
+ : parts[0];
+ return cleanId;
+ });
+ if (institutions.length === 0) {
+ institutions = ['I62318514'];
+ }
+
+ // Parse countries
+ const countryParams = params.getAll('countries');
+ let countries = countryParams.map((c) => c.split('|')[0]);
+ if (countries.length === 0) {
+ countries = ['DE'];
+ }
+
+ // Parse regions & authors
+ const regionParams = params.getAll('regions');
+ const regions = regionParams.map((r) => r.split('|')[0]);
+
+ const authorParams = params.getAll('authors');
+ const authors = authorParams.map((a) => a.split('|')[0]);
+
+ const apiService = inject(UniversityRankingsService);
+
+ return apiService
+ .getTrendApiInseServiceUniversityRankingsTrendGet(
+ topics,
+ keywords,
+ fuzzy,
+ institutions,
+ countries,
+ regions,
+ authors,
+ searchType as any,
+ )
+ .pipe(
+ map((trendResponse) => ({
+ trendResponse,
+ searchType,
+ topics,
+ keywords,
+ fuzzy,
+ })),
+ catchError((err) => {
+ console.error('uniTrendResolver failed to load trend data:', err);
+ return of({
+ trendResponse: null,
+ searchType,
+ topics,
+ keywords,
+ fuzzy,
+ });
+ }),
+ );
+};