Merge remote-tracking branch 'origin/feature/timeline' into topic-colored-chips
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-06-25 00:02:43 +02:00
5 changed files with 81 additions and 68 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",
@@ -21,12 +21,22 @@
<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"
[title]="word.name + ' (' + word.value + ')'"
(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,
@@ -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',
})
@@ -56,7 +62,7 @@ export class PersonOverviewComponent implements OnInit {
timelineLegendVisible = true;
timelineLegendExpanded = false;
wordCloudOptions: EChartsOption | null = null;
wordCloudWords: WordCloudWord[] = [];
loadingWordCloud = false;
wordCloudEmpty = false;
@@ -199,17 +205,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,
},
});
}
@@ -341,7 +344,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 = [];
@@ -350,7 +353,7 @@ export class PersonOverviewComponent implements OnInit {
this.loadingWordCloud = true;
this.wordCloudEmpty = false;
this.wordCloudOptions = null;
this.wordCloudWords = [];
this.worksService
.getAuthorWorks(authorId, 1, 100)
@@ -404,7 +407,7 @@ export class PersonOverviewComponent implements OnInit {
}
if (counts.size === 0) {
this.wordCloudOptions = null;
this.wordCloudWords = [];
this.wordCloudEmpty = true;
return;
}
@@ -414,51 +417,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(