Skip to content

Commit 753682d

Browse files
Mattia VianelliAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2025_02_x/DSC-2702 (pull request DSpace#4058)
DSC-2702 Created box that is shown instead of the pie chart in statistics categories tab if there is no data Approved-by: Andrea Barbasso
2 parents 52aad49 + 97d53eb commit 753682d

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

src/app/statistics-page/cris-statistics-page/statistics-chart/statistics-chart-pie/statistics-chart-pie.component.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@
2020
}
2121

2222
@if ((results | async) && (results | async).length > 0) {
23-
<div #chartRef id="chart" class="d-flex w-100 search-chart-container">
24-
<ds-chart [results]="results" [view]="view" [type]='chartType.PIE' [animations]="true"></ds-chart>
25-
</div>
23+
@let res = results | async;
24+
@if (hasNonZeroValues(res)) {
25+
<div #chartRef id="chart" class="d-flex w-100 search-chart-container">
26+
<ds-chart [results]="results" [view]="view" [type]='chartType.PIE' [animations]="true"></ds-chart>
27+
</div>
28+
} @else {
29+
<div class="no-data-message">
30+
<i class="fas fa-chart-pie fa-4x no-data-icon"></i><br>
31+
<h4 class="no-data-title">{{ 'chart.no-data.title' | translate }}</h4>
32+
</div>
33+
}
2634
} @else {
2735
<ds-alert [type]="'alert-info'" [content]="'search.filters.applied.charts.no.data.found'"></ds-alert>
2836
}

src/app/statistics-page/cris-statistics-page/statistics-chart/statistics-chart-pie/statistics-chart-pie.component.scss

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,33 @@
55
.export-buttons-container{
66
display:flex;
77
justify-content:flex-end;
8-
}
8+
}
9+
10+
.no-data-message {
11+
display: flex;
12+
flex-direction: column;
13+
align-items: center;
14+
justify-content: center;
15+
padding: 40px 20px;
16+
text-align: center;
17+
color: #666;
18+
border: 1px solid #ddd;
19+
background: #f9f9f9;
20+
border-radius: 8px;
21+
height: 400px;
22+
}
23+
24+
.no-data-icon {
25+
color: #ccc;
26+
margin-bottom: 15px;
27+
}
28+
29+
.no-data-title {
30+
margin: 10px 0;
31+
color: #555;
32+
}
33+
34+
.no-data-description {
35+
margin: 10px 0;
36+
color: #777;
37+
}

src/app/statistics-page/cris-statistics-page/statistics-chart/statistics-chart-pie/statistics-chart-pie.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ export class StatisticsChartPieComponent extends StatisticsChartDataComponent {
7474
));
7575
}
7676

77+
/**
78+
* Check if the data has any non-zero values
79+
*/
80+
public hasNonZeroValues(data: any[]): boolean {
81+
if (!data || data.length === 0) {
82+
return false;
83+
}
84+
return data.some(item => item && item.value && item.value > 0);
85+
}
86+
7787
}

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,8 @@
14091409

14101410
"chart.load-more": "Load more results",
14111411

1412+
"chart.no-data.title": "No Data Available",
1413+
14121414
"claimed-approved-search-result-list-element.title": "Approved",
14131415

14141416
"claimed-declined-search-result-list-element.title": "Rejected, sent back to submitter",

src/assets/i18n/it.json5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,9 @@
22702270
// "chart.load-more": "Load more results",
22712271
"chart.load-more": "Carica più risultati",
22722272

2273+
//"chart.no-data.title": "No Data Available",
2274+
"chart.no-data.title": "Data Non Disponibile",
2275+
22732276
// "claimed-approved-search-result-list-element.title": "Approved",
22742277
"claimed-approved-search-result-list-element.title": "Approvato",
22752278

0 commit comments

Comments
 (0)