From e3c1c567bf0a17e4c8d0b226b42f9b865517c224 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Sun, 21 Jun 2026 18:04:19 +0200 Subject: [PATCH 1/6] fix(wordcloud): fix overlapping of words --- webapp/package-lock.json | 10 --- webapp/package.json | 1 - .../person-overview.component.html | 22 +++-- .../person-overview.component.scss | 31 ++++++- .../person-overview.component.ts | 85 ++++++++----------- 5 files changed, 81 insertions(+), 68 deletions(-) diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 94bb537f..14b6ae31 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -19,7 +19,6 @@ "@angular/platform-browser-dynamic": "^21.2.14", "@angular/router": "^21.2.14", "echarts": "^6.1.0", - "echarts-wordcloud": "^2.1.0", "ngx-echarts": "^21.0.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", @@ -6088,15 +6087,6 @@ "zrender": "6.1.0" } }, - "node_modules/echarts-wordcloud": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/echarts-wordcloud/-/echarts-wordcloud-2.1.0.tgz", - "integrity": "sha512-Kt1JmbcROgb+3IMI48KZECK2AP5lG6bSsOEs+AsuwaWJxQom31RTNd6NFYI01E/YaI1PFZeueaupjlmzSQasjQ==", - "license": "ISC", - "peerDependencies": { - "echarts": "^5.0.1" - } - }, "node_modules/echarts/node_modules/tslib": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", diff --git a/webapp/package.json b/webapp/package.json index 7c6bbb36..3c83c9ca 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -22,7 +22,6 @@ "@angular/platform-browser-dynamic": "^21.2.14", "@angular/router": "^21.2.14", "echarts": "^6.1.0", - "echarts-wordcloud": "^2.1.0", "ngx-echarts": "^21.0.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", diff --git a/webapp/src/app/modules/person-overview/person-overview.component.html b/webapp/src/app/modules/person-overview/person-overview.component.html index 31ac9ae8..7a903cfe 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.html +++ b/webapp/src/app/modules/person-overview/person-overview.component.html @@ -17,12 +17,22 @@
@if (loadingWordCloud) {
Forschungsthemen werden geladen ...
- } @else if (wordCloudOptions) { -
+ } @else if (wordCloudWords.length) { +
+ @for (word of wordCloudWords; track word.name) { + + } +
} @else if (wordCloudEmpty) {

Keine Forschungsthemen gefunden.

} diff --git a/webapp/src/app/modules/person-overview/person-overview.component.scss b/webapp/src/app/modules/person-overview/person-overview.component.scss index 7e0732ce..f41a127d 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.scss +++ b/webapp/src/app/modules/person-overview/person-overview.component.scss @@ -11,8 +11,37 @@ .word-cloud-chart { width: 100%; - height: 420px; + min-height: 420px; + display: flex; + flex-wrap: wrap; + align-content: center; + align-items: baseline; + justify-content: center; + gap: 0.35em 1em; + padding: 1.5rem 1rem; + box-sizing: border-box; +} + +.word-cloud-word { + appearance: none; + border: none; + background: none; + padding: 0; + margin: 0; + font-family: 'Open Sans', Arial, sans-serif; + line-height: 1.1; cursor: pointer; + transition: transform 0.15s ease; + + &:hover:not(:disabled), + &:focus-visible { + transform: scale(1.08); + outline: none; + } + + &:disabled { + cursor: default; + } } .word-cloud-state, diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index 5c6c0420..5c6107e4 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -3,9 +3,6 @@ import { Component, DestroyRef, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { combineLatest, distinctUntilChanged, map } from 'rxjs'; -import { NgxEchartsDirective } from 'ngx-echarts'; -import type { EChartsOption } from 'echarts'; -import 'echarts-wordcloud'; import { TopicCount, TopicsByYear, WorksService } from '../../api'; import { @@ -17,10 +14,19 @@ import { TopicTimelineTopic, } from './components/research-timeline/research-timeline.component'; +export interface WordCloudWord { + name: string; + value: number; + topicId: string | undefined; + color: string; + fontSize: number; + fontWeight: number; +} + @Component({ selector: 'app-person-overview', standalone: true, - imports: [CommonModule, ResearchTimelineComponent, NgxEchartsDirective], + imports: [CommonModule, ResearchTimelineComponent], templateUrl: './person-overview.component.html', styleUrl: './person-overview.component.scss', }) @@ -50,7 +56,7 @@ export class PersonOverviewComponent implements OnInit { timelineStartYear: number | undefined; timelineEndYear: number | undefined; - wordCloudOptions: EChartsOption | null = null; + wordCloudWords: WordCloudWord[] = []; loadingWordCloud = false; wordCloudEmpty = false; @@ -155,17 +161,14 @@ export class PersonOverviewComponent implements OnInit { this.loadCompleteTopicTimeline(this.currentAuthorId); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - onWordClick(event: any): void { - const topicId = event?.data?.topicId; - const topicName = event?.data?.name; - if (!topicId) return; + onWordClick(word: WordCloudWord): void { + if (!word.topicId) return; void this.router.navigate(['../publications'], { relativeTo: this.route, queryParams: { publicationPage: 1, - publicationTopicId: topicId, - publicationTopicName: topicName, + publicationTopicId: word.topicId, + publicationTopicName: word.name, }, }); } @@ -297,7 +300,7 @@ export class PersonOverviewComponent implements OnInit { private loadWordCloud(authorId: string): void { if (!authorId || authorId === '0') { - this.wordCloudOptions = null; + this.wordCloudWords = []; this.wordCloudEmpty = false; this.loadingWordCloud = false; this.rawTopicOccurrences = []; @@ -306,7 +309,7 @@ export class PersonOverviewComponent implements OnInit { this.loadingWordCloud = true; this.wordCloudEmpty = false; - this.wordCloudOptions = null; + this.wordCloudWords = []; this.worksService .getAuthorWorks(authorId, 1, 100) @@ -360,7 +363,7 @@ export class PersonOverviewComponent implements OnInit { } if (counts.size === 0) { - this.wordCloudOptions = null; + this.wordCloudWords = []; this.wordCloudEmpty = true; return; } @@ -370,51 +373,33 @@ export class PersonOverviewComponent implements OnInit { const allValues = Array.from(counts.values()); const minVal = Math.min(...allValues); const maxVal = Math.max(...allValues); - const computeSize = (v: number): number => - maxVal === minVal - ? 22 - : Math.round(12 + ((v - minVal) / (maxVal - minVal)) * (32 - 12)); + const intensity = (v: number): number => + maxVal === minVal ? 1 : (v - minVal) / (maxVal - minVal); const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]); - const data = sorted.slice(0, 30).map(([name, value], i) => { - const fontSize = computeSize(value); - const color = this.timelineColors[i % this.timelineColors.length]; + const words = sorted.slice(0, 30).map(([name, value], i): WordCloudWord => { + const t = intensity(value); return { name, value, topicId: nameToId.get(name), - textStyle: { color, fontSize }, - emphasis: { - textStyle: { - fontSize: Math.round(fontSize * 1.1), - color, - shadowBlur: 16, - shadowColor: 'rgba(0, 87, 255, 0.35)', - }, - }, + color: this.timelineColors[i % this.timelineColors.length], + fontSize: Math.round(12 + t * (32 - 12)), + fontWeight: t > 0.66 ? 800 : t > 0.33 ? 600 : 400, }; }); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - this.wordCloudOptions = { - series: [ - { - type: 'wordCloud', - rotationRange: [0, 0], - rotationStep: 0, - gridSize: 4, - width: '100%', - height: '100%', - drawOutOfBound: false, - textStyle: { - fontFamily: 'Open Sans, sans-serif', - fontWeight: 'bold', - }, - data, - }, - ], - } as any; + const centred: WordCloudWord[] = []; + words.forEach((word, i) => { + if (i % 2 === 0) { + centred.push(word); + } else { + centred.unshift(word); + } + }); + + this.wordCloudWords = centred; } private mapTimelineElements( -- 2.56.1 From 1205ebb1c07ceaef550f1544498cc02fc14ef3ca Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Wed, 24 Jun 2026 23:52:38 +0200 Subject: [PATCH 2/6] derive topic colors from the field only --- webapp/src/app/shared/utils/topic-colors.ts | 51 ++++----------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/webapp/src/app/shared/utils/topic-colors.ts b/webapp/src/app/shared/utils/topic-colors.ts index 7dfbfc9d..1d2b69d9 100644 --- a/webapp/src/app/shared/utils/topic-colors.ts +++ b/webapp/src/app/shared/utils/topic-colors.ts @@ -1,8 +1,6 @@ export interface TopicHierarchyColorInput { id?: string | null; name?: string | null; - subfield_id?: string | null; - subfield_name?: string | null; field_id?: string | null; field_name?: string | null; domain_id?: string | null; @@ -52,30 +50,8 @@ const DOMAIN_FALLBACK_HUES: Record = { 'social sciences': 24, }; -interface SubfieldColorVariant { - hueOffset: number; - saturation: number; - lightness: number; -} - -const SUBFIELD_COLOR_VARIANTS: readonly SubfieldColorVariant[] = [ - { hueOffset: -6, saturation: 92, lightness: 27 }, - { hueOffset: 6, saturation: 82, lightness: 48 }, - { hueOffset: -2, saturation: 90, lightness: 35 }, - { hueOffset: 7, saturation: 78, lightness: 42 }, - { hueOffset: -8, saturation: 86, lightness: 31 }, - { hueOffset: 3, saturation: 94, lightness: 24 }, - { hueOffset: 8, saturation: 84, lightness: 38 }, - { hueOffset: -4, saturation: 80, lightness: 45 }, - { hueOffset: 0, saturation: 92, lightness: 30 }, - { hueOffset: 8, saturation: 76, lightness: 50 }, - { hueOffset: -7, saturation: 88, lightness: 40 }, - { hueOffset: 4, saturation: 80, lightness: 33 }, - { hueOffset: -8, saturation: 82, lightness: 47 }, - { hueOffset: 2, saturation: 96, lightness: 26 }, - { hueOffset: 8, saturation: 86, lightness: 36 }, - { hueOffset: -2, saturation: 78, lightness: 43 }, -]; +const FIELD_COLOR_SATURATION = 86; +const FIELD_COLOR_LIGHTNESS = 36; export function topicHierarchyColor( topic: TopicHierarchyColorInput | undefined | null, @@ -86,29 +62,22 @@ export function topicHierarchyColor( const fieldKey = normalizeColorKey(topic.field_name); const domainKey = normalizeColorKey(topic.domain_name); - const fieldIdentity = - topic.field_id ?? fieldKey ?? topic.domain_id ?? domainKey; - const subfieldIdentity = - topic.subfield_id ?? - normalizeColorKey(topic.subfield_name) ?? + const fieldIdentity = topic.field_id ?? fieldKey; + const fallbackIdentity = + fieldIdentity ?? + topic.domain_id ?? + domainKey ?? topic.id ?? normalizeColorKey(topic.name) ?? - fieldIdentity ?? 'topic'; const baseHue = (fieldKey ? FIELD_HUES[fieldKey] : undefined) ?? (domainKey ? DOMAIN_FALLBACK_HUES[domainKey] : undefined) ?? - stableHue(fieldIdentity ?? subfieldIdentity); + stableHue(fallbackIdentity); + const hue = normalizeHue(baseHue); - const variantHash = stableHash(subfieldIdentity); - const variant = - SUBFIELD_COLOR_VARIANTS[variantHash % SUBFIELD_COLOR_VARIANTS.length]; - const hue = normalizeHue(baseHue + variant.hueOffset); - const saturation = variant.saturation; - const lightness = variant.lightness; - - return `hsl(${hue} ${saturation}% ${lightness}%)`; + return `hsl(${hue} ${FIELD_COLOR_SATURATION}% ${FIELD_COLOR_LIGHTNESS}%)`; } function normalizeColorKey( -- 2.56.1 From 17037668d8235d1bbf6c9cacdab94913973de433 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Wed, 24 Jun 2026 23:52:56 +0200 Subject: [PATCH 3/6] share topic legend between timeline and interesting-for --- .../topic-legend/topic-legend.component.html | 89 ++++++++ .../topic-legend/topic-legend.component.scss | 201 ++++++++++++++++++ .../ui/topic-legend/topic-legend.component.ts | 76 +++++++ webapp/src/app/shared/utils/topic-legend.ts | 152 +++++++++++++ 4 files changed, 518 insertions(+) create mode 100644 webapp/src/app/shared/ui/topic-legend/topic-legend.component.html create mode 100644 webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss create mode 100644 webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts create mode 100644 webapp/src/app/shared/utils/topic-legend.ts diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html new file mode 100644 index 00000000..34c724d1 --- /dev/null +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.html @@ -0,0 +1,89 @@ +
+
+
+ {{ title }} + + info_outline + +
+ + +
+ +
+ + info_outline + + +
+
+ + + {{ group.name }} + + + + + {{ item.name }} + + +
+ + +
+
+
diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss new file mode 100644 index 00000000..fa9fca76 --- /dev/null +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.scss @@ -0,0 +1,201 @@ +:host { + display: block; +} + +.topic-legend { + --topic-legend-accent: #0057ff; + + width: min(760px, 100%); + box-sizing: border-box; + margin-top: 16px; + padding: 13px 16px; + border: 1px solid #dbe5f6; + border-radius: 8px; + background: #ffffff; +} + +.topic-legend-header, +.topic-legend-title, +.topic-legend-visibility-toggle, +.topic-legend-body, +.topic-legend-content, +.topic-legend-group, +.topic-legend-field, +.topic-legend-items { + display: flex; + align-items: center; +} + +.topic-legend-header { + justify-content: space-between; + gap: 16px; +} + +.topic-legend-title { + gap: 5px; + color: #07163d; + font-size: 12px; + font-weight: 800; + line-height: 1.25; +} + +.topic-legend-info { + flex: 0 0 auto; + width: 14px; + height: 14px; + color: #7d8aa8; + font-size: 14px; + line-height: 14px; +} + +.topic-legend-visibility-toggle, +.topic-legend-more-toggle { + border: 0; + background: transparent; + color: var(--topic-legend-accent); + cursor: pointer; + font-family: inherit; + font-weight: 700; + + &:hover { + text-decoration: none; + } + + &:focus-visible { + outline: 2px solid var(--topic-legend-accent); + outline-offset: 2px; + border-radius: 4px; + } +} + +.topic-legend-visibility-toggle { + flex: 0 0 auto; + gap: 4px; + padding: 0; + font-size: 11px; + line-height: 1.2; + + mat-icon { + width: 14px; + height: 14px; + font-size: 14px; + line-height: 14px; + } +} + +.topic-legend-body { + align-items: flex-start; + gap: 9px; + margin-top: 17px; +} + +.topic-legend-body-inline-info { + margin-top: 0; +} + +.topic-legend-content { + flex-wrap: wrap; + gap: 8px; + min-width: 0; +} + +.topic-legend-group { + gap: 9px; + max-width: 100%; + min-width: 0; + min-height: 28px; + padding: 5px 9px; + border: 1px solid #dbe5f6; + border-radius: 999px; + background: #fbfdff; +} + +.topic-legend-field { + flex: 0 1 auto; + min-width: 0; + gap: 5px; + color: #07163d; + font-size: 11px; + font-weight: 800; + line-height: 1.2; + cursor: help; +} + +.topic-legend-field span:last-child, +.topic-legend-item { + overflow-wrap: anywhere; +} + +.topic-legend-dot { + flex: 0 0 auto; + width: 9px; + height: 9px; + border: 1px solid rgba(255, 255, 255, 0.85); + border-radius: 50%; + box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2); +} + +.topic-legend-items { + flex: 0 1 auto; + flex-wrap: wrap; + gap: 6px 11px; + min-width: 0; +} + +.topic-legend-item { + color: #53617e; + font-size: 11px; + font-weight: 600; + line-height: 1.25; + cursor: help; +} + +.topic-legend-more-toggle { + flex: 0 0 auto; + padding: 0; + font-size: 11px; + line-height: 1.25; +} + +.topic-legend-compact { + width: fit-content; + max-width: 100%; + margin: 0 0 16px; + padding: 8px 10px; + + .topic-legend-body { + gap: 9px; + } + + .topic-legend-content { + gap: 7px; + } + + .topic-legend-group { + gap: 6px; + flex-wrap: wrap; + min-height: 24px; + padding: 3px 7px; + } + + .topic-legend-field, + .topic-legend-item { + font-size: 10px; + } + + .topic-legend-dot { + width: 8px; + height: 8px; + } + + .topic-legend-more-toggle { + min-height: 24px; + padding: 0 2px; + font-size: 11px; + white-space: nowrap; + + &:hover { + text-decoration: underline; + } + } +} diff --git a/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts new file mode 100644 index 00000000..171ac204 --- /dev/null +++ b/webapp/src/app/shared/ui/topic-legend/topic-legend.component.ts @@ -0,0 +1,76 @@ +import { CommonModule } from '@angular/common'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { MatIconModule } from '@angular/material/icon'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { TopicLegendGroup, TopicLegendItem } from '../../utils/topic-legend'; + +export type TopicLegendVariant = 'default' | 'compact'; + +@Component({ + selector: 'app-topic-legend', + standalone: true, + imports: [CommonModule, MatIconModule, MatTooltipModule], + templateUrl: './topic-legend.component.html', + styleUrl: './topic-legend.component.scss', +}) +export class TopicLegendComponent { + @Input() groups: TopicLegendGroup[] = []; + @Input() title = 'Farben nach Fachgebiet'; + @Input() infoTooltip = + 'Fachgebiete bestimmen die Farbe. Themenbereiche werden darunter gruppiert.'; + @Input() visible = true; + @Input() expanded = false; + @Input() showTitle = true; + @Input() showVisibilityToggle = true; + @Input() collapsedGroupLimit = 3; + @Input() variant: TopicLegendVariant = 'default'; + + @Output() visibleChange = new EventEmitter(); + @Output() expandedChange = new EventEmitter(); + + get hasGroups(): boolean { + return this.groups.length > 0; + } + + get hasHeader(): boolean { + return this.showTitle || this.showVisibilityToggle; + } + + get visibleGroups(): TopicLegendGroup[] { + if (this.expanded) { + return this.groups; + } + + return this.groups.slice(0, this.collapsedGroupLimit); + } + + get hiddenLegendItemCount(): number { + if (this.expanded) { + return 0; + } + + return this.groups + .slice(this.collapsedGroupLimit) + .reduce((count, group) => count + group.items.length, 0); + } + + get showExpandedToggle(): boolean { + return this.expanded || this.hiddenLegendItemCount > 0; + } + + toggleVisibility(): void { + this.visibleChange.emit(!this.visible); + } + + toggleExpanded(): void { + this.expandedChange.emit(!this.expanded); + } + + trackByGroup(_: number, group: TopicLegendGroup): string { + return group.id; + } + + trackByItem(_: number, item: TopicLegendItem): string { + return item.id; + } +} diff --git a/webapp/src/app/shared/utils/topic-legend.ts b/webapp/src/app/shared/utils/topic-legend.ts new file mode 100644 index 00000000..a54779c3 --- /dev/null +++ b/webapp/src/app/shared/utils/topic-legend.ts @@ -0,0 +1,152 @@ +import { topicHierarchyColor, TopicHierarchyColorInput } from './topic-colors'; + +export interface TopicLegendTopic extends TopicHierarchyColorInput { + subfield_id?: string | null; + subfield_name?: string | null; + subfield_description?: string | null; + field_description?: string | null; + domain_description?: string | null; +} + +export interface TopicLegendItem { + id: string; + name: string; + description: string; + tooltip: string; +} + +export interface TopicLegendGroup { + id: string; + name: string; + description: string; + domainName: string; + domainDescription: string; + color: string; + tooltip: string; + items: TopicLegendItem[]; +} + +export function buildTopicLegendGroups( + topics: readonly TopicLegendTopic[], +): TopicLegendGroup[] { + const groups = new Map(); + + for (const topic of topics) { + const subfieldName = normalizeLegendValue(topic.subfield_name); + + if (!subfieldName) { + continue; + } + + const fieldName = + normalizeLegendValue(topic.field_name) ?? 'Ohne Fachgebiet'; + const fieldDescription = + normalizeLegendValue(topic.field_description) ?? ''; + const domainName = normalizeLegendValue(topic.domain_name) ?? ''; + const domainDescription = + normalizeLegendValue(topic.domain_description) ?? ''; + const subfieldDescription = + normalizeLegendValue(topic.subfield_description) ?? ''; + const fieldKey = topic.field_id ?? normalizeLegendKey(fieldName); + const subfieldKey = topic.subfield_id ?? normalizeLegendKey(subfieldName); + + if (!groups.has(fieldKey)) { + groups.set(fieldKey, { + id: fieldKey, + name: fieldName, + description: fieldDescription, + domainName, + domainDescription, + color: topicHierarchyColor(topic), + tooltip: buildTopicLegendTooltip([ + { + label: 'Fachgebiet', + value: fieldName, + description: fieldDescription, + }, + { + label: 'Wissenschaftsbereich', + value: domainName, + description: domainDescription, + }, + ]), + items: [], + }); + } + + const group = groups.get(fieldKey); + + if (!group || group.items.some((item) => item.id === subfieldKey)) { + continue; + } + + group.items.push({ + id: subfieldKey, + name: subfieldName, + description: subfieldDescription, + tooltip: buildTopicLegendTooltip([ + { + label: 'Themenbereich', + value: subfieldName, + description: subfieldDescription, + }, + { + label: 'Fachgebiet', + value: fieldName, + description: fieldDescription, + }, + { + label: 'Wissenschaftsbereich', + value: domainName, + description: domainDescription, + }, + ]), + }); + } + + return [...groups.values()] + .map((group) => ({ + ...group, + items: group.items.sort((left, right) => + left.name.localeCompare(right.name), + ), + })) + .sort((left, right) => left.name.localeCompare(right.name)); +} + +function buildTopicLegendTooltip( + entries: Array<{ label: string; value: string; description: string }>, +): string { + const lines: string[] = []; + + for (const entry of entries) { + if (!entry.value && !entry.description) { + continue; + } + + if (lines.length > 0) { + lines.push(''); + } + + if (entry.value) { + lines.push(`${entry.label}: ${entry.value}`); + } + + if (entry.description) { + lines.push(''); + lines.push(`Beschreibung: ${entry.description}`); + } + } + + return lines.join('\n'); +} + +function normalizeLegendValue(value: string | null | undefined): string | null { + const normalized = value?.trim(); + + return normalized || null; +} + +function normalizeLegendKey(value: string): string { + return value.trim().toLowerCase(); +} -- 2.56.1 From d1bb1363c016eb4df1465191451d0a60906186ac Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Wed, 24 Jun 2026 23:53:08 +0200 Subject: [PATCH 4/6] show one color marker per field with subfields grouped underneath --- .../person-interesting.component.html | 65 +------ .../person-interesting.component.scss | 121 ------------ .../person-interesting.component.ts | 164 +++------------- .../research-timeline.component.html | 89 +-------- .../research-timeline.component.scss | 125 ------------- .../research-timeline.component.ts | 175 ++---------------- 6 files changed, 56 insertions(+), 683 deletions(-) diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.html b/webapp/src/app/modules/person-interesting/person-interesting.component.html index 7a9e4e45..bc015605 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.html +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.html @@ -8,62 +8,15 @@ }
- @if (visibleLegendGroups().length > 0) { -
- - info_outline - - -
- @for (group of visibleLegendGroups(); track group.id) { - - {{ group.name }} - - @for (item of group.items; track item.id) { - - - {{ item.name }} - - } - - - } - - @if (hasHiddenLegendGroups()) { - - } -
-
- } + +
@if (tags().length > 0) { @for (tag of tags(); track tag.label) { diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.scss b/webapp/src/app/modules/person-interesting/person-interesting.component.scss index 3132b644..9d82782e 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.scss +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.scss @@ -45,127 +45,6 @@ line-height: 1; } -.interest-legend { - display: flex; - align-items: flex-start; - gap: 9px; - width: fit-content; - max-width: 100%; - margin: 0 0 16px; - padding: 8px 10px; - border: 1px solid #dbe5f6; - border-radius: 8px; - background: #ffffff; - box-sizing: border-box; -} - -.interest-legend-content, -.interest-legend-group, -.interest-legend-items, -.interest-legend-item { - display: inline-flex; - align-items: center; -} - -.interest-legend-info { - flex: 0 0 auto; - width: 14px; - height: 14px; - color: #7d8aa8; - font-size: 14px; - line-height: 14px; -} - -.interest-legend-content { - gap: 7px; - flex: 0 1 auto; - min-width: 0; - max-width: 100%; - flex-wrap: wrap; -} - -.interest-legend-group { - gap: 6px; - flex: 0 1 auto; - flex-wrap: wrap; - min-width: 0; - max-width: 100%; - min-height: 24px; - padding: 3px 7px; - border: 1px solid #dbe5f6; - border-radius: 999px; - background: #fbfdff; -} - -.interest-legend-field { - flex: 0 1 auto; - min-width: 0; - color: #07163d; - font-size: 10px; - font-weight: 800; - line-height: 1.2; - cursor: help; -} - -.interest-legend-items { - flex: 0 1 auto; - gap: 4px 7px; - min-width: 0; - flex-wrap: wrap; -} - -.interest-legend-item { - gap: 4px; - flex: 0 0 auto; - min-width: 0; - color: #53617e; - font-size: 10px; - font-weight: 600; - line-height: 1.2; - white-space: nowrap; - cursor: help; - - span:last-child { - overflow: visible; - text-overflow: clip; - } -} - -.interest-legend-dot { - flex: 0 0 auto; - width: 8px; - height: 8px; - border: 1px solid rgba(255, 255, 255, 0.85); - border-radius: 50%; - box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2); -} - -.interest-legend-more { - display: inline-flex; - align-items: center; - flex: 0 0 auto; - min-height: 24px; - padding: 0 2px; - border: 0; - background: transparent; - color: var(--accent, #0057ff); - cursor: pointer; - font: inherit; - font-size: 11px; - font-weight: 700; - white-space: nowrap; - - &:hover { - text-decoration: underline; - } - - &:focus-visible { - outline: 2px solid var(--accent, #0057ff); - outline-offset: 2px; - border-radius: 4px; - } -} - .interest-tags .interest-empty { padding: 9px 16px; border: 1px solid #e2e8f0; diff --git a/webapp/src/app/modules/person-interesting/person-interesting.component.ts b/webapp/src/app/modules/person-interesting/person-interesting.component.ts index d8d496aa..b4b67654 100644 --- a/webapp/src/app/modules/person-interesting/person-interesting.component.ts +++ b/webapp/src/app/modules/person-interesting/person-interesting.component.ts @@ -10,13 +10,14 @@ import { } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatIconModule } from '@angular/material/icon'; -import { MatTooltipModule } from '@angular/material/tooltip'; import { CommonModule } from '@angular/common'; import { ActivatedRoute, Router } from '@angular/router'; import { TopicCount } from '../../api'; import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component'; +import { TopicLegendComponent } from '../../shared/ui/topic-legend/topic-legend.component'; import { topicHierarchyColor } from '../../shared/utils/topic-colors'; +import { buildTopicLegendGroups } from '../../shared/utils/topic-legend'; interface InterestTag { id: string; @@ -35,30 +36,16 @@ interface InterestTag { domainDescription: string; } -interface InterestLegendGroup { - id: string; - name: string; - description: string; - domainName: string; - domainDescription: string; - tooltip: string; - items: InterestLegendItem[]; -} - -interface InterestLegendItem { - id: string; - name: string; - description: string; - color: string; - tooltip: string; -} - const MAX_TAGS = 5; -const MAX_LEGEND_GROUPS = 3; @Component({ selector: 'app-person-interesting', - imports: [CommonModule, MatIconModule, MatTooltipModule, TopicChipComponent], + imports: [ + CommonModule, + MatIconModule, + TopicChipComponent, + TopicLegendComponent, + ], templateUrl: './person-interesting.component.html', styleUrl: './person-interesting.component.scss', }) @@ -104,95 +91,22 @@ export class PersonInterestingComponent implements OnInit { return tags.sort((a, b) => b.count - a.count).slice(0, MAX_TAGS); }); - readonly legendGroups = computed(() => { - const groups = new Map(); - - for (const tag of this.tags()) { - if (!tag.subfieldName) { - continue; - } - - const fieldName = tag.fieldName || 'Ohne Field'; - const fieldId = tag.fieldId || fieldName.toLowerCase(); - const subfieldId = tag.subfieldId || tag.subfieldName.toLowerCase(); - - if (!groups.has(fieldId)) { - groups.set(fieldId, { - id: fieldId, - name: fieldName, - description: tag.fieldDescription, - domainName: tag.domainName, - domainDescription: tag.domainDescription, - tooltip: this.buildLegendTooltip([ - { - label: 'Fachgebiet', - value: fieldName, - description: tag.fieldDescription, - }, - { - label: 'Wissenschaftsbereich', - value: tag.domainName, - description: tag.domainDescription, - }, - ]), - items: [], - }); - } - - const group = groups.get(fieldId); - - if (!group || group.items.some((item) => item.id === subfieldId)) { - continue; - } - - group.items.push({ - id: subfieldId, - name: tag.subfieldName, - description: tag.subfieldDescription, - color: tag.color, - tooltip: this.buildLegendTooltip([ - { - label: 'Themenbereich', - value: tag.subfieldName, - description: tag.subfieldDescription, - }, - { - label: 'Fachgebiet', - value: fieldName, - description: tag.fieldDescription, - }, - { - label: 'Wissenschaftsbereich', - value: tag.domainName, - description: tag.domainDescription, - }, - ]), - }); - } - - return [...groups.values()] - .map((group) => ({ - ...group, - items: group.items.sort((left, right) => - left.name.localeCompare(right.name), - ), - })) - .sort((left, right) => left.name.localeCompare(right.name)); - }); - - readonly visibleLegendGroups = computed(() => { - const groups = this.legendGroups(); - return this.legendExpanded() ? groups : groups.slice(0, MAX_LEGEND_GROUPS); - }); - - readonly hasHiddenLegendGroups = computed( - () => this.legendGroups().length > MAX_LEGEND_GROUPS, - ); - - readonly hiddenLegendItemCount = computed(() => - this.legendGroups() - .slice(MAX_LEGEND_GROUPS) - .reduce((count, group) => count + group.items.length, 0), + readonly legendGroups = computed(() => + buildTopicLegendGroups( + this.tags().map((tag) => ({ + id: tag.id, + name: tag.label, + subfield_id: tag.subfieldId, + subfield_name: tag.subfieldName, + subfield_description: tag.subfieldDescription, + field_id: tag.fieldId, + field_name: tag.fieldName, + field_description: tag.fieldDescription, + domain_id: tag.domainId, + domain_name: tag.domainName, + domain_description: tag.domainDescription, + })), + ), ); ngOnInit(): void { @@ -215,8 +129,7 @@ export class PersonInterestingComponent implements OnInit { this.tagClick.emit({ id: tag.id, name: tag.label }); } - toggleLegend(): void { - const expanded = !this.legendExpanded(); + onLegendExpandedChange(expanded: boolean): void { this.legendExpanded.set(expanded); void this.router.navigate([], { @@ -249,31 +162,4 @@ export class PersonInterestingComponent implements OnInit { return fallback; } - - private buildLegendTooltip( - entries: Array<{ label: string; value: string; description: string }>, - ): string { - const lines: string[] = []; - - for (const entry of entries) { - if (!entry.value && !entry.description) { - continue; - } - - if (lines.length > 0) { - lines.push(''); - } - - if (entry.value) { - lines.push(`${entry.label}: ${entry.value}`); - } - - if (entry.description) { - lines.push(''); - lines.push(`Beschreibung: ${entry.description}`); - } - } - - return lines.join('\n'); - } } diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html index dd8801dc..fb4d9f42 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.html @@ -7,87 +7,14 @@ (basierend auf Publikationen)

-
-
-
- Farben nach Themenbereich - - info_outline - -
- - -
- -
-
- {{ group.name }} - - - - - {{ item.name }} - - -
- - -
-
+ + Date: Thu, 25 Jun 2026 18:04:24 +0200 Subject: [PATCH 5/6] feat(wordcloud): apply new color scheme to wordcloud --- .../person-overview.component.ts | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index f77b728f..244843b5 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -5,6 +5,7 @@ import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { combineLatest, distinctUntilChanged, map } from 'rxjs'; import { TopicCount, TopicsByYear, WorksService } from '../../api'; +import { topicHierarchyColor } from '../../shared/utils/topic-colors'; import { ResearchTimelineComponent, TimelineViewMode, @@ -70,6 +71,10 @@ export class PersonOverviewComponent implements OnInit { name: string; topicId: string; year: number | undefined; + fieldId: string | undefined; + fieldName: string | undefined; + domainId: string | undefined; + domainName: string | undefined; }> = []; ngOnInit(): void { @@ -334,14 +339,6 @@ export class PersonOverviewComponent implements OnInit { this.timelineEarlierYearsLoadFailed = false; } - private readonly timelineColors = [ - '#7255d9', - '#2678e8', - '#39a96b', - '#f59e0b', - '#e0527c', - ]; - private loadWordCloud(authorId: string): void { if (!authorId || authorId === '0') { this.wordCloudWords = []; @@ -369,6 +366,10 @@ export class PersonOverviewComponent implements OnInit { name: topic.display_name, topicId: topic.id, year, + fieldId: topic.field?.id ?? undefined, + fieldName: topic.field?.display_name ?? undefined, + domainId: topic.domain?.id ?? undefined, + domainName: topic.domain?.display_name ?? undefined, }); } }); @@ -396,6 +397,10 @@ export class PersonOverviewComponent implements OnInit { const end = this.timelineEndYear; const counts = new Map(); const nameToId = new Map(); + const nameToColorInput = new Map< + string, + Parameters[0] + >(); for (const occ of this.rawTopicOccurrences) { if (start !== undefined && (occ.year === undefined || occ.year < start)) @@ -403,7 +408,17 @@ export class PersonOverviewComponent implements OnInit { if (end !== undefined && (occ.year === undefined || occ.year > end)) continue; counts.set(occ.name, (counts.get(occ.name) ?? 0) + 1); - if (!nameToId.has(occ.name)) nameToId.set(occ.name, occ.topicId); + if (!nameToId.has(occ.name)) { + nameToId.set(occ.name, occ.topicId); + nameToColorInput.set(occ.name, { + id: occ.topicId, + name: occ.name, + field_id: occ.fieldId, + field_name: occ.fieldName, + domain_id: occ.domainId, + domain_name: occ.domainName, + }); + } } if (counts.size === 0) { @@ -422,13 +437,13 @@ export class PersonOverviewComponent implements OnInit { const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]); - const words = sorted.slice(0, 30).map(([name, value], i): WordCloudWord => { + const words = sorted.slice(0, 30).map(([name, value]): WordCloudWord => { const t = intensity(value); return { name, value, topicId: nameToId.get(name), - color: this.timelineColors[i % this.timelineColors.length], + color: topicHierarchyColor(nameToColorInput.get(name)), fontSize: Math.round(12 + t * (32 - 12)), fontWeight: t > 0.66 ? 800 : t > 0.33 ? 600 : 400, }; -- 2.56.1 From e76c0b81873582ecd33e63fc565c7e56c407d197 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Tue, 30 Jun 2026 00:54:44 +0200 Subject: [PATCH 6/6] feat(wordcloud): add legend and tooltips --- .../research-timeline.component.ts | 12 +++--- .../person-overview.component.html | 5 ++- .../person-overview.component.ts | 37 ++++++++++++++++--- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts index 9d88ff2d..1e08547e 100644 --- a/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts +++ b/webapp/src/app/modules/person-overview/components/research-timeline/research-timeline.component.ts @@ -18,6 +18,7 @@ import { topicHierarchyColor } from '../../../../shared/utils/topic-colors'; import { buildTopicLegendGroups, TopicLegendGroup, + TopicLegendTopic, } from '../../../../shared/utils/topic-legend'; import { buildTopicHierarchyTooltip } from '../../../../shared/utils/topic-tooltip'; @@ -109,6 +110,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { @Input() endYear: number | undefined; @Input() subfieldLegendVisible = true; @Input() subfieldLegendExpanded = false; + @Input() wordCloudLegendTopics: TopicLegendTopic[] = []; @Output() viewModeChange = new EventEmitter(); @Output() yearRangeChange = new EventEmitter(); @@ -570,14 +572,14 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked { } private get allSubfieldLegendGroups(): TopicLegendGroup[] { - if ( - this.loading || - this.loadFailed || - this.timelineViewMode === 'wordcloud' - ) { + if (this.loading || this.loadFailed) { return []; } + if (this.timelineViewMode === 'wordcloud') { + return buildTopicLegendGroups(this.wordCloudLegendTopics); + } + return buildTopicLegendGroups(this.visibleLegendTopics); } diff --git a/webapp/src/app/modules/person-overview/person-overview.component.html b/webapp/src/app/modules/person-overview/person-overview.component.html index e7ee0af2..7b4404b9 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.html +++ b/webapp/src/app/modules/person-overview/person-overview.component.html @@ -11,6 +11,7 @@ [endYear]="timelineEndYear" [subfieldLegendVisible]="timelineLegendVisible" [subfieldLegendExpanded]="timelineLegendExpanded" + [wordCloudLegendTopics]="wordCloudLegendTopics" (viewModeChange)="onTimelineViewModeChange($event)" (yearRangeChange)="onTimelineYearRangeChange($event)" (subfieldLegendVisibleChange)="onTimelineLegendVisibleChange($event)" @@ -31,7 +32,9 @@ [style.fontSize.px]="word.fontSize" [style.fontWeight]="word.fontWeight" [disabled]="!word.topicId" - [title]="word.name + ' (' + word.value + ')'" + [matTooltip]="word.tooltip" + [matTooltipDisabled]="!word.tooltip" + matTooltipClass="topic-chip-tooltip" (click)="onWordClick(word)"> {{ word.name }} diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index 244843b5..912efc06 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -2,10 +2,13 @@ import { CommonModule } from '@angular/common'; import { Component, DestroyRef, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ActivatedRoute, ParamMap, Router } from '@angular/router'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { combineLatest, distinctUntilChanged, map } from 'rxjs'; import { TopicCount, TopicsByYear, WorksService } from '../../api'; import { topicHierarchyColor } from '../../shared/utils/topic-colors'; +import { TopicLegendTopic } from '../../shared/utils/topic-legend'; +import { buildTopicHierarchyTooltip } from '../../shared/utils/topic-tooltip'; import { ResearchTimelineComponent, TimelineViewMode, @@ -22,12 +25,13 @@ export interface WordCloudWord { color: string; fontSize: number; fontWeight: number; + tooltip: string; } @Component({ selector: 'app-person-overview', standalone: true, - imports: [CommonModule, ResearchTimelineComponent], + imports: [CommonModule, ResearchTimelineComponent, MatTooltipModule], templateUrl: './person-overview.component.html', styleUrl: './person-overview.component.scss', }) @@ -64,6 +68,7 @@ export class PersonOverviewComponent implements OnInit { timelineLegendExpanded = false; wordCloudWords: WordCloudWord[] = []; + wordCloudLegendTopics: TopicLegendTopic[] = []; loadingWordCloud = false; wordCloudEmpty = false; @@ -75,6 +80,8 @@ export class PersonOverviewComponent implements OnInit { fieldName: string | undefined; domainId: string | undefined; domainName: string | undefined; + subfieldId: string | undefined; + subfieldName: string | undefined; }> = []; ngOnInit(): void { @@ -342,6 +349,7 @@ export class PersonOverviewComponent implements OnInit { private loadWordCloud(authorId: string): void { if (!authorId || authorId === '0') { this.wordCloudWords = []; + this.wordCloudLegendTopics = []; this.wordCloudEmpty = false; this.loadingWordCloud = false; this.rawTopicOccurrences = []; @@ -351,6 +359,7 @@ export class PersonOverviewComponent implements OnInit { this.loadingWordCloud = true; this.wordCloudEmpty = false; this.wordCloudWords = []; + this.wordCloudLegendTopics = []; this.worksService .getAuthorWorks(authorId, 1, 100) @@ -370,6 +379,8 @@ export class PersonOverviewComponent implements OnInit { fieldName: topic.field?.display_name ?? undefined, domainId: topic.domain?.id ?? undefined, domainName: topic.domain?.display_name ?? undefined, + subfieldId: topic.subfield?.id ?? undefined, + subfieldName: topic.subfield?.display_name ?? undefined, }); } }); @@ -378,6 +389,7 @@ export class PersonOverviewComponent implements OnInit { this.loadingWordCloud = false; if (this.rawTopicOccurrences.length === 0) { + this.wordCloudLegendTopics = []; this.wordCloudEmpty = true; return; } @@ -387,6 +399,7 @@ export class PersonOverviewComponent implements OnInit { error: (error) => { console.error('Word cloud could not be loaded.', error); this.loadingWordCloud = false; + this.wordCloudLegendTopics = []; this.wordCloudEmpty = true; }, }); @@ -397,10 +410,7 @@ export class PersonOverviewComponent implements OnInit { const end = this.timelineEndYear; const counts = new Map(); const nameToId = new Map(); - const nameToColorInput = new Map< - string, - Parameters[0] - >(); + const nameToColorInput = new Map(); for (const occ of this.rawTopicOccurrences) { if (start !== undefined && (occ.year === undefined || occ.year < start)) @@ -417,12 +427,15 @@ export class PersonOverviewComponent implements OnInit { field_name: occ.fieldName, domain_id: occ.domainId, domain_name: occ.domainName, + subfield_id: occ.subfieldId, + subfield_name: occ.subfieldName, }); } } if (counts.size === 0) { this.wordCloudWords = []; + this.wordCloudLegendTopics = []; this.wordCloudEmpty = true; return; } @@ -436,16 +449,28 @@ export class PersonOverviewComponent implements OnInit { maxVal === minVal ? 1 : (v - minVal) / (maxVal - minVal); const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]); + const topNames = sorted.slice(0, 30).map(([name]) => name); + + this.wordCloudLegendTopics = topNames + .map((name) => nameToColorInput.get(name)) + .filter((topic): topic is TopicLegendTopic => Boolean(topic)); const words = sorted.slice(0, 30).map(([name, value]): WordCloudWord => { const t = intensity(value); + const colorInput = nameToColorInput.get(name); return { name, value, topicId: nameToId.get(name), - color: topicHierarchyColor(nameToColorInput.get(name)), + color: topicHierarchyColor(colorInput), fontSize: Math.round(12 + t * (32 - 12)), fontWeight: t > 0.66 ? 800 : t > 0.33 ? 600 : 400, + tooltip: buildTopicHierarchyTooltip({ + topicName: name, + subfieldName: colorInput?.subfield_name, + fieldName: colorInput?.field_name, + domainName: colorInput?.domain_name, + }), }; }); -- 2.56.1