Skip to content

Commit 07178fd

Browse files
author
Melih Korkmaz
committed
Fixed NaN for loyalty table.
1 parent b80cee3 commit 07178fd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

frontend/express/public/javascripts/countly/countly.views.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,17 @@ window.LoyaltyView = countlyView.extend({
268268
for (var iTick = 1; iTick < ticks.length - 1; iTick++) {
269269
var all = dp[0].data[iTick][1] ? countlyCommon.formatNumber(dp[0].data[iTick][1]) : 0;
270270
var allPercentage = countlyCommon.formatNumber((100 * all) / totals[0], 2);
271+
allPercentage = isNaN(allPercentage) ? 0 : allPercentage;
271272

272-
var tDays = dp[1].data[iTick][1] ? countlyCommon.formatNumber(dp[1].data[iTick][1]) : 0;
273+
var tDays = (dp[1].data[iTick] && dp[1].data[iTick][1]) ? countlyCommon.formatNumber(dp[1].data[iTick][1]) : 0;
273274
var tDaysPercentage = countlyCommon.formatNumber((100 * tDays) / totals[1], 2);
274-
275-
var sDays = dp[2].data[iTick][1] ? countlyCommon.formatNumber(dp[2].data[iTick][1]) : 0;
275+
tDaysPercentage = isNaN(tDaysPercentage) ? 0 : tDaysPercentage;
276+
277+
var sDays = (dp[2].data[iTick] && dp[2].data[iTick][1]) ? countlyCommon.formatNumber(dp[2].data[iTick][1]) : 0;
276278
var sDaysPercentage = countlyCommon.formatNumber((100 * sDays) / totals[2], 2);
279+
sDaysPercentage = isNaN(sDaysPercentage) ? 0 : sDaysPercentage;
277280

281+
278282
chartData.push({
279283
l: ticks[iTick][1],
280284
a: "<div style='float:left;min-width: 40px'>" + all + "</div><div class='percent-bar' style='width:" + (allPercentage * 0.8) + "%'></div>" + allPercentage + "%",

0 commit comments

Comments
 (0)