Merge pull request 'feature/timeline' (#176) from feature/timeline into dev
LocationBasedServices/smartguide/pipeline/head This commit looks good

Reviewed-on: #176
This commit was merged in pull request #176.
This commit is contained in:
2026-06-30 01:13:40 +02:00
16 changed files with 722 additions and 804 deletions
-10
View File
@@ -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",
-1
View File
@@ -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",
@@ -8,62 +8,15 @@
</span>
}
</div>
@if (visibleLegendGroups().length > 0) {
<div class="interest-legend" aria-label="Aktuell sichtbare Themenbereiche">
<mat-icon
class="interest-legend-info"
matTooltip="Fachgebiete geben die Farbfamilie vor, Themenbereiche bestimmen die konkrete Farbvariante."
matTooltipPosition="above"
aria-label="Informationen zur Farblegende">
info_outline
</mat-icon>
<div class="interest-legend-content">
@for (group of visibleLegendGroups(); track group.id) {
<span class="interest-legend-group">
<span
class="interest-legend-field"
[matTooltip]="group.tooltip"
[matTooltipDisabled]="!group.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above"
>{{ group.name }}</span
>
<span class="interest-legend-items">
@for (item of group.items; track item.id) {
<span
class="interest-legend-item"
[matTooltip]="item.tooltip"
[matTooltipDisabled]="!item.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above">
<span
class="interest-legend-dot"
[style.background]="item.color"
aria-hidden="true"></span>
<span>{{ item.name }}</span>
</span>
}
</span>
</span>
}
@if (hasHiddenLegendGroups()) {
<button
type="button"
class="interest-legend-more"
[attr.aria-expanded]="legendExpanded()"
(click)="toggleLegend()">
@if (legendExpanded()) {
Weniger anzeigen
} @else {
+{{ hiddenLegendItemCount() }} weitere
}
</button>
}
</div>
</div>
}
<app-topic-legend
[groups]="legendGroups()"
[expanded]="legendExpanded()"
[showTitle]="false"
[showVisibilityToggle]="false"
[collapsedGroupLimit]="3"
variant="compact"
(expandedChange)="onLegendExpandedChange($event)">
</app-topic-legend>
<div class="interest-tags">
@if (tags().length > 0) {
@for (tag of tags(); track tag.label) {
@@ -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;
@@ -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<InterestLegendGroup[]>(() => {
const groups = new Map<string, InterestLegendGroup>();
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<InterestLegendGroup[]>(() => {
const groups = this.legendGroups();
return this.legendExpanded() ? groups : groups.slice(0, MAX_LEGEND_GROUPS);
});
readonly hasHiddenLegendGroups = computed<boolean>(
() => this.legendGroups().length > MAX_LEGEND_GROUPS,
);
readonly hiddenLegendItemCount = computed<number>(() =>
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');
}
}
@@ -7,87 +7,14 @@
<span>(basierend auf Publikationen)</span>
</p>
<div
*ngIf="subfieldLegendGroups.length > 0"
class="subfield-legend"
[class.expanded]="subfieldLegendExpanded"
aria-label="Aktuell sichtbare Themenbereiche">
<div class="subfield-legend-header">
<div class="subfield-legend-title">
<span>Farben nach Themenbereich</span>
<mat-icon
class="subfield-legend-info"
matTooltip="Fachgebiete geben die Farbfamilie vor, Themenbereiche bestimmen die konkrete Farbvariante."
matTooltipPosition="above"
aria-label="Informationen zur Farblegende">
info_outline
</mat-icon>
</div>
<button
type="button"
class="subfield-legend-visibility-toggle"
[attr.aria-expanded]="subfieldLegendVisible"
(click)="toggleSubfieldLegendVisibility()">
<span>
{{
subfieldLegendVisible
? 'Legende ausblenden'
: 'Legende einblenden'
}}
</span>
<mat-icon aria-hidden="true">
{{ subfieldLegendVisible ? 'expand_less' : 'expand_more' }}
</mat-icon>
</button>
</div>
<div *ngIf="subfieldLegendVisible" class="subfield-legend-content">
<div
*ngFor="
let group of subfieldLegendGroups;
trackBy: trackByLegendGroup
"
class="subfield-legend-group">
<span
class="subfield-legend-field"
[matTooltip]="group.tooltip"
[matTooltipDisabled]="!group.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above"
>{{ group.name }}</span
>
<span class="subfield-legend-items">
<span
*ngFor="let item of group.items; trackBy: trackByLegendItem"
class="subfield-legend-item"
[matTooltip]="item.tooltip"
[matTooltipDisabled]="!item.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above">
<span
class="subfield-legend-dot"
[style.background]="item.color"
aria-hidden="true"></span>
<span>{{ item.name }}</span>
</span>
</span>
</div>
<button
*ngIf="showSubfieldLegendToggle"
type="button"
class="subfield-legend-more-toggle"
(click)="toggleSubfieldLegend()">
{{
subfieldLegendExpanded
? 'Weniger anzeigen'
: '+' + hiddenSubfieldLegendItemCount + ' weitere'
}}
</button>
</div>
</div>
<app-topic-legend
[groups]="topicLegendGroups"
[visible]="subfieldLegendVisible"
[expanded]="subfieldLegendExpanded"
[collapsedGroupLimit]="3"
(visibleChange)="onSubfieldLegendVisibleChange($event)"
(expandedChange)="onSubfieldLegendExpandedChange($event)">
</app-topic-legend>
<span
*ngIf="
@@ -64,131 +64,6 @@
}
}
.subfield-legend {
width: min(760px, 100%);
box-sizing: border-box;
margin-top: 16px;
padding: 13px 16px;
border: 1px solid #dbe5f6;
border-radius: 8px;
background: #ffffff;
}
.subfield-legend-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
}
.subfield-legend-title,
.subfield-legend-visibility-toggle,
.subfield-legend-content,
.subfield-legend-group,
.subfield-legend-items,
.subfield-legend-item {
display: flex;
align-items: center;
}
.subfield-legend-title {
gap: 5px;
color: #07163d;
font-size: 12px;
font-weight: 800;
line-height: 1.25;
}
.subfield-legend-info {
width: 14px;
height: 14px;
color: #7d8aa8;
font-size: 14px;
line-height: 14px;
}
.subfield-legend-visibility-toggle {
flex: 0 0 auto;
gap: 4px;
color: var(--accent);
font-size: 11px;
font-weight: 700;
line-height: 1.2;
mat-icon {
width: 14px;
height: 14px;
font-size: 14px;
line-height: 14px;
}
&:hover {
text-decoration: none;
}
}
.subfield-legend-content {
flex-wrap: wrap;
gap: 8px;
margin-top: 17px;
}
.subfield-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;
}
.subfield-legend-field {
flex: 0 0 auto;
color: #07163d;
font-size: 11px;
font-weight: 800;
line-height: 1.2;
cursor: help;
}
.subfield-legend-items {
flex-wrap: wrap;
gap: 6px 11px;
min-width: 0;
}
.subfield-legend-item {
gap: 5px;
min-width: 0;
color: #53617e;
font-size: 11px;
font-weight: 600;
line-height: 1.25;
cursor: help;
}
.subfield-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);
}
.subfield-legend-more-toggle {
flex: 0 0 auto;
color: var(--accent);
font-size: 11px;
font-weight: 700;
&:hover {
text-decoration: none;
}
}
.view-toggle {
justify-self: center;
display: flex;
@@ -1,5 +1,4 @@
import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTooltipModule } from '@angular/material/tooltip';
import {
@@ -14,7 +13,13 @@ import {
ViewChild,
} from '@angular/core';
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,
TopicLegendGroup,
TopicLegendTopic,
} from '../../../../shared/utils/topic-legend';
import { buildTopicHierarchyTooltip } from '../../../../shared/utils/topic-tooltip';
export interface TopicTimelineTopic {
@@ -78,33 +83,15 @@ interface TimelineScrollAnchor {
scrollLeft: number;
}
interface TopicSubfieldLegendItem {
id: string;
name: string;
description: string;
color: string;
tooltip: string;
}
interface TopicFieldLegendGroup {
id: string;
name: string;
description: string;
domainName: string;
domainDescription: string;
tooltip: string;
items: TopicSubfieldLegendItem[];
}
@Component({
selector: 'app-research-timeline',
standalone: true,
imports: [
CommonModule,
MatIconModule,
MatProgressSpinnerModule,
MatTooltipModule,
TopicChipComponent,
TopicLegendComponent,
],
templateUrl: './research-timeline.component.html',
styleUrl: './research-timeline.component.scss',
@@ -123,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<TimelineViewMode>();
@Output() yearRangeChange = new EventEmitter<TimelineYearRange>();
@@ -142,7 +130,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
private readonly columnWidth = 240;
private readonly displayedTopicLimit = 3;
private readonly displayedPhaseTopicLimit = 4;
private readonly collapsedSubfieldLegendGroupLimit = 3;
private readonly scrollRestoreThreshold = 24;
private readonly expandedPhaseIds = new Set<string>();
@@ -198,30 +185,8 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
return this.buildCompactPhases(this.timelineItems);
}
get subfieldLegendGroups(): TopicFieldLegendGroup[] {
const groups = this.allSubfieldLegendGroups;
if (this.subfieldLegendExpanded) {
return groups;
}
return groups.slice(0, this.collapsedSubfieldLegendGroupLimit);
}
get hiddenSubfieldLegendItemCount(): number {
if (this.subfieldLegendExpanded) {
return 0;
}
return this.allSubfieldLegendGroups
.slice(this.collapsedSubfieldLegendGroupLimit)
.reduce((count, group) => count + group.items.length, 0);
}
get showSubfieldLegendToggle(): boolean {
return (
this.subfieldLegendExpanded || this.hiddenSubfieldLegendItemCount > 0
);
get topicLegendGroups(): TopicLegendGroup[] {
return this.allSubfieldLegendGroups;
}
get hasYearRange(): boolean {
@@ -416,33 +381,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
return this.getTopicTooltip(topic).length > 0;
}
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');
}
getYearTopicCountTooltip(
topic: TopicTimelineTopic,
item: TopicTimelineElement,
@@ -477,24 +415,16 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
return topicHierarchyColor(topic);
}
toggleSubfieldLegend(): void {
this.subfieldLegendExpanded = !this.subfieldLegendExpanded;
onSubfieldLegendExpandedChange(expanded: boolean): void {
this.subfieldLegendExpanded = expanded;
this.subfieldLegendExpandedChange.emit(this.subfieldLegendExpanded);
}
toggleSubfieldLegendVisibility(): void {
this.subfieldLegendVisible = !this.subfieldLegendVisible;
onSubfieldLegendVisibleChange(visible: boolean): void {
this.subfieldLegendVisible = visible;
this.subfieldLegendVisibleChange.emit(this.subfieldLegendVisible);
}
trackByLegendGroup(_: number, group: TopicFieldLegendGroup): string {
return group.id;
}
trackByLegendItem(_: number, item: TopicSubfieldLegendItem): string {
return item.id;
}
trackByYear(_: number, item: TopicTimelineElement): number {
return item.year;
}
@@ -641,91 +571,16 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
);
}
private get allSubfieldLegendGroups(): TopicFieldLegendGroup[] {
if (
this.loading ||
this.loadFailed ||
this.timelineViewMode === 'wordcloud'
) {
private get allSubfieldLegendGroups(): TopicLegendGroup[] {
if (this.loading || this.loadFailed) {
return [];
}
const groups = new Map<string, TopicFieldLegendGroup>();
for (const topic of this.visibleLegendTopics) {
const subfieldName = topic.subfield_name?.trim();
if (!subfieldName) {
continue;
}
const fieldName = topic.field_name?.trim() || 'Ohne Field';
const fieldKey = topic.field_id ?? this.normalizeTopicName(fieldName);
const subfieldKey =
topic.subfield_id ?? this.normalizeTopicName(subfieldName);
if (!groups.has(fieldKey)) {
groups.set(fieldKey, {
id: fieldKey,
name: fieldName,
description: topic.field_description?.trim() ?? '',
domainName: topic.domain_name?.trim() ?? '',
domainDescription: topic.domain_description?.trim() ?? '',
tooltip: this.buildLegendTooltip([
{
label: 'Fachgebiet',
value: fieldName,
description: topic.field_description?.trim() ?? '',
},
{
label: 'Wissenschaftsbereich',
value: topic.domain_name?.trim() ?? '',
description: topic.domain_description?.trim() ?? '',
},
]),
items: [],
});
}
const group = groups.get(fieldKey);
if (!group || group.items.some((item) => item.id === subfieldKey)) {
continue;
}
group.items.push({
id: subfieldKey,
name: subfieldName,
description: topic.subfield_description?.trim() ?? '',
color: this.getTopicColor(topic),
tooltip: this.buildLegendTooltip([
{
label: 'Themenbereich',
value: subfieldName,
description: topic.subfield_description?.trim() ?? '',
},
{
label: 'Fachgebiet',
value: fieldName,
description: topic.field_description?.trim() ?? '',
},
{
label: 'Wissenschaftsbereich',
value: topic.domain_name?.trim() ?? '',
description: topic.domain_description?.trim() ?? '',
},
]),
});
if (this.timelineViewMode === 'wordcloud') {
return buildTopicLegendGroups(this.wordCloudLegendTopics);
}
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));
return buildTopicLegendGroups(this.visibleLegendTopics);
}
private get visibleLegendTopics(): TopicTimelineTopic[] {
@@ -11,6 +11,7 @@
[endYear]="timelineEndYear"
[subfieldLegendVisible]="timelineLegendVisible"
[subfieldLegendExpanded]="timelineLegendExpanded"
[wordCloudLegendTopics]="wordCloudLegendTopics"
(viewModeChange)="onTimelineViewModeChange($event)"
(yearRangeChange)="onTimelineYearRangeChange($event)"
(subfieldLegendVisibleChange)="onTimelineLegendVisibleChange($event)"
@@ -21,12 +22,24 @@
<div timeline-wordcloud-content class="word-cloud-view">
@if (loadingWordCloud) {
<div class="word-cloud-state">Forschungsthemen werden geladen ...</div>
} @else if (wordCloudOptions) {
<div
echarts
[options]="wordCloudOptions"
(chartClick)="onWordClick($event)"
class="word-cloud-chart"></div>
} @else if (wordCloudWords.length) {
<div class="word-cloud-chart">
@for (word of wordCloudWords; track word.name) {
<button
type="button"
class="word-cloud-word"
[style.color]="word.color"
[style.fontSize.px]="word.fontSize"
[style.fontWeight]="word.fontWeight"
[disabled]="!word.topicId"
[matTooltip]="word.tooltip"
[matTooltipDisabled]="!word.tooltip"
matTooltipClass="topic-chip-tooltip"
(click)="onWordClick(word)">
{{ word.name }}
</button>
}
</div>
} @else if (wordCloudEmpty) {
<p class="word-cloud-empty">Keine Forschungsthemen gefunden.</p>
}
@@ -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,
@@ -2,12 +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 { NgxEchartsDirective } from 'ngx-echarts';
import type { EChartsOption } from 'echarts';
import 'echarts-wordcloud';
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,
@@ -17,10 +18,20 @@ 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;
tooltip: string;
}
@Component({
selector: 'app-person-overview',
standalone: true,
imports: [CommonModule, ResearchTimelineComponent, NgxEchartsDirective],
imports: [CommonModule, ResearchTimelineComponent, MatTooltipModule],
templateUrl: './person-overview.component.html',
styleUrl: './person-overview.component.scss',
})
@@ -56,7 +67,8 @@ export class PersonOverviewComponent implements OnInit {
timelineLegendVisible = true;
timelineLegendExpanded = false;
wordCloudOptions: EChartsOption | null = null;
wordCloudWords: WordCloudWord[] = [];
wordCloudLegendTopics: TopicLegendTopic[] = [];
loadingWordCloud = false;
wordCloudEmpty = false;
@@ -64,6 +76,12 @@ export class PersonOverviewComponent implements OnInit {
name: string;
topicId: string;
year: number | undefined;
fieldId: string | undefined;
fieldName: string | undefined;
domainId: string | undefined;
domainName: string | undefined;
subfieldId: string | undefined;
subfieldName: string | undefined;
}> = [];
ngOnInit(): void {
@@ -199,17 +217,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,
},
});
}
@@ -331,17 +346,10 @@ 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.wordCloudOptions = null;
this.wordCloudWords = [];
this.wordCloudLegendTopics = [];
this.wordCloudEmpty = false;
this.loadingWordCloud = false;
this.rawTopicOccurrences = [];
@@ -350,7 +358,8 @@ export class PersonOverviewComponent implements OnInit {
this.loadingWordCloud = true;
this.wordCloudEmpty = false;
this.wordCloudOptions = null;
this.wordCloudWords = [];
this.wordCloudLegendTopics = [];
this.worksService
.getAuthorWorks(authorId, 1, 100)
@@ -366,6 +375,12 @@ 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,
subfieldId: topic.subfield?.id ?? undefined,
subfieldName: topic.subfield?.display_name ?? undefined,
});
}
});
@@ -374,6 +389,7 @@ export class PersonOverviewComponent implements OnInit {
this.loadingWordCloud = false;
if (this.rawTopicOccurrences.length === 0) {
this.wordCloudLegendTopics = [];
this.wordCloudEmpty = true;
return;
}
@@ -383,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;
},
});
@@ -393,6 +410,7 @@ export class PersonOverviewComponent implements OnInit {
const end = this.timelineEndYear;
const counts = new Map<string, number>();
const nameToId = new Map<string, string>();
const nameToColorInput = new Map<string, TopicLegendTopic>();
for (const occ of this.rawTopicOccurrences) {
if (start !== undefined && (occ.year === undefined || occ.year < start))
@@ -400,11 +418,24 @@ 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,
subfield_id: occ.subfieldId,
subfield_name: occ.subfieldName,
});
}
}
if (counts.size === 0) {
this.wordCloudOptions = null;
this.wordCloudWords = [];
this.wordCloudLegendTopics = [];
this.wordCloudEmpty = true;
return;
}
@@ -414,51 +445,45 @@ 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 topNames = sorted.slice(0, 30).map(([name]) => name);
const data = sorted.slice(0, 30).map(([name, value], i) => {
const fontSize = computeSize(value);
const color = this.timelineColors[i % this.timelineColors.length];
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),
textStyle: { color, fontSize },
emphasis: {
textStyle: {
fontSize: Math.round(fontSize * 1.1),
color,
shadowBlur: 16,
shadowColor: 'rgba(0, 87, 255, 0.35)',
},
},
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,
}),
};
});
// 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(
@@ -0,0 +1,89 @@
<section
*ngIf="hasGroups"
class="topic-legend"
[class.topic-legend-compact]="variant === 'compact'"
[class.topic-legend-expanded]="expanded"
aria-label="Aktuell sichtbare Themenbereiche">
<div *ngIf="hasHeader" class="topic-legend-header">
<div *ngIf="showTitle" class="topic-legend-title">
<span>{{ title }}</span>
<mat-icon
class="topic-legend-info"
[matTooltip]="infoTooltip"
matTooltipPosition="above"
aria-label="Informationen zur Farblegende">
info_outline
</mat-icon>
</div>
<button
*ngIf="showVisibilityToggle"
type="button"
class="topic-legend-visibility-toggle"
[attr.aria-expanded]="visible"
(click)="toggleVisibility()">
<span>{{ visible ? 'Legende ausblenden' : 'Legende einblenden' }}</span>
<mat-icon aria-hidden="true">
{{ visible ? 'expand_less' : 'expand_more' }}
</mat-icon>
</button>
</div>
<div
*ngIf="visible"
class="topic-legend-body"
[class.topic-legend-body-inline-info]="!hasHeader">
<mat-icon
*ngIf="!hasHeader"
class="topic-legend-info topic-legend-info-inline"
[matTooltip]="infoTooltip"
matTooltipPosition="above"
aria-label="Informationen zur Farblegende">
info_outline
</mat-icon>
<div class="topic-legend-content">
<div
*ngFor="let group of visibleGroups; trackBy: trackByGroup"
class="topic-legend-group">
<span
class="topic-legend-field"
[matTooltip]="group.tooltip"
[matTooltipDisabled]="!group.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above">
<span
class="topic-legend-dot"
[style.background]="group.color"
aria-hidden="true"></span>
<span>{{ group.name }}</span>
</span>
<span class="topic-legend-items">
<span
*ngFor="let item of group.items; trackBy: trackByItem"
class="topic-legend-item"
[matTooltip]="item.tooltip"
[matTooltipDisabled]="!item.tooltip"
matTooltipClass="topic-chip-tooltip"
matTooltipPosition="above">
{{ item.name }}
</span>
</span>
</div>
<button
*ngIf="showExpandedToggle"
type="button"
class="topic-legend-more-toggle"
[attr.aria-expanded]="expanded"
(click)="toggleExpanded()">
{{
expanded
? 'Weniger anzeigen'
: '+' + hiddenLegendItemCount + ' weitere'
}}
</button>
</div>
</div>
</section>
@@ -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;
}
}
}
@@ -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<boolean>();
@Output() expandedChange = new EventEmitter<boolean>();
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;
}
}
+10 -41
View File
@@ -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<string, number> = {
'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(
+152
View File
@@ -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<string, TopicLegendGroup>();
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();
}