Merge remote-tracking branch 'origin/dev' into topic-colored-chips
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
+7
-5
@@ -21,6 +21,7 @@ import {
|
||||
getTopicLegendSubfieldId,
|
||||
TopicLegendGroup,
|
||||
TopicLegendSubfieldSelection,
|
||||
TopicLegendTopic,
|
||||
toggleTopicLegendFieldSelection,
|
||||
toggleTopicLegendSubfieldSelection,
|
||||
} from '../../../../shared/utils/topic-legend';
|
||||
@@ -114,6 +115,7 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
@Input() endYear: number | undefined;
|
||||
@Input() subfieldLegendVisible = true;
|
||||
@Input() subfieldLegendExpanded = false;
|
||||
@Input() wordCloudLegendTopics: TopicLegendTopic[] = [];
|
||||
|
||||
@Output() viewModeChange = new EventEmitter<TimelineViewMode>();
|
||||
@Output() yearRangeChange = new EventEmitter<TimelineYearRange>();
|
||||
@@ -609,14 +611,14 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
}
|
||||
|
||||
private get allSubfieldLegendGroups(): TopicLegendGroup[] {
|
||||
if (
|
||||
this.loading ||
|
||||
this.loadFailed ||
|
||||
this.timelineViewMode === 'wordcloud'
|
||||
) {
|
||||
if (this.loading || this.loadFailed) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (this.timelineViewMode === 'wordcloud') {
|
||||
return buildTopicLegendGroups(this.wordCloudLegendTopics);
|
||||
}
|
||||
|
||||
return buildTopicLegendGroups(this.visibleLegendTopics);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
[endYear]="timelineEndYear"
|
||||
[subfieldLegendVisible]="timelineLegendVisible"
|
||||
[subfieldLegendExpanded]="timelineLegendExpanded"
|
||||
[wordCloudLegendTopics]="wordCloudLegendTopics"
|
||||
(viewModeChange)="onTimelineViewModeChange($event)"
|
||||
(yearRangeChange)="onTimelineYearRangeChange($event)"
|
||||
(subfieldLegendVisibleChange)="onTimelineLegendVisibleChange($event)"
|
||||
@@ -31,7 +32,9 @@
|
||||
[style.fontSize.px]="word.fontSize"
|
||||
[style.fontWeight]="word.fontWeight"
|
||||
[disabled]="!word.topicId"
|
||||
[title]="word.name + ' (' + word.value + ')'"
|
||||
[matTooltip]="word.tooltip"
|
||||
[matTooltipDisabled]="!word.tooltip"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
(click)="onWordClick(word)">
|
||||
{{ word.name }}
|
||||
</button>
|
||||
|
||||
@@ -2,10 +2,13 @@ import { CommonModule } from '@angular/common';
|
||||
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { combineLatest, distinctUntilChanged, map } from 'rxjs';
|
||||
|
||||
import { TopicCount, TopicsByYear, WorksService } from '../../api';
|
||||
import { topicHierarchyColor } from '../../shared/utils/topic-colors';
|
||||
import { TopicLegendTopic } from '../../shared/utils/topic-legend';
|
||||
import { buildTopicHierarchyTooltip } from '../../shared/utils/topic-tooltip';
|
||||
import {
|
||||
ResearchTimelineComponent,
|
||||
TimelineViewMode,
|
||||
@@ -22,12 +25,13 @@ export interface WordCloudWord {
|
||||
color: string;
|
||||
fontSize: number;
|
||||
fontWeight: number;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-person-overview',
|
||||
standalone: true,
|
||||
imports: [CommonModule, ResearchTimelineComponent],
|
||||
imports: [CommonModule, ResearchTimelineComponent, MatTooltipModule],
|
||||
templateUrl: './person-overview.component.html',
|
||||
styleUrl: './person-overview.component.scss',
|
||||
})
|
||||
@@ -64,6 +68,7 @@ export class PersonOverviewComponent implements OnInit {
|
||||
timelineLegendExpanded = false;
|
||||
|
||||
wordCloudWords: WordCloudWord[] = [];
|
||||
wordCloudLegendTopics: TopicLegendTopic[] = [];
|
||||
loadingWordCloud = false;
|
||||
wordCloudEmpty = false;
|
||||
|
||||
@@ -75,6 +80,8 @@ export class PersonOverviewComponent implements OnInit {
|
||||
fieldName: string | undefined;
|
||||
domainId: string | undefined;
|
||||
domainName: string | undefined;
|
||||
subfieldId: string | undefined;
|
||||
subfieldName: string | undefined;
|
||||
}> = [];
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -342,6 +349,7 @@ export class PersonOverviewComponent implements OnInit {
|
||||
private loadWordCloud(authorId: string): void {
|
||||
if (!authorId || authorId === '0') {
|
||||
this.wordCloudWords = [];
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = false;
|
||||
this.loadingWordCloud = false;
|
||||
this.rawTopicOccurrences = [];
|
||||
@@ -351,6 +359,7 @@ export class PersonOverviewComponent implements OnInit {
|
||||
this.loadingWordCloud = true;
|
||||
this.wordCloudEmpty = false;
|
||||
this.wordCloudWords = [];
|
||||
this.wordCloudLegendTopics = [];
|
||||
|
||||
this.worksService
|
||||
.getAuthorWorks(authorId, 1, 100)
|
||||
@@ -370,6 +379,8 @@ export class PersonOverviewComponent implements OnInit {
|
||||
fieldName: topic.field?.display_name ?? undefined,
|
||||
domainId: topic.domain?.id ?? undefined,
|
||||
domainName: topic.domain?.display_name ?? undefined,
|
||||
subfieldId: topic.subfield?.id ?? undefined,
|
||||
subfieldName: topic.subfield?.display_name ?? undefined,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -378,6 +389,7 @@ export class PersonOverviewComponent implements OnInit {
|
||||
this.loadingWordCloud = false;
|
||||
|
||||
if (this.rawTopicOccurrences.length === 0) {
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = true;
|
||||
return;
|
||||
}
|
||||
@@ -387,6 +399,7 @@ export class PersonOverviewComponent implements OnInit {
|
||||
error: (error) => {
|
||||
console.error('Word cloud could not be loaded.', error);
|
||||
this.loadingWordCloud = false;
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = true;
|
||||
},
|
||||
});
|
||||
@@ -397,10 +410,7 @@ export class PersonOverviewComponent implements OnInit {
|
||||
const end = this.timelineEndYear;
|
||||
const counts = new Map<string, number>();
|
||||
const nameToId = new Map<string, string>();
|
||||
const nameToColorInput = new Map<
|
||||
string,
|
||||
Parameters<typeof topicHierarchyColor>[0]
|
||||
>();
|
||||
const nameToColorInput = new Map<string, TopicLegendTopic>();
|
||||
|
||||
for (const occ of this.rawTopicOccurrences) {
|
||||
if (start !== undefined && (occ.year === undefined || occ.year < start))
|
||||
@@ -417,12 +427,15 @@ export class PersonOverviewComponent implements OnInit {
|
||||
field_name: occ.fieldName,
|
||||
domain_id: occ.domainId,
|
||||
domain_name: occ.domainName,
|
||||
subfield_id: occ.subfieldId,
|
||||
subfield_name: occ.subfieldName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (counts.size === 0) {
|
||||
this.wordCloudWords = [];
|
||||
this.wordCloudLegendTopics = [];
|
||||
this.wordCloudEmpty = true;
|
||||
return;
|
||||
}
|
||||
@@ -436,16 +449,28 @@ export class PersonOverviewComponent implements OnInit {
|
||||
maxVal === minVal ? 1 : (v - minVal) / (maxVal - minVal);
|
||||
|
||||
const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]);
|
||||
const topNames = sorted.slice(0, 30).map(([name]) => name);
|
||||
|
||||
this.wordCloudLegendTopics = topNames
|
||||
.map((name) => nameToColorInput.get(name))
|
||||
.filter((topic): topic is TopicLegendTopic => Boolean(topic));
|
||||
|
||||
const words = sorted.slice(0, 30).map(([name, value]): WordCloudWord => {
|
||||
const t = intensity(value);
|
||||
const colorInput = nameToColorInput.get(name);
|
||||
return {
|
||||
name,
|
||||
value,
|
||||
topicId: nameToId.get(name),
|
||||
color: topicHierarchyColor(nameToColorInput.get(name)),
|
||||
color: topicHierarchyColor(colorInput),
|
||||
fontSize: Math.round(12 + t * (32 - 12)),
|
||||
fontWeight: t > 0.66 ? 800 : t > 0.33 ? 600 : 400,
|
||||
tooltip: buildTopicHierarchyTooltip({
|
||||
topicName: name,
|
||||
subfieldName: colorInput?.subfield_name,
|
||||
fieldName: colorInput?.field_name,
|
||||
domainName: colorInput?.domain_name,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user