mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 06:52:46 +08:00
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.
This commit is contained in:
parent
480f26a2c2
commit
3a04443632
|
@ -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}`;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user