This commit is contained in:
@@ -18,6 +18,22 @@ class DashboardStatisticValue(BaseModel):
|
||||
value: int
|
||||
|
||||
|
||||
class EuProjectStatusStatistics(BaseModel):
|
||||
institution_id: str
|
||||
organization_name: str
|
||||
ongoing: int
|
||||
upcoming: int
|
||||
completed: int
|
||||
|
||||
|
||||
class BmbfProjectStatusStatistics(BaseModel):
|
||||
institution_id: str
|
||||
organization_name: str
|
||||
ongoing: int
|
||||
upcoming: int
|
||||
completed: int
|
||||
|
||||
|
||||
class DfgProjectTopic(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
|
||||
@@ -9,18 +9,22 @@ from inse.database import get_session
|
||||
from inse.tags import Tags
|
||||
|
||||
from .model import (
|
||||
BmbfProjectStatusStatistics,
|
||||
DashboardStatisticValue,
|
||||
DashboardStatistics,
|
||||
DfgProjectTopics,
|
||||
EuProjectStatusStatistics,
|
||||
TopAuthorStatistics,
|
||||
TopicHeatmap,
|
||||
TopicWordCloud,
|
||||
)
|
||||
from .service import (
|
||||
get_dashboard_bmbf_project_statuses,
|
||||
get_dashboard_bmbf_projects,
|
||||
get_dashboard_dfg_projects,
|
||||
get_dashboard_dfg_topics,
|
||||
get_dashboard_eu_projects,
|
||||
get_dashboard_eu_project_statuses,
|
||||
get_dashboard_organization,
|
||||
get_dashboard_patents,
|
||||
get_dashboard_persons,
|
||||
@@ -114,6 +118,22 @@ async def dashboard_eu_projects(
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/projects/eu/status",
|
||||
operation_id="getDashboardEuProjectStatuses",
|
||||
response_model=EuProjectStatusStatistics,
|
||||
)
|
||||
async def dashboard_eu_project_statuses(
|
||||
session: Session = Depends(get_session),
|
||||
access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep,
|
||||
) -> EuProjectStatusStatistics:
|
||||
organization = get_dashboard_organization(session, access_token)
|
||||
return await get_dashboard_eu_project_statuses(
|
||||
organization.openalex_institution_id,
|
||||
organization.name,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/statistics/projects/bmbf",
|
||||
operation_id="getDashboardBmbfProjects",
|
||||
@@ -130,6 +150,22 @@ async def dashboard_bmbf_projects(
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/projects/bmbf/status",
|
||||
operation_id="getDashboardBmbfProjectStatuses",
|
||||
response_model=BmbfProjectStatusStatistics,
|
||||
)
|
||||
async def dashboard_bmbf_project_statuses(
|
||||
session: Session = Depends(get_session),
|
||||
access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep,
|
||||
) -> BmbfProjectStatusStatistics:
|
||||
organization = get_dashboard_organization(session, access_token)
|
||||
return await get_dashboard_bmbf_project_statuses(
|
||||
organization.openalex_institution_id,
|
||||
organization.name,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/statistics/projects/dfg",
|
||||
operation_id="getDashboardDfgProjects",
|
||||
|
||||
@@ -15,10 +15,12 @@ from inse.patents.org.elastic_search_client import OrgPatentsSearchClient
|
||||
|
||||
from .institute_helper import get_openalex_institution
|
||||
from .model import (
|
||||
BmbfProjectStatusStatistics,
|
||||
DashboardStatisticValue,
|
||||
DashboardStatistics,
|
||||
DfgProjectTopic,
|
||||
DfgProjectTopics,
|
||||
EuProjectStatusStatistics,
|
||||
TopAuthor,
|
||||
TopAuthorStatistics,
|
||||
TopicHeatmap,
|
||||
@@ -234,6 +236,86 @@ async def get_dashboard_eu_projects(
|
||||
)
|
||||
|
||||
|
||||
async def get_dashboard_eu_project_statuses(
|
||||
institution_id: str,
|
||||
organization_name: str,
|
||||
) -> EuProjectStatusStatistics:
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||
project_ids: set[str] = set()
|
||||
|
||||
async for hit in elasticsearch.scan(
|
||||
index=str(ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD),
|
||||
query=_eu_organization_query(aliases),
|
||||
source=["projectID"],
|
||||
page_size=1000,
|
||||
cluster=ESCluster.INSE,
|
||||
):
|
||||
project_id = hit.get("_source", {}).get("projectID")
|
||||
if project_id is not None:
|
||||
project_ids.add(str(project_id))
|
||||
|
||||
if not project_ids:
|
||||
return EuProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=0,
|
||||
upcoming=0,
|
||||
completed=0,
|
||||
)
|
||||
|
||||
today = datetime.now().date().isoformat()
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.CORDIS_EU_PROJECTS_WILDCARD,
|
||||
body={
|
||||
"size": 0,
|
||||
"query": {"terms": {"id": sorted(project_ids)}},
|
||||
"aggs": {
|
||||
"ongoing": {
|
||||
"filter": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"range": {"startDate": {"lte": today}}},
|
||||
{"range": {"endDate": {"gte": today}}},
|
||||
]
|
||||
}
|
||||
},
|
||||
"aggs": {
|
||||
"projects": {"cardinality": {"field": "id"}}
|
||||
},
|
||||
},
|
||||
"upcoming": {
|
||||
"filter": {"range": {"startDate": {"gt": today}}},
|
||||
"aggs": {
|
||||
"projects": {"cardinality": {"field": "id"}}
|
||||
},
|
||||
},
|
||||
"completed": {
|
||||
"filter": {"range": {"endDate": {"lt": today}}},
|
||||
"aggs": {
|
||||
"projects": {"cardinality": {"field": "id"}}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
aggregations = response.get("aggregations", {})
|
||||
return EuProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=_project_status_count(aggregations, "ongoing"),
|
||||
upcoming=_project_status_count(aggregations, "upcoming"),
|
||||
completed=_project_status_count(aggregations, "completed"),
|
||||
)
|
||||
|
||||
|
||||
def _project_status_count(aggregations: dict[str, Any], status_name: str) -> int:
|
||||
return int(
|
||||
aggregations.get(status_name, {}).get("projects", {}).get("value", 0)
|
||||
)
|
||||
|
||||
|
||||
async def get_dashboard_bmbf_projects(
|
||||
institution_id: str,
|
||||
organization_name: str,
|
||||
@@ -250,6 +332,57 @@ async def get_dashboard_bmbf_projects(
|
||||
return _dashboard_statistic_value(normalized_id, organization_name, response)
|
||||
|
||||
|
||||
async def get_dashboard_bmbf_project_statuses(
|
||||
institution_id: str,
|
||||
organization_name: str,
|
||||
) -> BmbfProjectStatusStatistics:
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||
today = datetime.now().strftime("%d.%m.%Y")
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_BUND_V1,
|
||||
body={
|
||||
"size": 0,
|
||||
"query": _alias_match_query("Zuwendungsempfänger", aliases),
|
||||
"aggs": _project_status_filter_aggregations(
|
||||
start_field="funding_start",
|
||||
end_field="funding_end",
|
||||
today=today,
|
||||
),
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
aggregations = response.get("aggregations", {})
|
||||
return BmbfProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=int(aggregations.get("ongoing", {}).get("doc_count", 0)),
|
||||
upcoming=int(aggregations.get("upcoming", {}).get("doc_count", 0)),
|
||||
completed=int(aggregations.get("completed", {}).get("doc_count", 0)),
|
||||
)
|
||||
|
||||
|
||||
def _project_status_filter_aggregations(
|
||||
start_field: str,
|
||||
end_field: str,
|
||||
today: str,
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"ongoing": {
|
||||
"filter": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{"range": {start_field: {"lte": today}}},
|
||||
{"range": {end_field: {"gte": today}}},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"upcoming": {"filter": {"range": {start_field: {"gt": today}}}},
|
||||
"completed": {"filter": {"range": {end_field: {"lt": today}}}},
|
||||
}
|
||||
|
||||
|
||||
async def get_dashboard_dfg_projects(
|
||||
institution_id: str,
|
||||
organization_name: str,
|
||||
|
||||
@@ -8,8 +8,10 @@ from sqlmodel import Session, SQLModel, create_engine
|
||||
from inse import config
|
||||
from inse.auth.model import AccessToken, Organization, UserRole
|
||||
from inse.dashboard.service import (
|
||||
get_dashboard_bmbf_project_statuses,
|
||||
get_dashboard_organization,
|
||||
get_dashboard_dfg_topics,
|
||||
get_dashboard_eu_project_statuses,
|
||||
get_dashboard_patents,
|
||||
get_dashboard_statistics,
|
||||
get_top_authors,
|
||||
@@ -43,6 +45,109 @@ async def test_dashboard_patents_uses_org_patent_total():
|
||||
search.assert_awaited_once_with(ORG_INSTITUTION_ID, page=0, size=0)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_eu_project_statuses_deduplicates_projects():
|
||||
async def scan(**kwargs):
|
||||
assert kwargs["index"] == str(ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD)
|
||||
assert kwargs["source"] == ["projectID"]
|
||||
yield {"_source": {"projectID": "P2"}}
|
||||
yield {"_source": {"projectID": "P1"}}
|
||||
yield {"_source": {"projectID": "P1"}}
|
||||
|
||||
response = {
|
||||
"aggregations": {
|
||||
"ongoing": {"projects": {"value": 2}},
|
||||
"upcoming": {"projects": {"value": 1}},
|
||||
"completed": {"projects": {"value": 7}},
|
||||
}
|
||||
}
|
||||
with patch(
|
||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||
new=AsyncMock(return_value=["Example University"]),
|
||||
), patch("inse.dashboard.service.elasticsearch.scan", new=scan), patch(
|
||||
"inse.dashboard.service.elasticsearch.search",
|
||||
new=AsyncMock(return_value=response),
|
||||
) as search:
|
||||
result = await get_dashboard_eu_project_statuses(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
)
|
||||
|
||||
assert result.model_dump() == {
|
||||
"institution_id": ORG_INSTITUTION_ID,
|
||||
"organization_name": "Example Org",
|
||||
"ongoing": 2,
|
||||
"upcoming": 1,
|
||||
"completed": 7,
|
||||
}
|
||||
call = search.await_args
|
||||
assert call.kwargs["index"] == ESIndex.CORDIS_EU_PROJECTS_WILDCARD
|
||||
assert call.kwargs["body"]["query"] == {
|
||||
"terms": {"id": ["P1", "P2"]}
|
||||
}
|
||||
today = datetime.now().date().isoformat()
|
||||
aggregations = call.kwargs["body"]["aggs"]
|
||||
assert aggregations["ongoing"]["filter"]["bool"]["filter"] == [
|
||||
{"range": {"startDate": {"lte": today}}},
|
||||
{"range": {"endDate": {"gte": today}}},
|
||||
]
|
||||
assert aggregations["upcoming"]["filter"] == {
|
||||
"range": {"startDate": {"gt": today}}
|
||||
}
|
||||
assert aggregations["completed"]["filter"] == {
|
||||
"range": {"endDate": {"lt": today}}
|
||||
}
|
||||
assert all(
|
||||
aggregation["aggs"]["projects"]["cardinality"]["field"] == "id"
|
||||
for aggregation in aggregations.values()
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_bmbf_project_statuses_uses_funding_dates():
|
||||
response = {
|
||||
"aggregations": {
|
||||
"ongoing": {"doc_count": 4},
|
||||
"upcoming": {"doc_count": 2},
|
||||
"completed": {"doc_count": 19},
|
||||
}
|
||||
}
|
||||
with patch(
|
||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||
new=AsyncMock(return_value=["Example University"]),
|
||||
), patch(
|
||||
"inse.dashboard.service.elasticsearch.search",
|
||||
new=AsyncMock(return_value=response),
|
||||
) as search:
|
||||
result = await get_dashboard_bmbf_project_statuses(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
)
|
||||
|
||||
assert result.model_dump() == {
|
||||
"institution_id": ORG_INSTITUTION_ID,
|
||||
"organization_name": "Example Org",
|
||||
"ongoing": 4,
|
||||
"upcoming": 2,
|
||||
"completed": 19,
|
||||
}
|
||||
call = search.await_args
|
||||
assert call.kwargs["index"] == ESIndex.PROJECTS_BUND_V1
|
||||
assert call.kwargs["body"]["query"]["bool"]["minimum_should_match"] == 1
|
||||
today = datetime.now().strftime("%d.%m.%Y")
|
||||
aggregations = call.kwargs["body"]["aggs"]
|
||||
assert aggregations["ongoing"]["filter"]["bool"]["filter"] == [
|
||||
{"range": {"funding_start": {"lte": today}}},
|
||||
{"range": {"funding_end": {"gte": today}}},
|
||||
]
|
||||
assert aggregations["upcoming"]["filter"] == {
|
||||
"range": {"funding_start": {"gt": today}}
|
||||
}
|
||||
assert aggregations["completed"]["filter"] == {
|
||||
"range": {"funding_end": {"lt": today}}
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
||||
async def search(**kwargs):
|
||||
|
||||
@@ -24,6 +24,22 @@ export interface DashboardStatisticValue {
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface EuProjectStatusStatistics {
|
||||
institution_id: string;
|
||||
organization_name: string;
|
||||
ongoing: number;
|
||||
upcoming: number;
|
||||
completed: number;
|
||||
}
|
||||
|
||||
export interface BmbfProjectStatusStatistics {
|
||||
institution_id: string;
|
||||
organization_name: string;
|
||||
ongoing: number;
|
||||
upcoming: number;
|
||||
completed: number;
|
||||
}
|
||||
|
||||
export interface DfgProjectTopic {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -137,6 +153,18 @@ export class DashboardStatisticsService {
|
||||
);
|
||||
}
|
||||
|
||||
getEuProjectStatuses(): Observable<EuProjectStatusStatistics> {
|
||||
return this.httpClient.get<EuProjectStatusStatistics>(
|
||||
`${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/eu/status`,
|
||||
);
|
||||
}
|
||||
|
||||
getBmbfProjectStatuses(): Observable<BmbfProjectStatusStatistics> {
|
||||
return this.httpClient.get<BmbfProjectStatusStatistics>(
|
||||
`${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/bmbf/status`,
|
||||
);
|
||||
}
|
||||
|
||||
getBmbfProjectCount(): Observable<DashboardStatisticValue> {
|
||||
return this.httpClient.get<DashboardStatisticValue>(
|
||||
`${this.apiConfiguration?.basePath ?? ''}/api/dashboard/statistics/projects/bmbf`,
|
||||
|
||||
@@ -129,6 +129,63 @@
|
||||
<p class="statistics-error">Die Kennzahlen konnten nicht geladen werden.</p>
|
||||
}
|
||||
|
||||
@if (
|
||||
euProjectStatusesLoading ||
|
||||
bmbfProjectStatusesLoading ||
|
||||
euProjectStatusesError ||
|
||||
bmbfProjectStatusesError ||
|
||||
(euProjectStatuses && bmbfProjectStatuses)
|
||||
) {
|
||||
<section class="topic-heatmap-section">
|
||||
<header class="topic-heatmap-header">
|
||||
<div>
|
||||
<h2>Projektstatus nach Fördergeber</h2>
|
||||
<p>
|
||||
Laufende, kommende und abgeschlossene EU- und Bund-Projekte Ihrer Organisation.
|
||||
</p>
|
||||
</div>
|
||||
@if (euProjectStatuses && bmbfProjectStatuses) {
|
||||
<div class="project-status-summary">
|
||||
<span>
|
||||
EU:
|
||||
{{
|
||||
euProjectStatuses.ongoing +
|
||||
euProjectStatuses.upcoming +
|
||||
euProjectStatuses.completed | number
|
||||
}}
|
||||
</span>
|
||||
<span>
|
||||
Bund:
|
||||
{{
|
||||
bmbfProjectStatuses.ongoing +
|
||||
bmbfProjectStatuses.upcoming +
|
||||
bmbfProjectStatuses.completed | number
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
</header>
|
||||
|
||||
@if (euProjectStatusesLoading || bmbfProjectStatusesLoading) {
|
||||
<div class="project-status-loading" role="status" aria-live="polite">
|
||||
<app-loading
|
||||
text="Projektstatus wird geladen …"
|
||||
icon="stacked_bar_chart"
|
||||
size="64"
|
||||
diameter="64"></app-loading>
|
||||
</div>
|
||||
} @else if (euProjectStatusesError || bmbfProjectStatusesError) {
|
||||
<p class="statistics-error">
|
||||
Der Status der EU- und Bund-Projekte konnte nicht geladen werden.
|
||||
</p>
|
||||
} @else if (euProjectStatuses && bmbfProjectStatuses) {
|
||||
<app-eu-project-status-chart
|
||||
[statuses]="euProjectStatuses"
|
||||
[bmbfStatuses]="bmbfProjectStatuses"></app-eu-project-status-chart>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (topicHeatmapLoading || topicHeatmapError || hasTopicHeatmapData()) {
|
||||
<section class="topic-heatmap-section">
|
||||
<header class="topic-heatmap-header">
|
||||
|
||||
@@ -144,6 +144,27 @@
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.project-status-loading {
|
||||
min-height: 15rem;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.project-status-summary {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
gap: 0.5rem;
|
||||
|
||||
span {
|
||||
padding: 0.35rem 0.65rem;
|
||||
border-radius: 999px;
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.dfg-topic-summary {
|
||||
flex: 0 0 auto;
|
||||
color: #475569;
|
||||
|
||||
@@ -5,13 +5,16 @@ import { Observable, finalize } from 'rxjs';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { TopicHeatmapComponent } from './topic-heatmap/topic-heatmap.component';
|
||||
import { DfgTopicDonutComponent } from './dfg-topic-donut/dfg-topic-donut.component';
|
||||
import { EuProjectStatusChartComponent } from './eu-project-status-chart/eu-project-status-chart.component';
|
||||
import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import {
|
||||
BmbfProjectStatusStatistics,
|
||||
DashboardStatisticValue,
|
||||
DashboardStatistics,
|
||||
DashboardStatisticsService,
|
||||
DfgProjectTopics,
|
||||
EuProjectStatusStatistics,
|
||||
TopAuthor,
|
||||
TopAuthorStatistics,
|
||||
TopAuthorsWorksPeriod,
|
||||
@@ -32,6 +35,7 @@ type DashboardStatisticKey =
|
||||
RouterLink,
|
||||
LoadingComponent,
|
||||
DfgTopicDonutComponent,
|
||||
EuProjectStatusChartComponent,
|
||||
TopicHeatmapComponent,
|
||||
YearRangeSliderComponent,
|
||||
],
|
||||
@@ -69,6 +73,12 @@ export class DashboardComponent implements OnInit {
|
||||
dfgProjectTopics?: DfgProjectTopics;
|
||||
dfgTopicsLoading = false;
|
||||
dfgTopicsError = false;
|
||||
euProjectStatuses?: EuProjectStatusStatistics;
|
||||
euProjectStatusesLoading = false;
|
||||
euProjectStatusesError = false;
|
||||
bmbfProjectStatuses?: BmbfProjectStatusStatistics;
|
||||
bmbfProjectStatusesLoading = false;
|
||||
bmbfProjectStatusesError = false;
|
||||
readonly topicTreemapMinYear = 1900;
|
||||
readonly topicTreemapMaxYear = new Date().getFullYear();
|
||||
topicTreemapFromYear = this.topicTreemapMaxYear - 4;
|
||||
@@ -89,6 +99,8 @@ export class DashboardComponent implements OnInit {
|
||||
this.loadTopAuthors();
|
||||
this.loadTopicHeatmap();
|
||||
this.loadDfgProjectTopics();
|
||||
this.loadEuProjectStatuses();
|
||||
this.loadBmbfProjectStatuses();
|
||||
}
|
||||
|
||||
private loadStatistics(): void {
|
||||
@@ -326,6 +338,38 @@ export class DashboardComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private loadEuProjectStatuses(): void {
|
||||
this.euProjectStatusesLoading = true;
|
||||
this.euProjectStatusesError = false;
|
||||
this.statisticsService
|
||||
.getEuProjectStatuses()
|
||||
.pipe(finalize(() => (this.euProjectStatusesLoading = false)))
|
||||
.subscribe({
|
||||
next: (statuses) => {
|
||||
this.euProjectStatuses = statuses;
|
||||
},
|
||||
error: () => {
|
||||
this.euProjectStatusesError = true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private loadBmbfProjectStatuses(): void {
|
||||
this.bmbfProjectStatusesLoading = true;
|
||||
this.bmbfProjectStatusesError = false;
|
||||
this.statisticsService
|
||||
.getBmbfProjectStatuses()
|
||||
.pipe(finalize(() => (this.bmbfProjectStatusesLoading = false)))
|
||||
.subscribe({
|
||||
next: (statuses) => {
|
||||
this.bmbfProjectStatuses = statuses;
|
||||
},
|
||||
error: () => {
|
||||
this.bmbfProjectStatusesError = true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private loadTopicHeatmap(): void {
|
||||
if (this.topicTreemapFromYear > this.topicTreemapToYear) {
|
||||
this.topicHeatmapLoading = false;
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<div
|
||||
echarts
|
||||
[options]="options"
|
||||
class="eu-project-status-chart"
|
||||
role="img"
|
||||
aria-label="Gestapeltes Balkendiagramm zum Status der EU- und Bund-Projekte"></div>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
.eu-project-status-chart {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
import { Component, Input, OnChanges } from '@angular/core';
|
||||
import { EChartsOption } from 'echarts';
|
||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||
|
||||
import {
|
||||
BmbfProjectStatusStatistics,
|
||||
EuProjectStatusStatistics,
|
||||
} from '../dashboard-statistics.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-eu-project-status-chart',
|
||||
imports: [NgxEchartsDirective],
|
||||
templateUrl: './eu-project-status-chart.component.html',
|
||||
styleUrl: './eu-project-status-chart.component.scss',
|
||||
})
|
||||
export class EuProjectStatusChartComponent implements OnChanges {
|
||||
@Input({ required: true }) statuses!: EuProjectStatusStatistics;
|
||||
@Input({ required: true }) bmbfStatuses!: BmbfProjectStatusStatistics;
|
||||
|
||||
options: EChartsOption = {};
|
||||
|
||||
ngOnChanges(): void {
|
||||
const values = [
|
||||
{
|
||||
name: 'Laufend',
|
||||
data: [
|
||||
this.statuses?.ongoing ?? 0,
|
||||
this.bmbfStatuses?.ongoing ?? 0,
|
||||
],
|
||||
color: '#2563eb',
|
||||
},
|
||||
{
|
||||
name: 'Kommend',
|
||||
data: [
|
||||
this.statuses?.upcoming ?? 0,
|
||||
this.bmbfStatuses?.upcoming ?? 0,
|
||||
],
|
||||
color: '#f59e0b',
|
||||
},
|
||||
{
|
||||
name: 'Abgeschlossen',
|
||||
data: [
|
||||
this.statuses?.completed ?? 0,
|
||||
this.bmbfStatuses?.completed ?? 0,
|
||||
],
|
||||
color: '#64748b',
|
||||
},
|
||||
];
|
||||
|
||||
this.options = {
|
||||
color: values.map((item) => item.color),
|
||||
animationDuration: 500,
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
confine: true,
|
||||
valueFormatter: (value) =>
|
||||
`${Number(value ?? 0).toLocaleString('de-DE')} Projekte`,
|
||||
},
|
||||
legend: {
|
||||
top: 0,
|
||||
left: 'center',
|
||||
data: values.map((item) => item.name),
|
||||
textStyle: { color: '#334155' },
|
||||
},
|
||||
grid: { top: 56, right: 24, bottom: 30, left: 24, containLabel: true },
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
minInterval: 1,
|
||||
name: 'Anzahl Projekte',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 28,
|
||||
axisLabel: { color: '#64748b' },
|
||||
splitLine: { lineStyle: { color: '#e2e8f0' } },
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: ['EU-Projekte', 'Bund-Projekte'],
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: false },
|
||||
axisLabel: { color: '#334155', fontWeight: 600 },
|
||||
},
|
||||
series: values.map((item, index) => ({
|
||||
name: item.name,
|
||||
type: 'bar',
|
||||
stack: 'status',
|
||||
barWidth: 54,
|
||||
data: item.data,
|
||||
label: {
|
||||
show: true,
|
||||
position: 'inside',
|
||||
formatter: (params) =>
|
||||
Number(params.value ?? 0) > 0 ? String(params.value) : '',
|
||||
color: '#ffffff',
|
||||
fontWeight: 700,
|
||||
},
|
||||
itemStyle: {
|
||||
borderRadius:
|
||||
index === 0
|
||||
? [6, 0, 0, 6]
|
||||
: index === values.length - 1
|
||||
? [0, 6, 6, 0]
|
||||
: 0,
|
||||
},
|
||||
})),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user