diff --git a/webapp/.npmrc b/webapp/.npmrc
new file mode 100644
index 00000000..521a9f7c
--- /dev/null
+++ b/webapp/.npmrc
@@ -0,0 +1 @@
+legacy-peer-deps=true
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 47b67e94..90e8d07d 100644
--- a/webapp/src/app/modules/person-overview/person-overview.component.html
+++ b/webapp/src/app/modules/person-overview/person-overview.component.html
@@ -12,11 +12,11 @@
(yearSelect)="onTimelineYearSelect($event)"
>
- @if (wordCloudOptions) {
+ @if (!loadingWordCloud) {
}
diff --git a/webapp/src/app/modules/person-overview/person-overview.component.scss b/webapp/src/app/modules/person-overview/person-overview.component.scss
index 025d1732..ab1f1a88 100644
--- a/webapp/src/app/modules/person-overview/person-overview.component.scss
+++ b/webapp/src/app/modules/person-overview/person-overview.component.scss
@@ -115,4 +115,11 @@
width: 100%;
height: 400px;
cursor: pointer;
+}
+
+.word-cloud-empty {
+ margin: 2rem 0 0.5rem;
+ text-align: center;
+ color: var(--sg-text-muted);
+ font-size: 14px;
}
\ 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 8bdc5ae7..c1af43af 100644
--- a/webapp/src/app/modules/person-overview/person-overview.component.ts
+++ b/webapp/src/app/modules/person-overview/person-overview.component.ts
@@ -43,6 +43,8 @@ export class PersonOverviewComponent implements OnInit {
timelineEndYear: number | undefined;
wordCloudOptions: EChartsOption | null = null;
+ loadingWordCloud = false;
+ wordCloudEmpty = false;
topN = 30;
sliderMax = 50;
@@ -61,7 +63,8 @@ export class PersonOverviewComponent implements OnInit {
name: string;
value: number;
topicId: string | undefined;
- textStyle: { color: string };
+ textStyle: { color: string; fontSize: number };
+ emphasis: { textStyle: { fontSize: number; color: string; shadowBlur: number; shadowColor: string } };
}> = [];
ngOnInit(): void {
@@ -213,10 +216,16 @@ export class PersonOverviewComponent implements OnInit {
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))
@@ -236,16 +245,40 @@ export class PersonOverviewComponent implements OnInit {
});
});
+ 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]) => ({
- name,
- value,
- topicId: nameToId.get(name),
- textStyle: { color: this.topicColor(name) },
- }));
+ .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)',
+ },
+ },
+ };
+ });
- if (this.allTopicData.length === 0) return;
+ 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);
@@ -254,6 +287,8 @@ export class PersonOverviewComponent implements OnInit {
},
error: (error) => {
console.error('Word cloud could not be loaded.', error);
+ this.loadingWordCloud = false;
+ this.wordCloudEmpty = true;
},
});
}
@@ -265,7 +300,6 @@ export class PersonOverviewComponent implements OnInit {
this.wordCloudOptions = {
series: [{
type: 'wordCloud',
- sizeRange: [12, 32],
rotationRange: [0, 0],
rotationStep: 0,
gridSize: 4,
@@ -273,13 +307,6 @@ export class PersonOverviewComponent implements OnInit {
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;