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 0bde8ea9..e5b2489c 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.html +++ b/webapp/src/app/modules/person-overview/person-overview.component.html @@ -49,38 +49,4 @@ } } - - @if (!loadingWordCloud) { -
-
-

Forschungsthemen

- @if (wordCloudOptions && sliderMax > 5) { -
- {{ topN }} Themen -
-
- -
-
- } -
- @if (wordCloudOptions) { -
- } @else if (wordCloudEmpty) { -

Keine Forschungsthemen gefunden.

- } -
- } \ No newline at end of file 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 ddf0aa4a..48a20769 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -75,31 +75,6 @@ export class PersonOverviewComponent implements OnInit { emphasis: { textStyle: { fontSize: number; color: string; shadowBlur: number; shadowColor: string } }; }> = []; - wordCloudOptions: EChartsOption | null = null; - loadingWordCloud = false; - wordCloudEmpty = false; - - 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; fontSize: number }; - emphasis: { textStyle: { fontSize: number; color: string; shadowBlur: number; shadowColor: string } }; - }> = []; - ngOnInit(): void { combineLatest(this.route.pathFromRoot.map((route) => route.paramMap)) .pipe( @@ -414,97 +389,6 @@ 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.wordCloudEmpty = false; - this.loadingWordCloud = false; - this.allTopicData = []; - return; - } - - this.loadingWordCloud = true; - this.wordCloudEmpty = false; - this.wordCloudOptions = null; - - this.worksService - .getAuthorWorks(authorId, 1, 100) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe({ - next: (page) => { - const counts = new Map(); - const nameToId = new Map(); - - 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); - } - } - }); - }); - - 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)); - - this.allTopicData = Array.from(counts.entries()) - .sort((a, b) => b[1] - a[1]) - .map(([name, value]) => { - const fontSize = computeSize(value); - return { - name, - value, - topicId: nameToId.get(name), - textStyle: { color: this.topicColor(name), fontSize }, - emphasis: { - textStyle: { - fontSize: Math.round(fontSize * 1.1), - color: '#101a3d', - shadowBlur: 16, - shadowColor: 'rgba(0, 87, 255, 0.35)', - }, - }, - }; - }); - - this.loadingWordCloud = false; - - if (this.allTopicData.length === 0) { - this.wordCloudEmpty = true; - 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); - this.loadingWordCloud = false; - this.wordCloudEmpty = true; - }, - }); - } - private rebuildWordCloud(): void { const data = this.allTopicData.slice(0, this.topN); if (data.length === 0) return;