feat(wordcloud): change hover effect for topics
This commit is contained in:
@@ -0,0 +1 @@
|
||||
legacy-peer-deps=true
|
||||
@@ -12,11 +12,11 @@
|
||||
(yearSelect)="onTimelineYearSelect($event)"
|
||||
></app-research-timeline>
|
||||
|
||||
@if (wordCloudOptions) {
|
||||
@if (!loadingWordCloud) {
|
||||
<div class="word-cloud-card">
|
||||
<div class="word-cloud-header">
|
||||
<h3 class="word-cloud-title">Forschungsthemen</h3>
|
||||
@if (sliderMax > 5) {
|
||||
@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">
|
||||
@@ -33,12 +33,16 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div
|
||||
echarts
|
||||
[options]="wordCloudOptions"
|
||||
(chartClick)="onWordClick($event)"
|
||||
class="word-cloud-chart"
|
||||
></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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user