Skip to content

Commit b439037

Browse files
authored
Merge pull request #3324 from digitalfabrik/enhancement/export_only_selected_data_as_csv
Show only selected data in CSV export
2 parents a51f84f + bf0730a commit b439037

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
en: Export only statistics for selected languages
2+
de: Exportiere nur ausgewählte Seitenzugriffsstatistiken

integreat_cms/static/src/js/analytics/statistics-charts.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ const exportStatisticsData = (): void => {
181181
downloadFile(`${filename}.png`, image);
182182
} else if (exportFormat.value === "csv") {
183183
// Convert datasets into the format [["language 1", "hits on day 1", "hits 2", ...], [["language 1", "hits on day 1", ...], ...]
184-
const datasetsWithLabels: string[][] = chart.data.datasets.map((dataset) =>
185-
[dataset.label].concat(dataset.data.map(String))
186-
);
184+
const datasets = chart.data.datasets;
185+
const datasetsWithLabels: string[][] = datasets
186+
.filter((dataset) => chart.isDatasetVisible(datasets.indexOf(dataset)))
187+
.map((dataset) => [dataset.label].concat(dataset.data.map(String)));
187188
// Ensure export labels don't contain comma and corrupt CSV
188189
exportLabels = exportLabels.map((x) => x.replace(",", " - "));
189190
// Create matrix with date labels in the first row and the hits per language in the subsequent rows

0 commit comments

Comments
 (0)