diff --git a/webapp/src/app/modules/university-ranking/uni-trend-chart/uni-trend-chart.component.ts b/webapp/src/app/modules/university-ranking/uni-trend-chart/uni-trend-chart.component.ts index 8dfdc67b..41664237 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-chart/uni-trend-chart.component.ts +++ b/webapp/src/app/modules/university-ranking/uni-trend-chart/uni-trend-chart.component.ts @@ -76,6 +76,9 @@ export class UniTrendChartComponent { // Build series: Line in top grid, growth volume bars and S-Curve in bottom grid trendData.series.forEach((entity, entityIdx) => { const color = getEntityColor(entityIdx); + if ((entity as any).visible === false) { + return; + } const yrTopicData = entity.topic_data[selectedTopic] || []; // 1. Add line series for the currently selected topic (placed in Grid 0) @@ -194,6 +197,9 @@ export class UniTrendChartComponent { trendData.series.forEach((entity: TrendSeries, entityIdx: number) => { const color = getEntityColor(entityIdx); + if ((entity as any).visible === false) { + return; + } const yrTopicData = entity.topic_data[selectedTopic] || []; // Recalculate cumulative sum map for this entity @@ -329,14 +335,7 @@ export class UniTrendChartComponent { }, }, legend: { - orient: 'vertical', - right: 10, - top: 'middle', - type: 'scroll', - textStyle: { color: '#4b5563' }, - formatter: (name: string) => { - return name.length > 22 ? name.substring(0, 20) + '...' : name; - }, + show: false, }, axisPointer: { link: [{ xAxisIndex: 'all' }], @@ -345,13 +344,13 @@ export class UniTrendChartComponent { grid: [ { left: 80, - right: 220, + right: 50, top: 80, height: 230, }, { left: 80, - right: 220, + right: 50, top: 360, height: 70, }, diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html index 69c6a181..405ba5c1 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html +++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html @@ -21,162 +21,28 @@ -
-

2. Zeitraum

-
- - bis - -
-
+ + -
-

3. Länder/Kontinente vergleichen

- -
- @if ( - comparisonCountries().length > 0 || comparisonRegions().length > 0 - ) { - @for (c of comparisonCountries(); track c.id) { -
- flag {{ c.name }} - -
- } - @for (r of comparisonRegions(); track r.id) { -
- public {{ r.name }} - -
- } - } @else { -
- Keine Länder/Kontinente ausgewählt. Suchen zum Hinzufügen. -
- } -
- - - -
- - -
-

4. Einrichtungen vergleichen

- - @if (primaryInstitutionName()) { -
- Zugewiesen: - {{ primaryInstitutionName() }} -
- } - -
- @if (comparisonInstitutions().length > 0) { - @for (inst of comparisonInstitutions(); track inst.id) { -
- apartment {{ inst.name }} - -
- } - } @else { -
- Keine weiteren Einrichtungen ausgewählt. Suchen zum Hinzufügen. -
- } -
- - -
- - -
- -
+ + @@ -232,50 +98,22 @@ [endYear]="endYear()"> - -
-

- Empfohlene Top-Einrichtungen für das Thema: {{ activeChartTopic() }} -

-
- @if (isSuggestionsLoading()) { -
-
- Empfehlungen werden geladen... -
- } @else { - @if (topSuggestions().length === 0) { -

- Keine Empfehlungen für dieses Thema gefunden. -

- } @else { -
- @for (item of topSuggestions(); track item.id || '') { - - } -
- } - } -
-
+ + + diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss index 68ec8b97..0e630880 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss +++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.scss @@ -31,10 +31,6 @@ margin: 0 0 0.75rem 0; letter-spacing: 0.05em; } - - &.suggestions-card { - background: #fafafa; - } } .checkbox-group { @@ -59,211 +55,13 @@ } } -.comparison-list { - display: flex; - flex-direction: column; - gap: 0.4rem; - max-height: 140px; - overflow-y: auto; - margin-bottom: 0.75rem; - - .empty-list-info { - font-size: 0.75rem; - color: #9ca3af; - text-align: center; - padding: 8px 0; - border: 1px dashed #e5e7eb; - border-radius: 5px; - } -} - -.comparison-item { - display: flex; - justify-content: space-between; - align-items: center; - background: #f3f4f6; - border: 1px solid #e5e7eb; +.empty-list-info { + font-size: 0.75rem; + color: #9ca3af; + text-align: center; + padding: 8px 0; + border: 1px dashed #e5e7eb; border-radius: 5px; - padding: 0.3rem 0.5rem; - - .item-name { - display: inline-flex; - align-items: center; - gap: 4px; - font-size: 0.75rem; - color: #374151; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - max-width: 210px; - - mat-icon { - font-size: 14px; - width: 14px; - height: 14px; - } - } - - .remove-btn { - background: none; - border: none; - color: #9ca3af; - cursor: pointer; - padding: 1px 4px; - border-radius: 3px; - display: inline-flex; - align-items: center; - justify-content: center; - - mat-icon { - font-size: 12px; - width: 12px; - height: 12px; - } - - &:hover { - color: #ef4444; - background: #fee2e2; - } - } - - &.location-item { - &.font-country { - background: #f0fdf4 !important; - border-color: #bbf7d0 !important; - .item-name { - color: #166534 !important; - } - } - &.font-region { - background: #eff6ff !important; - border-color: #bfdbfe !important; - .item-name { - color: #1e40af !important; - } - } - } -} - -.autocomplete-search { - position: relative; - width: 100%; - - input { - width: 100%; - padding: 0.5rem; - border-radius: 5px; - border: 1px solid #d1d5db; - font-size: 0.8125rem; - outline: none; - box-sizing: border-box; - &:focus { - border-color: #3b82f6; - } - } -} - -.autocomplete-results { - position: absolute; - top: 100%; - left: 0; - right: 0; - z-index: 50; - background: white; - border: 1px solid #e5e7eb; - border-radius: 5px; - box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); - margin-top: 3px; - padding: 0; - list-style: none; - max-height: 180px; - overflow-y: auto; - - li button { - width: 100%; - text-align: left; - background: none; - border: none; - padding: 0.5rem 0.75rem; - cursor: pointer; - display: flex; - flex-direction: column; - &:hover { - background: #f3f4f6; - } - - .name { - font-size: 0.75rem; - font-weight: 500; - color: #1f2937; - } - .hint { - font-size: 0.65rem; - color: #9ca3af; - margin-top: 1px; - } - } -} - -.suggestions-list { - display: flex; - flex-direction: column; - gap: 0.4rem; - - .suggestions-loader { - font-size: 0.75rem; - color: #9ca3af; - text-align: center; - padding: 8px 0; - } -} - -.suggestion-item { - display: flex; - justify-content: space-between; - align-items: center; - background: white; - border: 1px solid #e5e7eb; - border-radius: 6px; - padding: 0.4rem 0.6rem; - text-align: left; - cursor: pointer; - - &:hover:not([disabled]) { - border-color: #3b82f6; - background: #f0f9ff; - transform: translateY(-1px); - } - - &[disabled] { - opacity: 0.5; - cursor: not-allowed; - background: #f3f4f6; - } - - .info { - display: flex; - flex-direction: column; - max-width: 210px; - - .name { - font-size: 0.75rem; - color: #374151; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - .meta { - font-size: 0.65rem; - color: #9ca3af; - margin-top: 1px; - } - } - .add-icon { - font-size: 1rem; - color: #3b82f6; - font-weight: 600; - } } .trend-main { @@ -341,40 +139,6 @@ padding: 0.6rem 1rem; background: #f9fafb; border-bottom: 1px solid #e5e7eb; - - button { - padding: 0.3rem 0.6rem; - border: 1px solid #e5e7eb; - background: white; - color: #4b5563; - border-radius: 5px; - font-size: 0.75rem; - font-weight: 500; - cursor: pointer; - transition: all 0.15s ease; - display: inline-flex; - align-items: center; - gap: 4px; - - mat-icon { - font-size: 14px; - width: 14px; - height: 14px; - } - - &:hover { - border-color: #3b82f6; - color: #3b82f6; - background: #f0f9ff; - } - - &.active { - background: #3b82f6; - border-color: #3b82f6; - color: white; - font-weight: 600; - } - } } .loader-overlay { @@ -407,193 +171,11 @@ } } -.search-trend-btn-container { - display: flex; - justify-content: flex-end; - padding: 0.5rem 0; -} - -.search-trend-btn { - display: flex; - align-items: center; - gap: 0.5rem; - padding: 0.6rem 1.2rem; - border-radius: 6px; - font-size: 0.875rem; - font-weight: 600; - cursor: pointer; - border: 1px solid #3b82f6; - background-color: #3b82f6; - color: white; - transition: all 0.2s ease; - - mat-icon { - font-size: 18px; - width: 18px; - height: 18px; - } - - &:hover:not([disabled]) { - background-color: #2563eb; - border-color: #2563eb; - box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2); - } - - &[disabled] { - opacity: 0.6; - cursor: not-allowed; - background-color: #9ca3af; - border-color: #9ca3af; - } - - &.dirty { - animation: pulse-border 2s infinite; - background-color: #2563eb; - border-color: #1d4ed8; - } -} - -.year-selectors { - display: flex; - gap: 0.5rem; - align-items: center; - - select { - flex: 1; - padding: 0.4rem; - border-radius: 5px; - border: 1px solid #d1d5db; - font-size: 0.8125rem; - background: white; - outline: none; - &:focus { - border-color: #3b82f6; - } - } -} - @keyframes spin { - to { + 0% { + transform: rotate(0deg); + } + 100% { transform: rotate(360deg); } } - -@keyframes pulse-border { - 0% { - box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); - } - 70% { - box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); - } - 100% { - box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); - } -} - -.suggestions-below-card { - background: white; - border-radius: 10px; - padding: 1.25rem; - border: 1px solid #e5e7eb; - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); - margin-top: 1rem; - - h3 { - font-size: 0.875rem; - font-weight: 600; - color: #374151; - margin: 0 0 1rem 0; - } - - .suggestions-loader { - display: flex; - align-items: center; - gap: 0.5rem; - color: #6b7280; - font-size: 0.8125rem; - padding: 1rem 0; - - .spinner-small { - width: 16px; - height: 16px; - border: 2px solid rgba(59, 130, 246, 0.1); - border-radius: 50%; - border-top-color: #3b82f6; - animation: spin 0.8s linear infinite; - } - } - - .no-suggestions-msg { - font-size: 0.8125rem; - color: #6b7280; - text-align: center; - padding: 1rem 0; - } - - .suggestions-flex { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); - gap: 0.75rem; - } -} - -.suggestion-item-horizontal { - display: flex; - align-items: center; - gap: 0.75rem; - background: #f9fafb; - border: 1px solid #e5e7eb; - border-radius: 8px; - padding: 0.6rem 0.8rem; - text-align: left; - cursor: pointer; - transition: all 0.2s ease; - width: 100%; - box-sizing: border-box; - - &:hover:not([disabled]) { - border-color: #3b82f6; - background: #f0f9ff; - transform: translateY(-1px); - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); - } - - &[disabled] { - opacity: 0.5; - cursor: not-allowed; - background: #f3f4f6; - } - - .add-icon { - color: #3b82f6; - display: flex; - align-items: center; - justify-content: center; - width: 20px; - height: 20px; - border-radius: 50%; - background: rgba(59, 130, 246, 0.1); - flex-shrink: 0; - font-size: 14px; - } - - .info { - display: flex; - flex-direction: column; - overflow: hidden; - - .name { - font-size: 0.8125rem; - color: #374151; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - font-weight: 600; - } - .meta { - font-size: 0.7rem; - color: #6b7280; - margin-top: 2px; - } - } -} diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts index 2aa8650c..1e7ae1fe 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts +++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts @@ -35,6 +35,9 @@ import { } from '../../../api'; import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component'; import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; +import { YearRangeSliderComponent } from '../../../shared/ui/year-range-slider/year-range-slider.component'; +import { LocationSelectorComponent } from '../../../shared/ui/location-selector/location-selector.component'; +import { InstitutionSelectorComponent } from '../../../shared/ui/institution-selector/institution-selector.component'; export interface CompareItem { id: string; @@ -47,15 +50,14 @@ export interface CompareItem { CommonModule, FormsModule, UniTrendChartComponent, - MatFormFieldModule, - MatInputModule, - MatSelectModule, MatCheckboxModule, MatButtonModule, MatIconModule, MatProgressSpinnerModule, - MatAutocompleteModule, TopicChipComponent, + YearRangeSliderComponent, + LocationSelectorComponent, + InstitutionSelectorComponent, ], templateUrl: './uni-trend-parent.component.html', styleUrl: './uni-trend-parent.component.scss', @@ -113,6 +115,58 @@ export class UniTrendParentComponent implements OnInit { // Years array for selects readonly availableYears: number[] = []; + readonly entityVisibilityMap = signal>(new Map()); + + isVisible(id: string): boolean { + return this.entityVisibilityMap().get(id) !== false; + } + + toggleVisibility(id: string): void { + this.entityVisibilityMap.update((map) => { + const newMap = new Map(map); + const current = newMap.get(id) !== false; + newMap.set(id, !current); + return newMap; + }); + } + + getEntityColor(entityId: string): string { + const defaultInstId = 'https://openalex.org/I62318514'; + const primaryId = this.primaryInstitution() || defaultInstId; + const insts = this.comparisonInstitutions().map((i) => i.id); + const countries = this.comparisonCountries().map((c) => c.id); + const regions = this.comparisonRegions().map((r) => r.id); + + const orderedIds = [primaryId, ...insts, ...countries, ...regions]; + + const idx = orderedIds.indexOf(entityId); + if (idx === -1) return '#9ca3af'; + + const entityColors = [ + '#3b82f6', + '#10b981', + '#f59e0b', + '#ec4899', + '#8b5cf6', + '#06b6d4', + '#6366f1', + '#ef4444', + '#14b8a6', + '#f97316', + '#d946ef', + '#84cc16', + '#22c55e', + '#a855f7', + '#eab308', + '#f43f5e', + ]; + + return entityColors[idx % entityColors.length]; + } + + readonly boundGetEntityColor = (id: string) => this.getEntityColor(id); + readonly boundIsVisible = (id: string) => this.isVisible(id); + // Computed: filters out items locally if they were removed from list readonly trendResponse = computed(() => { const raw = this.rawTrendResponse(); @@ -129,63 +183,46 @@ export class UniTrendParentComponent implements OnInit { ); const defaultInstId = 'https://openalex.org/I62318514'.toLowerCase(); - const filteredSeries = raw.series.filter((s: TrendSeries) => { + const primaryInstSeries: TrendSeries[] = []; + const compInstSeries: TrendSeries[] = []; + const countrySeries: TrendSeries[] = []; + const regionSeries: TrendSeries[] = []; + + raw.series.forEach((s: TrendSeries) => { const id = s.entity_id.toLowerCase(); if (s.entity_type === 'institution') { - return id === defaultInstId || currentInstIds.has(id); + if (id === defaultInstId) { + primaryInstSeries.push(s); + } else if (currentInstIds.has(id)) { + compInstSeries.push(s); + } } else if (s.entity_type === 'country') { - return currentCountryIds.has(id); + if (currentCountryIds.has(id)) { + countrySeries.push(s); + } } else if (s.entity_type === 'region') { - return currentRegionIds.has(id); + if (currentRegionIds.has(id)) { + regionSeries.push(s); + } } - return false; }); + const filteredSeries = [ + ...primaryInstSeries, + ...compInstSeries, + ...countrySeries, + ...regionSeries, + ].map((s) => ({ + ...s, + visible: this.isVisible(s.entity_id), + })); + return { ...raw, series: filteredSeries, }; }); - // Computed dirty state to enable "Search" button - readonly isDirty = computed(() => { - const fetchedInsts = this.fetchedInstitutions() - .map((i: CompareItem) => i.id) - .sort() - .join(','); - const currentInsts = this.comparisonInstitutions() - .map((i: CompareItem) => i.id) - .sort() - .join(','); - if (fetchedInsts !== currentInsts) return true; - - const fetchedC = this.fetchedCountries() - .map((c: CompareItem) => c.id) - .sort() - .join(','); - const currentC = this.comparisonCountries() - .map((c: CompareItem) => c.id) - .sort() - .join(','); - if (fetchedC !== currentC) return true; - - const fetchedR = this.fetchedRegions() - .map((r: CompareItem) => r.id) - .sort() - .join(','); - const currentR = this.comparisonRegions() - .map((r: CompareItem) => r.id) - .sort() - .join(','); - if (fetchedR !== currentR) return true; - - const fetchedT = this.fetchedTopics().sort().join(','); - const currentT = this.selectedTrendTopics().sort().join(','); - if (fetchedT !== currentT) return true; - - return false; - }); - constructor() { // Generate year range from 2000 to current year const currentYear = new Date().getFullYear(); @@ -238,6 +275,59 @@ export class UniTrendParentComponent implements OnInit { }); }); + // Effect: automatically refetch trend data whenever topics or comparisons change (fully reactive) + effect(() => { + const topics = this.selectedTrendTopics(); + const insts = this.comparisonInstitutions(); + const countries = this.comparisonCountries(); + const regions = this.comparisonRegions(); + + if (topics.length === 0) return; + + const topicsStr = [...topics].sort().join(','); + const fetchedT = untracked(() => this.fetchedTopics()) + .sort() + .join(','); + + const instsStr = insts + .map((i) => i.id) + .sort() + .join(','); + const fetchedI = untracked(() => this.fetchedInstitutions()) + .map((i) => i.id) + .sort() + .join(','); + + const countriesStr = countries + .map((c) => c.id) + .sort() + .join(','); + const fetchedC = untracked(() => this.fetchedCountries()) + .map((c) => c.id) + .sort() + .join(','); + + const regionsStr = regions + .map((r) => r.id) + .sort() + .join(','); + const fetchedR = untracked(() => this.fetchedRegions()) + .map((r) => r.id) + .sort() + .join(','); + + if ( + topicsStr === fetchedT && + instsStr === fetchedI && + countriesStr === fetchedC && + regionsStr === fetchedR + ) { + return; + } + + untracked(() => this.fetchTrendData()); + }); + // Handle initialization and synchronization of URL state this.route.queryParams.subscribe((params) => { // Parse institutions serialized as id|name