feat(work-classifications): add research profiles to publication details
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List, Optional, Set
|
||||
|
||||
from inse.authors.v2.model import AuthorPage
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.institutions.v2 import service as institution_service
|
||||
from inse.model import ESIndex
|
||||
from inse.models.openalex.author import Author
|
||||
from inse.models.openalex.institution import Institution
|
||||
|
||||
|
||||
async def search_authors(
|
||||
@@ -128,18 +130,165 @@ async def author_currently_belongs_to_institution(
|
||||
bool: True if the author belongs to the institution in any of the specified years, False otherwise.
|
||||
"""
|
||||
|
||||
author = await get_author_by_id(raw_oa_author_id)
|
||||
if not author:
|
||||
if not current_years:
|
||||
return False
|
||||
|
||||
for affiliation in author.affiliations or []:
|
||||
institution = affiliation.institution
|
||||
if not institution:
|
||||
continue
|
||||
matching_author_ids = await _authors_belong_to_institution(
|
||||
[raw_oa_author_id],
|
||||
raw_oa_institution_id,
|
||||
affiliation_year_filter={"terms": {"affiliations.years": current_years}},
|
||||
)
|
||||
return bool(matching_author_ids)
|
||||
|
||||
if institution.id == f"https://openalex.org/{raw_oa_institution_id}" and any(
|
||||
year in (affiliation.years or []) for year in current_years
|
||||
):
|
||||
return True
|
||||
|
||||
return False
|
||||
def _prefix_openalex_id(raw_id: str) -> str:
|
||||
if raw_id.startswith("https://openalex.org/"):
|
||||
return raw_id
|
||||
return f"https://openalex.org/{raw_id}"
|
||||
|
||||
|
||||
async def _get_institution_identity(
|
||||
raw_oa_institution_id: str,
|
||||
) -> Optional[Institution]:
|
||||
page = await institution_service.get_institutions_by_ids(
|
||||
[_prefix_openalex_id(raw_oa_institution_id)]
|
||||
)
|
||||
return page.elements[0] if page.elements else None
|
||||
|
||||
|
||||
def _current_institution_cohort_query(
|
||||
author_ids: List[str],
|
||||
institution_id: str,
|
||||
institution_ror: Optional[str],
|
||||
institution_display_name: str,
|
||||
affiliation_year_filter: Dict,
|
||||
) -> Dict:
|
||||
"""Build the author cohort query used by work classification access."""
|
||||
|
||||
affiliation_identifiers = [
|
||||
{"term": {"affiliations.institution.id": institution_id}},
|
||||
]
|
||||
if institution_ror:
|
||||
affiliation_identifiers.append(
|
||||
{"term": {"affiliations.institution.ror": institution_ror}}
|
||||
)
|
||||
affiliation_identifiers.append(
|
||||
{
|
||||
"match_phrase": {
|
||||
"affiliations.institution.display_name": institution_display_name
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
recent_affiliation = {
|
||||
"nested": {
|
||||
"path": "affiliations",
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"bool": {
|
||||
"should": affiliation_identifiers,
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
affiliation_year_filter,
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
matching_last_known_institution = {
|
||||
"nested": {
|
||||
"path": "last_known_institutions",
|
||||
"query": {
|
||||
"match_phrase": {
|
||||
"last_known_institutions.display_name": institution_display_name
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
missing_last_known_institutions = {
|
||||
"bool": {
|
||||
"must_not": [
|
||||
{
|
||||
"nested": {
|
||||
"path": "last_known_institutions",
|
||||
"query": {
|
||||
"exists": {
|
||||
"field": "last_known_institutions.display_name"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"terms": {
|
||||
"id": [_prefix_openalex_id(author_id) for author_id in author_ids]
|
||||
}
|
||||
},
|
||||
recent_affiliation,
|
||||
{
|
||||
"bool": {
|
||||
"should": [
|
||||
matching_last_known_institution,
|
||||
missing_last_known_institutions,
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async def authors_currently_belong_to_institution(
|
||||
raw_oa_author_ids: List[str],
|
||||
raw_oa_institution_id: str,
|
||||
) -> Set[str]:
|
||||
"""Return current cohort members using one query for all author IDs."""
|
||||
|
||||
return await _authors_belong_to_institution(
|
||||
raw_oa_author_ids,
|
||||
raw_oa_institution_id,
|
||||
affiliation_year_filter={
|
||||
"range": {"affiliations.years": {"gte": 2025}}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
async def _authors_belong_to_institution(
|
||||
raw_oa_author_ids: List[str],
|
||||
raw_oa_institution_id: str,
|
||||
affiliation_year_filter: Dict,
|
||||
) -> Set[str]:
|
||||
"""Return matching author IDs for the supplied affiliation-year filter."""
|
||||
|
||||
author_ids = list(dict.fromkeys(filter(None, raw_oa_author_ids)))
|
||||
if not author_ids:
|
||||
return set()
|
||||
|
||||
institution = await _get_institution_identity(raw_oa_institution_id)
|
||||
if not institution or not institution.display_name:
|
||||
return set()
|
||||
|
||||
authors = await search_authors(
|
||||
page=0,
|
||||
size=len(author_ids),
|
||||
query=_current_institution_cohort_query(
|
||||
author_ids=author_ids,
|
||||
institution_id=institution.id
|
||||
or _prefix_openalex_id(raw_oa_institution_id),
|
||||
institution_ror=institution.ror,
|
||||
institution_display_name=institution.display_name,
|
||||
affiliation_year_filter=affiliation_year_filter,
|
||||
),
|
||||
source=["id"],
|
||||
)
|
||||
return {author.id for author in authors.elements if author.id}
|
||||
|
||||
@@ -787,12 +787,21 @@ async def get_work_classification_by_work_id(
|
||||
return None
|
||||
|
||||
work = await get_work(
|
||||
raw_oa_work_id=raw_oa_work_id, source=["id", "authorships.institutions.id"]
|
||||
raw_oa_work_id=raw_oa_work_id, source=["id", "authorships.author.id"]
|
||||
)
|
||||
if not work:
|
||||
return None
|
||||
|
||||
if not _work_has_authorship_with_institution_id(work, raw_account_institution_id):
|
||||
author_ids = list(
|
||||
dict.fromkeys(
|
||||
authorship.author.id
|
||||
for authorship in work.authorships or []
|
||||
if authorship.author and authorship.author.id
|
||||
)
|
||||
)
|
||||
if not await author_service.authors_currently_belong_to_institution(
|
||||
author_ids, raw_account_institution_id
|
||||
):
|
||||
return None
|
||||
|
||||
return await _get_work_classification_by_work_id(
|
||||
|
||||
@@ -218,6 +218,8 @@
|
||||
}
|
||||
</section>
|
||||
|
||||
<app-research-profile [workClassification]="workClassification()" />
|
||||
|
||||
@if (publication.topics?.length) {
|
||||
<section class="card">
|
||||
<div class="section-title">
|
||||
|
||||
@@ -21,6 +21,7 @@ import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { WorkTypePipe } from '../../shared/pipes/work-type.pipe';
|
||||
import { LanguageCodePipe } from '../../shared/pipes/language-code.pipe';
|
||||
import { WorkPrimaryCategoryPipe } from '../../shared/pipes/work-primary-category.pipe';
|
||||
import { ResearchProfileComponent } from './research-profile/research-profile.component';
|
||||
|
||||
interface DetailLink {
|
||||
label: string;
|
||||
@@ -47,7 +48,8 @@ interface InstitutionDetail {
|
||||
TopicChipComponent,
|
||||
WorkTypePipe,
|
||||
LanguageCodePipe,
|
||||
WorkPrimaryCategoryPipe
|
||||
WorkPrimaryCategoryPipe,
|
||||
ResearchProfileComponent,
|
||||
],
|
||||
templateUrl: './publication-detail.component.html',
|
||||
styleUrl: './publication-detail.component.scss',
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
@if (details(); as profile) {
|
||||
<mat-card appearance="outlined" class="research-profile-card">
|
||||
<mat-card-header class="profile-header">
|
||||
<mat-icon class="profile-icon">science</mat-icon>
|
||||
<div class="profile-heading">
|
||||
<mat-card-title>Forschungsprofil</mat-card-title>
|
||||
<mat-card-subtitle>
|
||||
Einordnung der Forschungsorientierung dieser Publikation
|
||||
</mat-card-subtitle>
|
||||
</div>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-card-content>
|
||||
<div class="visualizations">
|
||||
<section aria-labelledby="pasteur-title">
|
||||
<h3 id="pasteur-title" class="visualization-title">
|
||||
Pasteur-Quadrant
|
||||
</h3>
|
||||
<div class="quadrant-chart-frame">
|
||||
<div
|
||||
echarts
|
||||
class="quadrant-chart"
|
||||
[options]="quadrantOptions()"
|
||||
(chartInit)="onQuadrantChartInit($event)"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<mat-divider vertical></mat-divider>
|
||||
|
||||
<section aria-labelledby="score-title" class="score-section">
|
||||
<h3 id="score-title" class="visualization-title">
|
||||
Orientierungsscore
|
||||
</h3>
|
||||
<div class="score-content">
|
||||
<div echarts class="score-chart" [options]="scoreOptions()"></div>
|
||||
<div class="score-labels" aria-hidden="true">
|
||||
<span>Grundlagenorientiert</span>
|
||||
<span>Anwendungsorientiert</span>
|
||||
</div>
|
||||
@if (profile.primary_category; as category) {
|
||||
<app-topic-chip
|
||||
[label]="category | workPrimaryCategory"
|
||||
[color]="primaryCategoryChipColor()"
|
||||
[disabled]="true" />
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@if (
|
||||
profile.confidence === 'medium' ||
|
||||
profile.confidence === 'low' ||
|
||||
profile.insufficient_context
|
||||
) {
|
||||
<mat-divider class="notices-divider"></mat-divider>
|
||||
<div class="notices" aria-label="Hinweise zur Klassifikation">
|
||||
@if (
|
||||
profile.confidence === 'medium' || profile.confidence === 'low'
|
||||
) {
|
||||
<mat-card
|
||||
appearance="outlined"
|
||||
class="warning-note"
|
||||
[style.--warning-border]="
|
||||
confidenceWarningTokens(profile.confidence).border
|
||||
"
|
||||
[style.--warning-background]="
|
||||
confidenceWarningTokens(profile.confidence).background
|
||||
"
|
||||
[style.--warning-text]="
|
||||
confidenceWarningTokens(profile.confidence).color
|
||||
">
|
||||
<span>{{ confidenceLabel(profile.confidence) }}</span>
|
||||
<mat-icon
|
||||
class="info-icon"
|
||||
[matTooltip]="confidenceTooltip(profile.confidence)"
|
||||
matTooltipPosition="above"
|
||||
(click)="$event.stopPropagation()"
|
||||
aria-label="Erläuterung zur Konfidenz">
|
||||
info_outline
|
||||
</mat-icon>
|
||||
</mat-card>
|
||||
}
|
||||
|
||||
@if (profile.insufficient_context) {
|
||||
<mat-card
|
||||
appearance="outlined"
|
||||
class="warning-note"
|
||||
[style.--warning-border]="warningTokens.border"
|
||||
[style.--warning-background]="warningTokens.background"
|
||||
[style.--warning-text]="warningTokens.color">
|
||||
<span>Begrenzte Informationsgrundlage</span>
|
||||
<mat-icon
|
||||
class="info-icon"
|
||||
matTooltip="Für diese Einordnung standen nicht genügend inhaltliche Angaben zur Verfügung."
|
||||
matTooltipPosition="above"
|
||||
(click)="$event.stopPropagation()"
|
||||
aria-label="Erläuterung zur Informationsgrundlage">
|
||||
info_outline
|
||||
</mat-icon>
|
||||
</mat-card>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.research-profile-card {
|
||||
border-color: var(--sg-border);
|
||||
border-radius: var(--sg-radius-md);
|
||||
background: var(--sg-surface);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
}
|
||||
|
||||
.profile-header {
|
||||
align-items: flex-start;
|
||||
padding: 22px 24px 12px;
|
||||
}
|
||||
|
||||
.profile-icon {
|
||||
flex: 0 0 24px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: 1px 12px 0 0;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 24px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.profile-heading {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
mat-card-title {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
mat-card-subtitle {
|
||||
margin-top: 3px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
mat-card-content {
|
||||
padding: 8px 24px 24px;
|
||||
}
|
||||
|
||||
.visualizations {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 1px minmax(240px, 300px);
|
||||
gap: 20px;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.visualizations section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.visualizations .visualization-title {
|
||||
margin: 8px 0 4px;
|
||||
color: var(--sg-text);
|
||||
font:
|
||||
700 16px/1.3 'Open Sans',
|
||||
Arial,
|
||||
sans-serif !important;
|
||||
}
|
||||
|
||||
.quadrant-chart-frame {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 320px;
|
||||
}
|
||||
|
||||
.quadrant-chart {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.score-section {
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.score-section .visualization-title {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.score-content {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding-bottom: 22px;
|
||||
}
|
||||
|
||||
.score-chart {
|
||||
width: 100%;
|
||||
max-width: 280px;
|
||||
height: 180px;
|
||||
}
|
||||
|
||||
.score-labels {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: min(100%, 280px);
|
||||
margin-top: -36px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.score-content app-topic-chip {
|
||||
margin-top: 24px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.notices-divider {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.notices {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.warning-note {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-height: 42px;
|
||||
padding: 9px 12px;
|
||||
border-color: var(--warning-border);
|
||||
border-radius: 12px;
|
||||
background: var(--warning-background);
|
||||
color: var(--warning-text);
|
||||
box-shadow: none;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.warning-note .info-icon {
|
||||
flex: 0 0 auto;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: inherit;
|
||||
font-size: 16px;
|
||||
line-height: 16px;
|
||||
opacity: 0.7;
|
||||
cursor: default;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.visualizations {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.visualizations > mat-divider {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.profile-header {
|
||||
padding-inline: 16px;
|
||||
}
|
||||
|
||||
mat-card-content {
|
||||
padding-inline: 16px;
|
||||
}
|
||||
|
||||
.quadrant-chart-frame {
|
||||
height: 350px;
|
||||
}
|
||||
}
|
||||
+422
@@ -0,0 +1,422 @@
|
||||
import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
computed,
|
||||
inject,
|
||||
input,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { EChartsOption, EChartsType } from 'echarts';
|
||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||
import {
|
||||
WorkClassification,
|
||||
WorkClassificationDetails,
|
||||
WorkPrimaryCategory,
|
||||
} from '../../../api';
|
||||
import { WorkPrimaryCategoryPipe } from '../../../shared/pipes/work-primary-category.pipe';
|
||||
import {
|
||||
TopicChipComponent,
|
||||
TopicChipPaletteColor,
|
||||
topicChipColorTokens,
|
||||
} from '../../../shared/ui/topic-chip/topic-chip.component';
|
||||
|
||||
type PasteurQuadrant =
|
||||
| 'pure_basic'
|
||||
| 'use_inspired_basic'
|
||||
| 'pure_applied'
|
||||
| 'not_applicable';
|
||||
|
||||
interface QuadrantDefinition {
|
||||
key: PasteurQuadrant;
|
||||
coordinate: [string, string];
|
||||
title: string;
|
||||
description: string;
|
||||
color?: 'blue' | 'purple' | 'green';
|
||||
}
|
||||
|
||||
const QUADRANTS: readonly QuadrantDefinition[] = [
|
||||
{
|
||||
key: 'pure_basic',
|
||||
coordinate: ['Niedrig', 'Hoch'],
|
||||
title: 'Bohr',
|
||||
description: 'Reine\nGrundlagenforschung',
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
key: 'use_inspired_basic',
|
||||
coordinate: ['Hoch', 'Hoch'],
|
||||
title: 'Pasteur',
|
||||
description: 'Vom Nutzen inspirierte\nGrundlagenforschung',
|
||||
color: 'purple',
|
||||
},
|
||||
{
|
||||
key: 'not_applicable',
|
||||
coordinate: ['Niedrig', 'Niedrig'],
|
||||
title: 'Weder noch',
|
||||
description: 'Keine eindeutige\nForschungsorientierung',
|
||||
},
|
||||
{
|
||||
key: 'pure_applied',
|
||||
coordinate: ['Hoch', 'Niedrig'],
|
||||
title: 'Edison',
|
||||
description: 'Angewandte Forschung\nund Entwicklung',
|
||||
color: 'green',
|
||||
},
|
||||
];
|
||||
|
||||
const BLUE_TOKENS = topicChipColorTokens('blue');
|
||||
const WARNING_TOKENS = topicChipColorTokens('orange');
|
||||
const LOW_CONFIDENCE_TOKENS = topicChipColorTokens('pink');
|
||||
|
||||
@Component({
|
||||
selector: 'app-research-profile',
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatDividerModule,
|
||||
MatIconModule,
|
||||
MatTooltipModule,
|
||||
NgxEchartsDirective,
|
||||
TopicChipComponent,
|
||||
WorkPrimaryCategoryPipe,
|
||||
],
|
||||
templateUrl: './research-profile.component.html',
|
||||
styleUrl: './research-profile.component.scss',
|
||||
})
|
||||
export class ResearchProfileComponent {
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly quadrantChartSize = signal({ width: 640, height: 320 });
|
||||
private quadrantResizeObserver?: ResizeObserver;
|
||||
|
||||
workClassification = input.required<WorkClassification | null>();
|
||||
readonly warningTokens = WARNING_TOKENS;
|
||||
|
||||
details = computed<WorkClassificationDetails | null>(() => {
|
||||
const details = this.workClassification()?.classification;
|
||||
if (
|
||||
!details ||
|
||||
details.primary_category === WorkPrimaryCategory.NonResearch
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return details;
|
||||
});
|
||||
|
||||
quadrantOptions = computed<EChartsOption>(() =>
|
||||
this.buildQuadrantOptions(this.details()?.pasteur_quadrant),
|
||||
);
|
||||
|
||||
scoreOptions = computed<EChartsOption>(() =>
|
||||
this.buildScoreOptions(this.details()?.applied_orientation_score ?? 0),
|
||||
);
|
||||
|
||||
primaryCategoryChipColor = computed<TopicChipPaletteColor>(() => {
|
||||
switch (this.details()?.primary_category) {
|
||||
case WorkPrimaryCategory.BasicResearch:
|
||||
return 'green';
|
||||
case WorkPrimaryCategory.AppliedResearch:
|
||||
return 'pink';
|
||||
case WorkPrimaryCategory.ExperimentalDevelopment:
|
||||
return 'purple';
|
||||
default:
|
||||
return 'orange';
|
||||
}
|
||||
});
|
||||
|
||||
confidenceLabel(confidence: string | null | undefined): string {
|
||||
return confidence === 'low' ? 'Geringe Konfidenz' : 'Mittlere Konfidenz';
|
||||
}
|
||||
|
||||
confidenceTooltip(confidence: string | null | undefined): string {
|
||||
return confidence === 'low'
|
||||
? 'Das Klassifikationsergebnis wurde mit geringer Konfidenz bestimmt.'
|
||||
: 'Das Klassifikationsergebnis wurde mit mittlerer Konfidenz bestimmt.';
|
||||
}
|
||||
|
||||
confidenceWarningTokens(confidence: string | null | undefined) {
|
||||
return confidence === 'low' ? LOW_CONFIDENCE_TOKENS : WARNING_TOKENS;
|
||||
}
|
||||
|
||||
onQuadrantChartInit(chart: EChartsType): void {
|
||||
const updateSize = (width: number, height: number) => {
|
||||
const current = this.quadrantChartSize();
|
||||
if (current.width !== width || current.height !== height) {
|
||||
this.quadrantChartSize.set({ width, height });
|
||||
}
|
||||
};
|
||||
|
||||
updateSize(chart.getWidth(), chart.getHeight());
|
||||
if (typeof ResizeObserver !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.quadrantResizeObserver?.disconnect();
|
||||
this.quadrantResizeObserver = new ResizeObserver(([entry]) => {
|
||||
if (entry) {
|
||||
updateSize(entry.contentRect.width, entry.contentRect.height);
|
||||
}
|
||||
});
|
||||
this.quadrantResizeObserver.observe(chart.getDom());
|
||||
this.destroyRef.onDestroy(() => this.quadrantResizeObserver?.disconnect());
|
||||
}
|
||||
|
||||
private buildQuadrantOptions(
|
||||
activeQuadrant: string | null | undefined,
|
||||
): EChartsOption {
|
||||
const textColor = this.cssColor('--sg-text-muted', BLUE_TOKENS.color);
|
||||
const inactiveColor = this.cssColor(
|
||||
'--sg-surface-muted',
|
||||
BLUE_TOKENS.background,
|
||||
);
|
||||
const neutralActiveColor = this.cssColor('--sg-border', BLUE_TOKENS.border);
|
||||
const surfaceColor = this.cssColor('--sg-surface', 'white');
|
||||
const axisColor = this.cssColor('--sg-text', BLUE_TOKENS.color);
|
||||
const { width: chartWidth, height: chartHeight } = this.quadrantChartSize();
|
||||
const axisLeft = 59;
|
||||
const axisTop = 12;
|
||||
const axisRight = 12;
|
||||
const axisBottom = 39;
|
||||
const horizontalY = chartHeight - axisBottom;
|
||||
const horizontalTipX = chartWidth - axisRight;
|
||||
return {
|
||||
animation: false,
|
||||
tooltip: { show: false },
|
||||
visualMap: {
|
||||
type: 'piecewise',
|
||||
show: false,
|
||||
dimension: 2,
|
||||
pieces: [
|
||||
{ value: 0, color: inactiveColor },
|
||||
{ value: 1, color: topicChipColorTokens('blue').activeBackground },
|
||||
{
|
||||
value: 2,
|
||||
color: topicChipColorTokens('purple').activeBackground,
|
||||
},
|
||||
{ value: 3, color: topicChipColorTokens('green').activeBackground },
|
||||
{ value: 4, color: neutralActiveColor },
|
||||
],
|
||||
},
|
||||
matrix: {
|
||||
left: 68,
|
||||
right: 12,
|
||||
top: 12,
|
||||
bottom: 48,
|
||||
x: {
|
||||
show: false,
|
||||
data: ['Niedrig', 'Hoch'],
|
||||
dividerLineStyle: { width: 0, opacity: 0 },
|
||||
itemStyle: { borderWidth: 0, opacity: 0 },
|
||||
},
|
||||
y: {
|
||||
show: false,
|
||||
data: ['Hoch', 'Niedrig'],
|
||||
dividerLineStyle: { width: 0, opacity: 0 },
|
||||
itemStyle: { borderWidth: 0, opacity: 0 },
|
||||
},
|
||||
body: {
|
||||
itemStyle: { borderWidth: 0, opacity: 0 },
|
||||
label: { show: false },
|
||||
},
|
||||
corner: {
|
||||
itemStyle: { borderWidth: 0, opacity: 0 },
|
||||
label: { show: false },
|
||||
},
|
||||
backgroundStyle: { borderWidth: 0, opacity: 0 },
|
||||
},
|
||||
graphic: [
|
||||
{
|
||||
type: 'line',
|
||||
silent: true,
|
||||
shape: {
|
||||
x1: axisLeft,
|
||||
y1: horizontalY,
|
||||
x2: horizontalTipX - 10,
|
||||
y2: horizontalY,
|
||||
},
|
||||
style: { stroke: axisColor, lineWidth: 2 },
|
||||
},
|
||||
{
|
||||
type: 'polygon',
|
||||
silent: true,
|
||||
shape: {
|
||||
points: [
|
||||
[horizontalTipX, horizontalY],
|
||||
[horizontalTipX - 10, horizontalY - 6],
|
||||
[horizontalTipX - 10, horizontalY + 6],
|
||||
],
|
||||
},
|
||||
style: { fill: axisColor },
|
||||
},
|
||||
{
|
||||
type: 'line',
|
||||
silent: true,
|
||||
shape: {
|
||||
x1: axisLeft,
|
||||
y1: horizontalY,
|
||||
x2: axisLeft,
|
||||
y2: axisTop + 10,
|
||||
},
|
||||
style: { stroke: axisColor, lineWidth: 2 },
|
||||
},
|
||||
{
|
||||
type: 'polygon',
|
||||
silent: true,
|
||||
shape: {
|
||||
points: [
|
||||
[axisLeft, axisTop],
|
||||
[axisLeft - 6, axisTop + 10],
|
||||
[axisLeft + 6, axisTop + 10],
|
||||
],
|
||||
},
|
||||
style: { fill: axisColor },
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
x: axisLeft + (horizontalTipX - axisLeft) / 2,
|
||||
y: chartHeight - 17,
|
||||
style: {
|
||||
text: 'Anwendungsorientierung',
|
||||
fill: textColor,
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
align: 'center',
|
||||
verticalAlign: 'bottom',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
left: 38,
|
||||
top: 'middle',
|
||||
rotation: Math.PI / 2,
|
||||
style: {
|
||||
text: 'Erkenntnisorientierung',
|
||||
fill: textColor,
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
},
|
||||
},
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'matrix',
|
||||
silent: true,
|
||||
emphasis: { disabled: true },
|
||||
data: QUADRANTS.map((quadrant) => {
|
||||
const active = quadrant.key === activeQuadrant;
|
||||
const activeTokens = quadrant.color
|
||||
? topicChipColorTokens(quadrant.color)
|
||||
: BLUE_TOKENS;
|
||||
const activeColorValue = quadrant.color
|
||||
? ({ blue: 1, purple: 2, green: 3 } as const)[quadrant.color]
|
||||
: 4;
|
||||
return {
|
||||
value: [...quadrant.coordinate, active ? activeColorValue : 0],
|
||||
itemStyle: {
|
||||
borderColor: surfaceColor,
|
||||
borderWidth: 4,
|
||||
borderRadius: 10,
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
color: active ? activeTokens.color : textColor,
|
||||
fontSize: 11,
|
||||
lineHeight: 16,
|
||||
fontWeight: 400,
|
||||
formatter: [
|
||||
`{title|${quadrant.title}}`,
|
||||
`{description|${quadrant.description}}`,
|
||||
...(active ? ['{active|✓ Diese Publikation}'] : []),
|
||||
].join('\n'),
|
||||
rich: {
|
||||
title: {
|
||||
color: active ? activeTokens.color : textColor,
|
||||
fontSize: 13,
|
||||
fontWeight: 700,
|
||||
lineHeight: 19,
|
||||
},
|
||||
description: {
|
||||
color: active ? activeTokens.color : textColor,
|
||||
fontSize: 11,
|
||||
fontWeight: 400,
|
||||
lineHeight: 16,
|
||||
},
|
||||
active: {
|
||||
color: activeTokens.color,
|
||||
backgroundColor: surfaceColor,
|
||||
borderColor: activeTokens.color,
|
||||
borderWidth: 1,
|
||||
borderRadius: 11,
|
||||
padding: [5, 10, 2, 10],
|
||||
fontSize: 10,
|
||||
fontWeight: 700,
|
||||
lineHeight: 18,
|
||||
align: 'center',
|
||||
verticalAlign: 'middle',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private buildScoreOptions(score: number): EChartsOption {
|
||||
const boundedScore = Math.max(0, Math.min(100, score));
|
||||
const textColor = this.cssColor('--sg-text', BLUE_TOKENS.color);
|
||||
return {
|
||||
animation: false,
|
||||
series: [
|
||||
{
|
||||
type: 'gauge',
|
||||
min: 0,
|
||||
max: 100,
|
||||
startAngle: 180,
|
||||
endAngle: 0,
|
||||
center: ['50%', '70%'],
|
||||
radius: '92%',
|
||||
progress: {
|
||||
show: true,
|
||||
width: 13,
|
||||
itemStyle: { color: BLUE_TOKENS.color },
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: { width: 13, color: [[1, BLUE_TOKENS.background]] },
|
||||
},
|
||||
pointer: { show: false },
|
||||
axisTick: { show: false },
|
||||
splitLine: { show: false },
|
||||
axisLabel: { show: false },
|
||||
anchor: { show: false },
|
||||
title: { show: false },
|
||||
detail: {
|
||||
valueAnimation: false,
|
||||
offsetCenter: [0, '-8%'],
|
||||
color: textColor,
|
||||
fontSize: 25,
|
||||
fontWeight: 700,
|
||||
formatter: '{value}',
|
||||
},
|
||||
data: [{ value: boundedScore }],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private cssColor(variable: string, fallback: string): string {
|
||||
if (typeof getComputedStyle !== 'function') {
|
||||
return fallback;
|
||||
}
|
||||
return (
|
||||
getComputedStyle(document.documentElement)
|
||||
.getPropertyValue(variable)
|
||||
.trim() || fallback
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ export class WorkPrimaryCategoryPipe implements PipeTransform {
|
||||
transform(
|
||||
value: WorkPrimaryCategory | null | undefined,
|
||||
...args: unknown[]
|
||||
): unknown {
|
||||
): string {
|
||||
return transformWorkPrimaryCategory(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="topic-chip__button"
|
||||
[class.topic-chip__button--without-count]="!hasCount"
|
||||
[disabled]="disabled"
|
||||
[attr.aria-pressed]="active ? 'true' : null"
|
||||
[matTooltip]="buttonTooltip"
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.topic-chip__button--without-count {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
:host(.topic-chip--normal) .topic-chip__button {
|
||||
column-gap: 8px;
|
||||
min-height: 34px;
|
||||
@@ -61,7 +65,7 @@
|
||||
|
||||
:host(.topic-chip--active.topic-chip--normal) .topic-chip__button {
|
||||
border-color: var(--topic-color);
|
||||
background: color-mix(in srgb, var(--topic-color) 27%, #ffffff);
|
||||
background: var(--topic-active-bg);
|
||||
color: color-mix(in srgb, var(--topic-color) 40%, #07163d);
|
||||
box-shadow:
|
||||
inset 0 0 0 1px var(--topic-color),
|
||||
|
||||
@@ -25,6 +25,7 @@ export type TopicChipTooltipTarget = 'label' | 'button';
|
||||
interface TopicChipColorTokens {
|
||||
border: string;
|
||||
background: string;
|
||||
activeBackground: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
@@ -32,30 +33,39 @@ const TOPIC_CHIP_COLORS: Record<TopicChipPaletteColor, TopicChipColorTokens> = {
|
||||
purple: {
|
||||
border: '#d8cafe',
|
||||
background: '#f6f0ff',
|
||||
activeBackground: '#d9d1f5',
|
||||
color: '#7255d9',
|
||||
},
|
||||
blue: {
|
||||
border: '#bdd4ff',
|
||||
background: '#f0f6ff',
|
||||
activeBackground: '#bdd5f2',
|
||||
color: '#0b63ce',
|
||||
},
|
||||
green: {
|
||||
border: '#bdebcf',
|
||||
background: '#effaf3',
|
||||
activeBackground: '#c4decf',
|
||||
color: '#24834f',
|
||||
},
|
||||
orange: {
|
||||
border: '#ffd796',
|
||||
background: '#fff7e8',
|
||||
activeBackground: '#f0daba',
|
||||
color: '#c67500',
|
||||
},
|
||||
pink: {
|
||||
border: '#ffc7d7',
|
||||
background: '#fff1f5',
|
||||
activeBackground: '#f2c7d4',
|
||||
color: '#d12f61',
|
||||
},
|
||||
};
|
||||
|
||||
export const topicChipColorTokens = (
|
||||
color: TopicChipPaletteColor,
|
||||
): Readonly<TopicChipColorTokens> => TOPIC_CHIP_COLORS[color];
|
||||
|
||||
@Component({
|
||||
selector: 'app-topic-chip',
|
||||
imports: [MatIconModule, MatTooltipModule],
|
||||
@@ -111,6 +121,14 @@ export class TopicChipComponent {
|
||||
);
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-active-bg')
|
||||
get topicActiveBackground(): string {
|
||||
return (
|
||||
this.colorTokens?.activeBackground ??
|
||||
`color-mix(in srgb, ${this.topicColor} 27%, #ffffff)`
|
||||
);
|
||||
}
|
||||
|
||||
@HostBinding('style.--topic-color')
|
||||
get topicColor(): string {
|
||||
return this.colorTokens?.color ?? this.color;
|
||||
|
||||
Reference in New Issue
Block a user