diff --git a/integreat_cms/release_notes/current/unreleased/3279.yml b/integreat_cms/release_notes/current/unreleased/3279.yml new file mode 100644 index 0000000000..6e6168f2a0 --- /dev/null +++ b/integreat_cms/release_notes/current/unreleased/3279.yml @@ -0,0 +1,2 @@ +en: Export only statistics for selected languages +de: Exportiere nur ausgewählte Seitenzugriffsstatistiken diff --git a/integreat_cms/static/src/js/analytics/statistics-charts.ts b/integreat_cms/static/src/js/analytics/statistics-charts.ts index 1d32dec86d..c954179d3f 100644 --- a/integreat_cms/static/src/js/analytics/statistics-charts.ts +++ b/integreat_cms/static/src/js/analytics/statistics-charts.ts @@ -181,9 +181,10 @@ const exportStatisticsData = (): void => { downloadFile(`${filename}.png`, image); } else if (exportFormat.value === "csv") { // Convert datasets into the format [["language 1", "hits on day 1", "hits 2", ...], [["language 1", "hits on day 1", ...], ...] - const datasetsWithLabels: string[][] = chart.data.datasets.map((dataset) => - [dataset.label].concat(dataset.data.map(String)) - ); + const datasets = chart.data.datasets; + const datasetsWithLabels: string[][] = datasets + .filter((dataset) => chart.isDatasetVisible(datasets.indexOf(dataset))) + .map((dataset) => [dataset.label].concat(dataset.data.map(String))); // Ensure export labels don't contain comma and corrupt CSV exportLabels = exportLabels.map((x) => x.replace(",", " - ")); // Create matrix with date labels in the first row and the hits per language in the subsequent rows