From 11ac6525c19289666e5485126ff666f33479a8b4 Mon Sep 17 00:00:00 2001
From: Kazgatari <56477241+Kazgatari@users.noreply.github.com>
Date: Sat, 25 Jul 2026 00:27:54 +0200
Subject: [PATCH] moved row with filters up above all visuals. Implemented
treemap for fuzzy search. adapted resolver
---
.../uni-trend-parent.component.html | 202 ++++++-----
.../uni-trend-parent.component.ts | 334 ++++++++++++++++--
.../src/app/resolvers/uni-trend.resolver.ts | 73 ++--
3 files changed, 463 insertions(+), 146 deletions(-)
diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html
index ccc758ea..eba4f3a6 100644
--- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html
+++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html
@@ -92,6 +92,87 @@
+
+
+
+ @if (activeConfig().showLocationSelector) {
+
+
+ }
+
+
+ @if (activeConfig().showAuthorSelector) {
+
+
+ }
+
+
+ @if (activeConfig().showInstitutionSelector) {
+
+
+ }
+
+
+ @if (activeConfig().showAuthorSelector) {
+
+
+ }
+
+
@if (isPageResolving() || (isTrendLoading() && !rawTrendResponse())) {
@@ -109,11 +190,11 @@
@if (selectedSearchType() === 'news') {
+ (chipClick)="toggleVisibility('news_topic_' + topic)">
} @else if (selectedTrendTopics().length > 1) {
}
-
-
-
- @if (activeConfig().showLocationSelector) {
-
-
- }
-
-
- @if (activeConfig().showAuthorSelector) {
-
-
- }
-
-
- @if (activeConfig().showInstitutionSelector) {
-
-
- }
-
-
- @if (activeConfig().showAuthorSelector) {
-
-
- }
-
+
+ @if (isFuzzy() && activeTreemapData()) {
+
+
+
+ account_tree
+ Themen-Hierarchie & Verteilung (Treemap)
+ @if (selectedPieEntity()?.name || primaryInstitutionName()) {
+
+ ·
+ {{ selectedPieEntity()?.name || primaryInstitutionName() }}
+
+ }
+
+
+
+
+
+ }
} @else {
trending_up
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 9fd2a328..eb689866 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
@@ -56,6 +56,16 @@ import { AuthorSelectorComponent } from '../../../shared/ui/author-selector/auth
import { AuthorInstitutionSelectorComponent } from '../../../shared/ui/author-institution-selector/author-institution-selector.component';
import { SearchResultsStateService } from '../../keywords-search/search-results/search-results-state.service';
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
+import { TopicTreemapComponent } from '../../../shared/ui/topic-treemap/topic-treemap.component';
+import {
+ TopicTreemapData,
+ TopicTreemapField,
+ TopicTreemapSubfield,
+ TopicTreemapTopic,
+ TopicTreemapValue,
+ TopicTreemapTopicSelect,
+} from '../../../shared/ui/topic-treemap/topic-treemap.models';
+import { TopicsService } from '../../../api/api/topics.service';
export interface CompareItem {
id: string;
@@ -136,6 +146,7 @@ export const TREND_CONFIGS: Record
= {
AuthorSelectorComponent,
AuthorInstitutionSelectorComponent,
LoadingComponent,
+ TopicTreemapComponent,
],
templateUrl: './uni-trend-parent.component.html',
styleUrl: './uni-trend-parent.component.scss',
@@ -143,6 +154,7 @@ export const TREND_CONFIGS: Record = {
})
export class UniTrendParentComponent implements OnInit {
private readonly apiService = inject(UniversityRankingsService);
+ private readonly topicsService = inject(TopicsService);
private readonly institutionsApiService = inject(InstitutionsService);
private readonly personsApiService = inject(PersonsService);
private readonly organizationService = inject(OrganizationService, {
@@ -230,6 +242,12 @@ export class UniTrendParentComponent implements OnInit {
readonly isTopTopicsLoading = signal(false);
readonly topTopicsError = signal(false);
+ // Topic Treemap signals
+ readonly isFuzzy = computed(() => this.state?.fuzzySearch() ?? true);
+ readonly topicTreemap = signal(null);
+ readonly isTreemapLoading = signal(false);
+ readonly selectedTopicTreemapNode = signal(undefined);
+
getMappedTopic(topicOrKeyword: string): string {
const kws = this.keywords();
const topics = this.state?.topicsList() ?? kws;
@@ -299,6 +317,197 @@ export class UniTrendParentComponent implements OnInit {
});
});
+ cleanEntityId(id: string | null | undefined): string {
+ if (!id) return '';
+ const lower = id.toLowerCase().trim();
+ return lower.includes('/') ? lower.split('/').pop()! : lower;
+ }
+
+ // Dynamic Treemap Data for Selected Entity (Institution or Author or Region/Country)
+ readonly activeTreemapData = computed(() => {
+ const data = this.trendResponse();
+ const searchType = this.selectedSearchType();
+ const isFuzzy = this.isFuzzy();
+ if (!data || !data.series || !isFuzzy) return null;
+
+ const startYr = this.startYear();
+ const endYr = this.endYear();
+
+ const activePie = this.selectedPieEntity();
+ let targetEntityId: string | undefined = activePie?.id || undefined;
+ let targetEntityName = activePie?.name || 'Ausgewählte Entität';
+
+ if (!targetEntityId) {
+ if (searchType === 'authors') {
+ const firstAuthor = this.comparisonAuthors()[0];
+ targetEntityId = firstAuthor?.id || undefined;
+ targetEntityName = firstAuthor?.name || 'Autor';
+ } else {
+ targetEntityId = this.primaryInstitution() || undefined;
+ targetEntityName = this.primaryInstitutionName();
+ }
+ }
+
+ const cleanTargetId = targetEntityId
+ ? this.cleanEntityId(targetEntityId)
+ : '';
+
+ let matchingSeries: TrendSeries[] = [];
+ if (searchType === 'news') {
+ matchingSeries = data.series;
+ } else {
+ matchingSeries = data.series.filter(
+ (s) => this.cleanEntityId(s.entity_id) === cleanTargetId,
+ );
+ if (matchingSeries.length === 0 && data.series.length > 0) {
+ matchingSeries = data.series;
+ }
+ }
+
+ if (matchingSeries.length === 0) return null;
+
+ const keywordEntries = this.state?.selectedKeywordEntries() ?? [];
+ const fieldsMap = new Map<
+ string,
+ {
+ id: string;
+ name: string;
+ subfieldsMap: Map<
+ string,
+ {
+ id: string;
+ name: string;
+ topicsMap: Map<
+ string,
+ {
+ id: string;
+ name: string;
+ total: number;
+ values: TopicTreemapValue[];
+ }
+ >;
+ }
+ >;
+ }
+ >();
+
+ matchingSeries.forEach((s) => {
+ Object.entries(s.topic_data || {}).forEach(
+ ([topicName, yearlyDataList]) => {
+ const totalCount = yearlyDataList
+ .filter((y) => y.year >= startYr && y.year <= endYr)
+ .reduce((sum, item) => sum + (item.raw || 0), 0);
+
+ if (totalCount <= 0) return;
+
+ const mappedName = this.getMappedTopic(topicName);
+ const targetLower = topicName.toLowerCase().trim();
+ const mappedLower = mappedName.toLowerCase().trim();
+
+ const match = keywordEntries.find(
+ (e) =>
+ e.topic_mapping?.topic?.display_name?.toLowerCase().trim() ===
+ mappedLower ||
+ e.topic_mapping?.topic?.display_name?.toLowerCase().trim() ===
+ targetLower ||
+ e.llm_keyword?.keyword?.toLowerCase().trim() === targetLower,
+ );
+
+ const fieldName =
+ match?.topic_mapping?.topic?.field?.display_name ||
+ 'Information & Communication Technology';
+ const fieldId = match?.topic_mapping?.topic?.field?.id
+ ? String(match.topic_mapping.topic.field.id)
+ : 'field_ict';
+
+ const subfieldName =
+ match?.topic_mapping?.topic?.subfield?.display_name || fieldName;
+ const subfieldId = match?.topic_mapping?.topic?.subfield?.id
+ ? String(match.topic_mapping.topic.subfield.id)
+ : `subfield_${fieldId}`;
+
+ const topicId = match?.topic_mapping?.topic?.id
+ ? String(match.topic_mapping.topic.id)
+ : topicName;
+
+ if (!fieldsMap.has(fieldId)) {
+ fieldsMap.set(fieldId, {
+ id: fieldId,
+ name: fieldName,
+ subfieldsMap: new Map(),
+ });
+ }
+ const fieldEntry = fieldsMap.get(fieldId)!;
+
+ if (!fieldEntry.subfieldsMap.has(subfieldId)) {
+ fieldEntry.subfieldsMap.set(subfieldId, {
+ id: subfieldId,
+ name: subfieldName,
+ topicsMap: new Map(),
+ });
+ }
+ const subfieldEntry = fieldEntry.subfieldsMap.get(subfieldId)!;
+
+ if (!subfieldEntry.topicsMap.has(topicId)) {
+ const yearlyValues: TopicTreemapValue[] = yearlyDataList
+ .filter((y) => y.year >= startYr && y.year <= endYr)
+ .map((y) => ({
+ year: y.year,
+ count: y.raw || 0,
+ share: y.normalized || 0,
+ }));
+
+ subfieldEntry.topicsMap.set(topicId, {
+ id: topicId,
+ name: topicName,
+ total: totalCount,
+ values: yearlyValues,
+ });
+ }
+ },
+ );
+ });
+
+ const years = Array.from(
+ { length: endYr - startYr + 1 },
+ (_, i) => startYr + i,
+ );
+ const fields: TopicTreemapField[] = Array.from(fieldsMap.values()).map(
+ (f) => {
+ const subfields: TopicTreemapSubfield[] = Array.from(
+ f.subfieldsMap.values(),
+ ).map((sf) => {
+ const topics: TopicTreemapTopic[] = Array.from(sf.topicsMap.values());
+ const sfTotal = topics.reduce((sum, t) => sum + t.total, 0);
+ return {
+ id: sf.id,
+ name: sf.name,
+ total: sfTotal,
+ values: [],
+ topics,
+ };
+ });
+ const fTotal = subfields.reduce((sum, sf) => sum + sf.total, 0);
+ return {
+ id: f.id,
+ name: f.name,
+ total: fTotal,
+ values: [],
+ subfields,
+ };
+ },
+ );
+
+ if (fields.length === 0) return null;
+
+ return {
+ institution_id: cleanTargetId,
+ organization_name: targetEntityName,
+ years,
+ fields,
+ };
+ });
+
// Autocomplete UI state
readonly searchQuery = signal('');
readonly searchResults = signal([]);
@@ -316,6 +525,26 @@ export class UniTrendParentComponent implements OnInit {
readonly entityVisibilityMap = signal