fix(wordcloud): remove duplicate code after rebase
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-06-08 22:55:43 +02:00
parent 4a909ab166
commit fc03a69ad3
2 changed files with 0 additions and 150 deletions
@@ -49,38 +49,4 @@
}
</div>
}
@if (!loadingWordCloud) {
<div class="word-cloud-card">
<div class="word-cloud-header">
<h3 class="word-cloud-title">Forschungsthemen</h3>
@if (wordCloudOptions && 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>
@if (wordCloudOptions) {
<div
echarts
[options]="wordCloudOptions"
(chartClick)="onWordClick($event)"
class="word-cloud-chart"
></div>
} @else if (wordCloudEmpty) {
<p class="word-cloud-empty">Keine Forschungsthemen gefunden.</p>
}
</div>
}
</section>
@@ -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<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);
}
}
});
});
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;