Add compact research timeline view
LocationBasedServices/smartguide/pipeline/pr-dev There was a failure building this commit
LocationBasedServices/smartguide/pipeline/pr-dev There was a failure building this commit
This commit is contained in:
+198
-101
@@ -8,69 +8,75 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="timeline-header-actions">
|
||||
<div *ngIf="hasYearRange" class="year-filter" aria-label="Zeitraum eingrenzen">
|
||||
<div class="year-filter-top">
|
||||
<span class="year-filter-label">Zeitraum</span>
|
||||
<div class="view-toggle" aria-label="Ansicht wechseln">
|
||||
<button
|
||||
type="button"
|
||||
[class.active]="timelineViewMode === 'years'"
|
||||
(click)="setTimelineViewMode('years')"
|
||||
>
|
||||
Jahre
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="reset-range-button"
|
||||
[disabled]="!canResetYearRange"
|
||||
(click)="resetYearRange()"
|
||||
>
|
||||
Zurücksetzen
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
[class.active]="timelineViewMode === 'compact'"
|
||||
(click)="setTimelineViewMode('compact')"
|
||||
>
|
||||
Kompakt
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="year-filter-values">
|
||||
<span>{{ selectedStartYear }}</span>
|
||||
<span>bis</span>
|
||||
<span>{{ selectedEndYear }}</span>
|
||||
</div>
|
||||
<div *ngIf="hasYearRange" class="year-filter" aria-label="Zeitraum eingrenzen">
|
||||
<div class="year-filter-top">
|
||||
<span class="year-filter-label">Zeitraum</span>
|
||||
|
||||
<div
|
||||
class="year-range-slider"
|
||||
[style.--range-start]="rangeStartPercent"
|
||||
[style.--range-end]="rangeEndPercent"
|
||||
<button
|
||||
type="button"
|
||||
class="reset-range-button"
|
||||
[disabled]="!canResetYearRange"
|
||||
(click)="resetYearRange()"
|
||||
>
|
||||
<div class="range-track"></div>
|
||||
|
||||
<input
|
||||
class="range-input range-input-start"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedStartYear"
|
||||
(input)="onStartYearInput($event)"
|
||||
aria-label="Startjahr"
|
||||
/>
|
||||
|
||||
<input
|
||||
class="range-input range-input-end"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedEndYear"
|
||||
(input)="onEndYearInput($event)"
|
||||
aria-label="Endjahr"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="year-filter-bounds">
|
||||
<span>{{ minYear }}</span>
|
||||
<span>{{ maxYear }}</span>
|
||||
</div>
|
||||
Zurücksetzen
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="view-toggle" aria-label="Ansicht wechseln">
|
||||
<button type="button" class="active">
|
||||
Zeitliste
|
||||
</button>
|
||||
<div class="year-filter-values">
|
||||
<span>{{ selectedStartYear }}</span>
|
||||
<span>bis</span>
|
||||
<span>{{ selectedEndYear }}</span>
|
||||
</div>
|
||||
|
||||
<button type="button" class="inactive-button" aria-disabled="true">
|
||||
Schlagwörter
|
||||
</button>
|
||||
<div
|
||||
class="year-range-slider"
|
||||
[style.--range-start]="rangeStartPercent"
|
||||
[style.--range-end]="rangeEndPercent"
|
||||
>
|
||||
<div class="range-track"></div>
|
||||
|
||||
<input
|
||||
class="range-input range-input-start"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedStartYear"
|
||||
(input)="onStartYearInput($event)"
|
||||
aria-label="Startjahr"
|
||||
/>
|
||||
|
||||
<input
|
||||
class="range-input range-input-end"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedEndYear"
|
||||
(input)="onEndYearInput($event)"
|
||||
aria-label="Endjahr"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="year-filter-bounds">
|
||||
<span>{{ minYear }}</span>
|
||||
<span>{{ maxYear }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,55 +91,146 @@
|
||||
|
||||
<ng-container *ngIf="!loading && !loadFailed">
|
||||
<ng-container *ngIf="timelineItems.length > 0; else emptyTimeline">
|
||||
<div class="timeline-wrapper">
|
||||
<div class="timeline-inner" [style.min-width.px]="timelineMinWidth">
|
||||
<div class="timeline-axis" aria-hidden="true"></div>
|
||||
<ng-container *ngIf="timelineViewMode === 'years'; else compactTimeline">
|
||||
<div class="timeline-wrapper">
|
||||
<div class="timeline-inner" [style.min-width.px]="timelineMinWidth">
|
||||
<div class="timeline-axis" aria-hidden="true"></div>
|
||||
|
||||
<div class="timeline-points" [style.grid-template-columns]="gridTemplateColumns">
|
||||
<div
|
||||
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
|
||||
class="timeline-point"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<span class="year">{{ item.year }}</span>
|
||||
<span class="dot"></span>
|
||||
<div class="timeline-points" [style.grid-template-columns]="gridTemplateColumns">
|
||||
<div
|
||||
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
|
||||
class="timeline-point"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<span class="year">{{ item.year }}</span>
|
||||
<span class="dot"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="timeline-content" [style.grid-template-columns]="gridTemplateColumns">
|
||||
<article
|
||||
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
|
||||
class="timeline-item"
|
||||
>
|
||||
<h3>{{ getMainTopic(item) }}</h3>
|
||||
|
||||
<span class="publication-count">
|
||||
{{ item.publication_count }}
|
||||
{{ item.publication_count === 1 ? 'Publikation' : 'Publikationen' }}
|
||||
</span>
|
||||
|
||||
<div class="topic-list">
|
||||
<ng-container *ngIf="getDisplayedTopics(item).length > 0; else noTopicsForYear">
|
||||
<span
|
||||
*ngFor="let topic of getDisplayedTopics(item); trackBy: trackByTopic"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
<span class="topic-count">{{ topic.count }}</span>
|
||||
</span>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noTopicsForYear>
|
||||
<span class="no-topics">
|
||||
Keine weiteren Topics
|
||||
</span>
|
||||
</ng-template>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="timeline-content" [style.grid-template-columns]="gridTemplateColumns">
|
||||
<article
|
||||
*ngFor="let item of timelineItems; let index = index; trackBy: trackByYear"
|
||||
class="timeline-item"
|
||||
>
|
||||
<h3>{{ getMainTopic(item) }}</h3>
|
||||
|
||||
<span class="publication-count">
|
||||
{{ item.publication_count }}
|
||||
{{ item.publication_count === 1 ? 'Publikation' : 'Publikationen' }}
|
||||
</span>
|
||||
|
||||
<div class="topic-list">
|
||||
<ng-container *ngIf="getDisplayedTopics(item).length > 0; else noTopicsForYear">
|
||||
<span
|
||||
*ngFor="let topic of getDisplayedTopics(item); trackBy: trackByTopic"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
<span class="topic-count">{{ topic.count }}</span>
|
||||
</span>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noTopicsForYear>
|
||||
<span class="no-topics">
|
||||
Keine weiteren Topics
|
||||
</span>
|
||||
</ng-template>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #compactTimeline>
|
||||
<div class="compact-phase-list">
|
||||
<article
|
||||
*ngFor="let phase of compactPhases; let index = index; trackBy: trackByPhase"
|
||||
class="phase-card"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<div class="phase-card-header">
|
||||
<span class="phase-marker"></span>
|
||||
|
||||
<div class="phase-title-block">
|
||||
<span class="phase-years">{{ getPhaseYearLabel(phase) }}</span>
|
||||
<h3>{{ phase.primaryTopicName }}</h3>
|
||||
<span class="phase-publications">
|
||||
{{ phase.publication_count }}
|
||||
{{ phase.publication_count === 1 ? 'Publikation' : 'Publikationen' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="phase-topics">
|
||||
<ng-container *ngIf="phase.topics.length > 0; else noPhaseTopics">
|
||||
<span
|
||||
*ngFor="let topic of phase.topics; trackBy: trackByTopic"
|
||||
class="topic-chip"
|
||||
[ngClass]="getColorClass(index)"
|
||||
>
|
||||
<span class="topic-name">{{ topic.name }}</span>
|
||||
<span class="topic-count">{{ topic.count }}</span>
|
||||
</span>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noPhaseTopics>
|
||||
<span class="no-topics">
|
||||
Keine weiteren Topics
|
||||
</span>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="phase-toggle"
|
||||
[attr.aria-expanded]="isPhaseExpanded(phase)"
|
||||
(click)="togglePhase(phase)"
|
||||
>
|
||||
{{ isPhaseExpanded(phase) ? 'Details ausblenden' : 'Details anzeigen' }}
|
||||
</button>
|
||||
|
||||
<div *ngIf="isPhaseExpanded(phase)" class="phase-year-details">
|
||||
<div *ngFor="let year of phase.years; trackBy: trackByYear" class="phase-year-row">
|
||||
<div class="phase-year-meta">
|
||||
<strong>{{ year.year }}</strong>
|
||||
<span>
|
||||
{{ year.publication_count }}
|
||||
{{ year.publication_count === 1 ? 'Publikation' : 'Publikationen' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="phase-year-topics">
|
||||
<ng-container
|
||||
*ngIf="
|
||||
getDisplayedTopicsForPrimaryTopic(year, phase.primaryTopicName).length > 0;
|
||||
else noPhaseYearTopics
|
||||
"
|
||||
>
|
||||
<span
|
||||
*ngFor="
|
||||
let topic of getDisplayedTopicsForPrimaryTopic(year, phase.primaryTopicName);
|
||||
trackBy: trackByTopic
|
||||
"
|
||||
class="mini-topic-chip"
|
||||
>
|
||||
<span>{{ topic.name }}</span>
|
||||
<strong>{{ topic.count }}</strong>
|
||||
</span>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noPhaseYearTopics>
|
||||
<span class="no-topics">
|
||||
Keine weiteren Topics
|
||||
</span>
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<div class="timeline-note">
|
||||
<span class="note-dot"></span>
|
||||
|
||||
+205
-40
@@ -9,15 +9,15 @@
|
||||
}
|
||||
|
||||
.timeline-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
|
||||
align-items: flex-start;
|
||||
gap: 24px;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.timeline-title {
|
||||
min-width: 260px;
|
||||
min-width: 0;
|
||||
|
||||
h2 {
|
||||
margin: 0 0 6px;
|
||||
@@ -39,17 +39,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.timeline-header-actions {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-end;
|
||||
gap: 14px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.year-filter {
|
||||
width: min(250px, 100%);
|
||||
padding: 1px 10px;
|
||||
justify-self: end;
|
||||
width: min(285px, 100%);
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #dbe5f6;
|
||||
border-radius: 10px;
|
||||
background: #fbfdff;
|
||||
@@ -198,9 +191,9 @@
|
||||
}
|
||||
|
||||
.view-toggle {
|
||||
justify-self: center;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
flex: 0 0 auto;
|
||||
padding: 4px;
|
||||
border: 1px solid #dbe5f6;
|
||||
border-radius: 10px;
|
||||
@@ -209,7 +202,7 @@
|
||||
button {
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 9px 16px;
|
||||
padding: 9px 18px;
|
||||
background: transparent;
|
||||
color: #3f4b66;
|
||||
font-size: 14px;
|
||||
@@ -225,14 +218,6 @@
|
||||
color: #0057ff;
|
||||
box-shadow: inset 0 0 0 1px #3d7cff;
|
||||
}
|
||||
|
||||
&.inactive-button {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
&.inactive-button:hover {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,36 +362,206 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.compact-phase-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.phase-card {
|
||||
flex: 0 1 calc((100% - 28px) / 3);
|
||||
max-width: 520px;
|
||||
min-width: 300px;
|
||||
box-sizing: border-box;
|
||||
padding: 15px 16px;
|
||||
border: 1px solid #dbe5f6;
|
||||
border-left-width: 4px;
|
||||
border-radius: 14px;
|
||||
background: #fbfdff;
|
||||
}
|
||||
|
||||
.phase-card-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.phase-marker {
|
||||
flex: 0 0 auto;
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
margin-top: 5px;
|
||||
border: 3px solid #ffffff;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
|
||||
}
|
||||
|
||||
.phase-title-block {
|
||||
min-width: 0;
|
||||
|
||||
h3 {
|
||||
margin: 3px 0 4px;
|
||||
color: #07163d;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
}
|
||||
}
|
||||
|
||||
.phase-years {
|
||||
display: inline-flex;
|
||||
width: fit-content;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: #eef4ff;
|
||||
color: #0057ff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.phase-publications {
|
||||
color: #68748f;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.phase-topics {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 7px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.phase-toggle {
|
||||
margin-top: 13px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #0057ff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.phase-year-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 13px;
|
||||
padding-top: 4px;
|
||||
border-top: 1px solid #dbe5f6;
|
||||
}
|
||||
|
||||
.phase-year-row {
|
||||
display: grid;
|
||||
grid-template-columns: 72px 1fr;
|
||||
gap: 10px;
|
||||
align-items: start;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.phase-year-row + .phase-year-row {
|
||||
border-top: 1px solid #e4ebf7;
|
||||
}
|
||||
|
||||
.phase-year-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
|
||||
strong {
|
||||
color: #07163d;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: #68748f;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.phase-year-topics {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.mini-topic-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
max-width: 100%;
|
||||
padding: 4px 7px;
|
||||
border-radius: 7px;
|
||||
background: #f2f6ff;
|
||||
color: #40506f;
|
||||
font-size: 11px;
|
||||
line-height: 1.25;
|
||||
|
||||
span {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #0057ff;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.purple {
|
||||
.dot {
|
||||
.dot,
|
||||
.phase-marker {
|
||||
background: #7255d9;
|
||||
}
|
||||
}
|
||||
|
||||
.blue {
|
||||
.dot {
|
||||
.dot,
|
||||
.phase-marker {
|
||||
background: #2678e8;
|
||||
}
|
||||
}
|
||||
|
||||
.green {
|
||||
.dot {
|
||||
.dot,
|
||||
.phase-marker {
|
||||
background: #39a96b;
|
||||
}
|
||||
}
|
||||
|
||||
.orange {
|
||||
.dot {
|
||||
.dot,
|
||||
.phase-marker {
|
||||
background: #f59e0b;
|
||||
}
|
||||
}
|
||||
|
||||
.pink {
|
||||
.dot {
|
||||
.dot,
|
||||
.phase-marker {
|
||||
background: #e0527c;
|
||||
}
|
||||
}
|
||||
|
||||
.phase-card.purple {
|
||||
border-left-color: #7255d9;
|
||||
}
|
||||
|
||||
.phase-card.blue {
|
||||
border-left-color: #2678e8;
|
||||
}
|
||||
|
||||
.phase-card.green {
|
||||
border-left-color: #39a96b;
|
||||
}
|
||||
|
||||
.phase-card.orange {
|
||||
border-left-color: #f59e0b;
|
||||
}
|
||||
|
||||
.phase-card.pink {
|
||||
border-left-color: #e0527c;
|
||||
}
|
||||
|
||||
.topic-chip.purple {
|
||||
border: 1px solid #d8cafe;
|
||||
background: #f6f0ff;
|
||||
@@ -471,14 +626,23 @@
|
||||
color: #b42318;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
@media (max-width: 1100px) {
|
||||
.timeline-header {
|
||||
flex-direction: column;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.timeline-header-actions {
|
||||
.view-toggle {
|
||||
justify-self: start;
|
||||
}
|
||||
|
||||
.year-filter {
|
||||
justify-self: stretch;
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.phase-card {
|
||||
flex-basis: calc((100% - 14px) / 2);
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,14 +651,6 @@
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.timeline-header-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.year-filter {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.view-toggle {
|
||||
width: 100%;
|
||||
|
||||
@@ -502,4 +658,13 @@
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.phase-card {
|
||||
flex-basis: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.phase-year-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
+179
@@ -13,6 +13,26 @@ export interface TopicTimelineElement {
|
||||
primary_topics?: TopicTimelineTopic[];
|
||||
}
|
||||
|
||||
type TimelineViewMode = 'years' | 'compact';
|
||||
|
||||
interface ResearchTimelinePhase {
|
||||
id: string;
|
||||
startYear: number;
|
||||
endYear: number;
|
||||
publication_count: number;
|
||||
primaryTopicName: string;
|
||||
years: TopicTimelineElement[];
|
||||
topics: TopicTimelineTopic[];
|
||||
}
|
||||
|
||||
interface WorkingResearchTimelinePhase {
|
||||
startYear: number;
|
||||
endYear: number;
|
||||
publication_count: number;
|
||||
primaryTopicName: string;
|
||||
years: TopicTimelineElement[];
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-research-timeline',
|
||||
standalone: true,
|
||||
@@ -25,6 +45,8 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
@Input() loading = false;
|
||||
@Input() loadFailed = false;
|
||||
|
||||
timelineViewMode: TimelineViewMode = 'years';
|
||||
|
||||
minYear = 0;
|
||||
maxYear = 0;
|
||||
selectedStartYear = 0;
|
||||
@@ -33,6 +55,8 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
private readonly colors = ['purple', 'blue', 'green', 'orange', 'pink'];
|
||||
private readonly columnWidth = 240;
|
||||
private readonly displayedTopicLimit = 3;
|
||||
private readonly displayedPhaseTopicLimit = 4;
|
||||
private readonly expandedPhaseIds = new Set<string>();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['elements']) {
|
||||
@@ -46,6 +70,10 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
get compactPhases(): ResearchTimelinePhase[] {
|
||||
return this.buildCompactPhases(this.timelineItems);
|
||||
}
|
||||
|
||||
get hasYearRange(): boolean {
|
||||
return this.minYear > 0 && this.maxYear > 0 && this.minYear < this.maxYear;
|
||||
}
|
||||
@@ -72,6 +100,10 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
return Math.max(count * this.columnWidth, 1000);
|
||||
}
|
||||
|
||||
setTimelineViewMode(mode: TimelineViewMode): void {
|
||||
this.timelineViewMode = mode;
|
||||
}
|
||||
|
||||
onStartYearInput(event: Event): void {
|
||||
const nextStartYear = this.parseYearInput(event);
|
||||
|
||||
@@ -108,11 +140,39 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
getDisplayedTopics(item: TopicTimelineElement): TopicTimelineTopic[] {
|
||||
const primaryTopicName = this.getPrimaryTopic(item)?.name;
|
||||
|
||||
return this.getDisplayedTopicsForPrimaryTopic(item, primaryTopicName);
|
||||
}
|
||||
|
||||
getDisplayedTopicsForPrimaryTopic(
|
||||
item: TopicTimelineElement,
|
||||
primaryTopicName: string | undefined,
|
||||
): TopicTimelineTopic[] {
|
||||
return (item.topics ?? [])
|
||||
.filter((topic) => !this.isSameTopic(topic.name, primaryTopicName))
|
||||
.slice(0, this.displayedTopicLimit);
|
||||
}
|
||||
|
||||
getPhaseYearLabel(phase: ResearchTimelinePhase): string {
|
||||
if (phase.startYear === phase.endYear) {
|
||||
return `${phase.startYear}`;
|
||||
}
|
||||
|
||||
return `${phase.startYear}–${phase.endYear}`;
|
||||
}
|
||||
|
||||
togglePhase(phase: ResearchTimelinePhase): void {
|
||||
if (this.expandedPhaseIds.has(phase.id)) {
|
||||
this.expandedPhaseIds.delete(phase.id);
|
||||
return;
|
||||
}
|
||||
|
||||
this.expandedPhaseIds.add(phase.id);
|
||||
}
|
||||
|
||||
isPhaseExpanded(phase: ResearchTimelinePhase): boolean {
|
||||
return this.expandedPhaseIds.has(phase.id);
|
||||
}
|
||||
|
||||
getColorClass(index: number): string {
|
||||
return this.colors[index % this.colors.length];
|
||||
}
|
||||
@@ -125,6 +185,10 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
return topic.name;
|
||||
}
|
||||
|
||||
trackByPhase(_: number, phase: ResearchTimelinePhase): string {
|
||||
return phase.id;
|
||||
}
|
||||
|
||||
private get sortedElements(): TopicTimelineElement[] {
|
||||
return [...(this.elements ?? [])].sort((left, right) => left.year - right.year);
|
||||
}
|
||||
@@ -147,6 +211,121 @@ export class ResearchTimelineComponent implements OnChanges {
|
||||
this.resetYearRange();
|
||||
}
|
||||
|
||||
private buildCompactPhases(items: TopicTimelineElement[]): ResearchTimelinePhase[] {
|
||||
const phases: ResearchTimelinePhase[] = [];
|
||||
let currentPhase: WorkingResearchTimelinePhase | undefined;
|
||||
|
||||
for (const item of items) {
|
||||
const candidates = this.getDominantPrimaryTopicCandidates(item);
|
||||
|
||||
if (candidates.length === 0) {
|
||||
this.pushWorkingPhase(phases, currentPhase);
|
||||
currentPhase = this.createWorkingPhase(item, this.getMainTopic(item));
|
||||
continue;
|
||||
}
|
||||
|
||||
const matchingCandidate = currentPhase
|
||||
? candidates.find((candidate) => this.isSameTopic(candidate.name, currentPhase?.primaryTopicName))
|
||||
: undefined;
|
||||
|
||||
const canExtendCurrentPhase =
|
||||
Boolean(currentPhase) &&
|
||||
Boolean(matchingCandidate) &&
|
||||
item.year === currentPhase!.endYear + 1;
|
||||
|
||||
if (currentPhase && canExtendCurrentPhase) {
|
||||
currentPhase.endYear = item.year;
|
||||
currentPhase.publication_count += item.publication_count;
|
||||
currentPhase.years.push(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.pushWorkingPhase(phases, currentPhase);
|
||||
currentPhase = this.createWorkingPhase(item, candidates[0].name);
|
||||
}
|
||||
|
||||
this.pushWorkingPhase(phases, currentPhase);
|
||||
|
||||
return phases;
|
||||
}
|
||||
|
||||
private createWorkingPhase(
|
||||
item: TopicTimelineElement,
|
||||
primaryTopicName: string,
|
||||
): WorkingResearchTimelinePhase {
|
||||
return {
|
||||
startYear: item.year,
|
||||
endYear: item.year,
|
||||
publication_count: item.publication_count,
|
||||
primaryTopicName,
|
||||
years: [item],
|
||||
};
|
||||
}
|
||||
|
||||
private pushWorkingPhase(
|
||||
phases: ResearchTimelinePhase[],
|
||||
workingPhase: WorkingResearchTimelinePhase | undefined,
|
||||
): void {
|
||||
if (!workingPhase) {
|
||||
return;
|
||||
}
|
||||
|
||||
phases.push({
|
||||
...workingPhase,
|
||||
id: `${workingPhase.startYear}-${workingPhase.endYear}-${this.normalizeTopicName(
|
||||
workingPhase.primaryTopicName,
|
||||
)}`,
|
||||
topics: this.aggregatePhaseTopics(workingPhase.years, workingPhase.primaryTopicName),
|
||||
});
|
||||
}
|
||||
|
||||
private aggregatePhaseTopics(
|
||||
years: TopicTimelineElement[],
|
||||
primaryTopicName: string,
|
||||
): TopicTimelineTopic[] {
|
||||
const counts = new Map<string, number>();
|
||||
const originalNames = new Map<string, string>();
|
||||
|
||||
for (const year of years) {
|
||||
for (const topic of year.topics ?? []) {
|
||||
if (this.isSameTopic(topic.name, primaryTopicName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const normalizedName = this.normalizeTopicName(topic.name);
|
||||
|
||||
originalNames.set(normalizedName, topic.name);
|
||||
counts.set(normalizedName, (counts.get(normalizedName) ?? 0) + topic.count);
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(counts.entries())
|
||||
.map(([normalizedName, count]) => ({
|
||||
name: originalNames.get(normalizedName) ?? normalizedName,
|
||||
count,
|
||||
}))
|
||||
.sort((left, right) => {
|
||||
if (right.count !== left.count) {
|
||||
return right.count - left.count;
|
||||
}
|
||||
|
||||
return left.name.localeCompare(right.name);
|
||||
})
|
||||
.slice(0, this.displayedPhaseTopicLimit);
|
||||
}
|
||||
|
||||
private getDominantPrimaryTopicCandidates(item: TopicTimelineElement): TopicTimelineTopic[] {
|
||||
const primaryTopics = item.primary_topics ?? [];
|
||||
|
||||
if (primaryTopics.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const maxCount = Math.max(...primaryTopics.map((topic) => topic.count));
|
||||
|
||||
return primaryTopics.filter((topic) => topic.count === maxCount);
|
||||
}
|
||||
|
||||
private getFirstTopic(item: TopicTimelineElement): TopicTimelineTopic | undefined {
|
||||
return (item.topics ?? [])[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user