From 8ee9aa00bf2870afd4f0de5d7e4f60e33215f566 Mon Sep 17 00:00:00 2001 From: "noemi.kallweit" Date: Thu, 25 Jun 2026 18:04:24 +0200 Subject: [PATCH] feat(wordcloud): apply new color scheme to wordcloud --- .../person-overview.component.ts | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) 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 f77b728f..244843b5 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -5,6 +5,7 @@ import { ActivatedRoute, ParamMap, Router } from '@angular/router'; import { combineLatest, distinctUntilChanged, map } from 'rxjs'; import { TopicCount, TopicsByYear, WorksService } from '../../api'; +import { topicHierarchyColor } from '../../shared/utils/topic-colors'; import { ResearchTimelineComponent, TimelineViewMode, @@ -70,6 +71,10 @@ export class PersonOverviewComponent implements OnInit { name: string; topicId: string; year: number | undefined; + fieldId: string | undefined; + fieldName: string | undefined; + domainId: string | undefined; + domainName: string | undefined; }> = []; ngOnInit(): void { @@ -334,14 +339,6 @@ 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.wordCloudWords = []; @@ -369,6 +366,10 @@ 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, }); } }); @@ -396,6 +397,10 @@ export class PersonOverviewComponent implements OnInit { const end = this.timelineEndYear; const counts = new Map(); const nameToId = new Map(); + const nameToColorInput = new Map< + string, + Parameters[0] + >(); for (const occ of this.rawTopicOccurrences) { if (start !== undefined && (occ.year === undefined || occ.year < start)) @@ -403,7 +408,17 @@ 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, + }); + } } if (counts.size === 0) { @@ -422,13 +437,13 @@ export class PersonOverviewComponent implements OnInit { const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]); - const words = sorted.slice(0, 30).map(([name, value], i): WordCloudWord => { + const words = sorted.slice(0, 30).map(([name, value]): WordCloudWord => { const t = intensity(value); return { name, value, topicId: nameToId.get(name), - color: this.timelineColors[i % this.timelineColors.length], + color: topicHierarchyColor(nameToColorInput.get(name)), fontSize: Math.round(12 + t * (32 - 12)), fontWeight: t > 0.66 ? 800 : t > 0.33 ? 600 : 400, };