Skip to content

Commit

Permalink
Show only selected data in CSV export
Browse files Browse the repository at this point in the history
Co-authored-by: JoeyStk <72705147+JoeyStk@users.noreply.github.com>
  • Loading branch information
2 people authored and charludo committed Jan 13, 2025
1 parent 739a2cf commit e4698a1
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 e4698a1

Please sign in to comment.