From 3a04443632ba2127c16868ec275db457714f433f Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Wed, 28 Aug 2024 19:24:57 +0800 Subject: [PATCH] FIX: Sum pageviews with number instead of string (#28596) When the tooltip items are tooltipItem = [{parsed: {y:12} }, {parsed: {y:10} } ], reducing without a initial value as a number would result in Javascript thinking it is a string. Thanks, Javascript! There are no tests here yet since this makes use of an external library Chart.js. --- .../admin/addon/components/admin-report-stacked-chart.gjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs b/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs index fd3af019a5b..8a7e2df0973 100644 --- a/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-report-stacked-chart.gjs @@ -42,7 +42,8 @@ export default class AdminReportStackedChart extends Component { callbacks: { beforeFooter: (tooltipItem) => { const total = tooltipItem.reduce( - (sum, item) => sum + parseInt(item.parsed.y || 0, 10) + (sum, item) => sum + parseInt(item.parsed.y || 0, 10), + 0 ); return `= ${total}`; },