Skip to content

Commit

Permalink
Merge pull request #3324 from digitalfabrik/enhancement/export_only_s…
Browse files Browse the repository at this point in the history
…elected_data_as_csv

Show only selected data in CSV export
  • Loading branch information
MizukiTemma authored Jan 10, 2025
2 parents a51f84f + bf0730a commit b439037
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions integreat_cms/release_notes/current/unreleased/3279.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en: Export only statistics for selected languages
de: Exportiere nur ausgewählte Seitenzugriffsstatistiken
7 changes: 4 additions & 3 deletions integreat_cms/static/src/js/analytics/statistics-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b439037

Please sign in to comment.