feat(wordcloud): integrate wordcloud in person overview page
LocationBasedServices/smartguide/pipeline/head There was a failure building this commit

This commit is contained in:
2026-06-08 15:15:07 +02:00
parent 0f838e3429
commit c9601b06a2
6 changed files with 286 additions and 168 deletions
+10 -165
View File
@@ -19,6 +19,7 @@
"@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",
@@ -325,38 +326,6 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/@angular-devkit/architect/node_modules/chokidar": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
"integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"readdirp": "^5.0.0"
},
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@angular-devkit/architect/node_modules/readdirp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
"integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==",
"dev": true,
"optional": true,
"peer": true,
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@angular-devkit/architect/node_modules/source-map": {
"version": "0.7.6",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz",
@@ -431,38 +400,6 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/@angular-devkit/schematics/node_modules/chokidar": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
"integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"readdirp": "^5.0.0"
},
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@angular-devkit/schematics/node_modules/readdirp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
"integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==",
"dev": true,
"optional": true,
"peer": true,
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@angular-devkit/schematics/node_modules/source-map": {
"version": "0.7.6",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz",
@@ -701,38 +638,6 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/@angular/cli/node_modules/chokidar": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
"integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"readdirp": "^5.0.0"
},
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@angular/cli/node_modules/readdirp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
"integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==",
"dev": true,
"optional": true,
"peer": true,
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@angular/cli/node_modules/source-map": {
"version": "0.7.6",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz",
@@ -1264,43 +1169,6 @@
"node": ">=0.1.90"
}
},
"node_modules/@emnapi/core": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
"integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"@emnapi/wasi-threads": "1.2.1",
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
"integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/wasi-threads": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
"integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.27.3",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz",
@@ -4535,38 +4403,6 @@
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/@schematics/angular/node_modules/chokidar": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
"integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"readdirp": "^5.0.0"
},
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@schematics/angular/node_modules/readdirp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
"integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==",
"dev": true,
"optional": true,
"peer": true,
"engines": {
"node": ">= 20.19.0"
},
"funding": {
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@schematics/angular/node_modules/source-map": {
"version": "0.7.6",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz",
@@ -6252,6 +6088,15 @@
"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,6 +22,7 @@
"@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",
+2
View File
@@ -10,6 +10,7 @@ import { authenticationInterceptor } from './shared/interceptors/authentication.
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
import { MatPaginatorIntl } from '@angular/material/paginator';
import { PaginatorIntl } from './shared/utils/paginatorIntl';
import { provideEchartsCore } from 'ngx-echarts';
registerLocaleData(locale);
@@ -26,5 +27,6 @@ export const appConfig: ApplicationConfig = {
provideHttpClient(withInterceptors([authenticationInterceptor])),
// provideApi('/inse-service'),
provideAnimationsAsync(),
provideEchartsCore({ echarts: () => import('echarts') }),
],
};
@@ -11,4 +11,34 @@
(topicSelect)="onTimelineTopicSelect($event)"
(yearSelect)="onTimelineYearSelect($event)"
></app-research-timeline>
@if (wordCloudOptions) {
<div class="word-cloud-card">
<div class="word-cloud-header">
<h3 class="word-cloud-title">Forschungsthemen</h3>
@if (sliderMax > 5) {
<div class="word-cloud-slider-wrapper">
<span class="slider-label">{{ topN }} Themen</span>
<div class="word-cloud-slider" [style.--range-value]="sliderPercent">
<div class="range-track"></div>
<input
type="range"
[min]="5"
[max]="sliderMax"
[value]="topN"
(input)="onTopNChange($event)"
aria-label="Anzahl der angezeigten Themen"
/>
</div>
</div>
}
</div>
<div
echarts
[options]="wordCloudOptions"
(chartClick)="onWordClick($event)"
class="word-cloud-chart"
></div>
</div>
}
</section>
@@ -1,4 +1,118 @@
.person-overview {
width: 100%;
display: block;
padding: 1.5rem 1.5rem 0;
box-sizing: border-box;
}
.word-cloud-card {
margin-top: 1.5rem;
padding: 24px 28px;
border: 1px solid #d7e4ff;
border-radius: 16px;
background: #ffffff;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
box-sizing: border-box;
}
.word-cloud-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1.5rem;
margin-bottom: 0.75rem;
}
.word-cloud-title {
margin: 0;
font-family: "Montserrat", "Open Sans", Arial, sans-serif;
font-size: 20px;
font-weight: 700;
color: var(--sg-text);
}
.word-cloud-slider-wrapper {
display: flex;
align-items: center;
gap: 0.75rem;
flex-shrink: 0;
}
.slider-label {
font-size: 13px;
color: var(--sg-text-muted);
white-space: nowrap;
min-width: 4.5rem;
text-align: right;
}
.word-cloud-slider {
--accent: #0057ff;
--range-value: 50%;
position: relative;
width: 160px;
height: 22px;
.range-track {
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 5px;
transform: translateY(-50%);
border-radius: 999px;
background: linear-gradient(
to right,
var(--accent) 0%,
var(--accent) var(--range-value),
#d8e2f4 var(--range-value),
#d8e2f4 100%
);
}
input[type='range'] {
position: absolute;
inset: 0;
width: 100%;
height: 22px;
margin: 0;
appearance: none;
background: transparent;
&::-webkit-slider-runnable-track,
&::-moz-range-track {
height: 5px;
background: transparent;
border: none;
}
&::-webkit-slider-thumb {
appearance: none;
width: 15px;
height: 15px;
margin-top: -5px;
border: 2px solid #ffffff;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 1px #9ab7ff, 0 2px 6px rgba(0, 87, 255, 0.22);
cursor: pointer;
}
&::-moz-range-thumb {
width: 15px;
height: 15px;
border: 2px solid #ffffff;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 1px #9ab7ff, 0 2px 6px rgba(0, 87, 255, 0.22);
cursor: pointer;
}
}
}
.word-cloud-chart {
width: 100%;
height: 400px;
cursor: pointer;
}
@@ -3,9 +3,11 @@ 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 } from '../../api';
import { WorksService } from '../../api';
import { TopicCount, TopicsByYear, WorksService } from '../../api';
import {
ResearchTimelineComponent,
TimelineViewMode,
@@ -18,7 +20,7 @@ import {
@Component({
selector: 'app-person-overview',
standalone: true,
imports: [CommonModule, ResearchTimelineComponent],
imports: [CommonModule, ResearchTimelineComponent, NgxEchartsDirective],
templateUrl: './person-overview.component.html',
styleUrl: './person-overview.component.scss',
})
@@ -40,6 +42,28 @@ export class PersonOverviewComponent implements OnInit {
timelineStartYear: number | undefined;
timelineEndYear: number | undefined;
wordCloudOptions: EChartsOption | null = null;
topN = 30;
sliderMax = 50;
get sliderPercent(): string {
if (this.sliderMax <= 5) return '100%';
return `${(((this.topN - 5) / (this.sliderMax - 5)) * 100).toFixed(1)}%`;
}
onTopNChange(event: Event): void {
this.topN = Number((event.target as HTMLInputElement).value);
this.rebuildWordCloud();
}
private allTopicData: Array<{
name: string;
value: number;
topicId: string | undefined;
textStyle: { color: string };
}> = [];
ngOnInit(): void {
combineLatest(this.route.pathFromRoot.map((route) => route.paramMap))
.pipe(
@@ -49,6 +73,7 @@ export class PersonOverviewComponent implements OnInit {
)
.subscribe((authorId) => {
this.loadTopicTimeline(authorId);
this.loadWordCloud(authorId);
});
this.route.queryParamMap
@@ -120,6 +145,21 @@ export class PersonOverviewComponent implements OnInit {
});
}
// 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;
void this.router.navigate(['../publications'], {
relativeTo: this.route,
queryParams: {
publicationPage: 1,
publicationTopicId: topicId,
publicationTopicName: topicName,
},
});
}
private findAuthorId(paramMaps: readonly ParamMap[]): string {
return (
paramMaps
@@ -159,6 +199,92 @@ export class PersonOverviewComponent implements OnInit {
});
}
private readonly blueShades = [
'#0057ff', '#1a6fff', '#2952d9', '#3d7cff',
'#1240cc', '#5a90ff', '#0044cc', '#4d85ff',
'#0b4fe0', '#2563eb',
];
private topicColor(name: string): string {
const hash = name.split('').reduce((acc, c) => acc + c.charCodeAt(0), 0);
return this.blueShades[hash % this.blueShades.length];
}
private loadWordCloud(authorId: string): void {
if (!authorId || authorId === '0') {
this.wordCloudOptions = null;
this.allTopicData = [];
return;
}
this.worksService
.getAuthorWorks(authorId, 1, 100)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (page) => {
const counts = new Map<string, number>();
const nameToId = new Map<string, string>();
page.elements?.forEach(work => {
work.topics?.forEach(topic => {
if (topic.display_name && topic.id) {
counts.set(topic.display_name, (counts.get(topic.display_name) ?? 0) + 1);
if (!nameToId.has(topic.display_name)) {
nameToId.set(topic.display_name, topic.id);
}
}
});
});
this.allTopicData = Array.from(counts.entries())
.sort((a, b) => b[1] - a[1])
.map(([name, value]) => ({
name,
value,
topicId: nameToId.get(name),
textStyle: { color: this.topicColor(name) },
}));
if (this.allTopicData.length === 0) return;
this.sliderMax = Math.min(50, this.allTopicData.length);
this.topN = Math.min(30, this.sliderMax);
setTimeout(() => { this.rebuildWordCloud(); });
},
error: (error) => {
console.error('Word cloud could not be loaded.', error);
},
});
}
private rebuildWordCloud(): void {
const data = this.allTopicData.slice(0, this.topN);
if (data.length === 0) return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.wordCloudOptions = {
series: [{
type: 'wordCloud',
sizeRange: [12, 32],
rotationRange: [0, 0],
rotationStep: 0,
gridSize: 4,
width: '100%',
height: '100%',
drawOutOfBound: false,
textStyle: { fontFamily: 'Open Sans, sans-serif', fontWeight: 'bold' },
emphasis: {
textStyle: {
shadowBlur: 14,
shadowColor: 'rgba(0, 87, 255, 0.45)',
color: '#0044cc',
},
},
data,
}],
} as any;
}
private mapTimelineElements(
elements: TopicsByYear[] | undefined,
): TopicTimelineElement[] {