From 8a5a805588a49a8cc74306b61ced9c375eb5a2e6 Mon Sep 17 00:00:00 2001 From: pererinha Date: Fri, 27 Dec 2013 15:02:12 -0200 Subject: [PATCH] partial #2252 - Historical Churn and Historical Churn Rate --- include/library/Crunchbutton/Chart/Churn.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/library/Crunchbutton/Chart/Churn.php b/include/library/Crunchbutton/Chart/Churn.php index 19e6d29c3..6564f8f4b 100644 --- a/include/library/Crunchbutton/Chart/Churn.php +++ b/include/library/Crunchbutton/Chart/Churn.php @@ -82,7 +82,12 @@ class Crunchbutton_Chart_Churn extends Crunchbutton_Chart { $activeForwardDaysPlusOne = $activeUsers[ ( $i + $daysForward + 1 ) ]->Total; $newForwardDays = $newUsers[ ( $i + $daysForward ) ]->Total; $newForwardDaysPlusOne = $newUsers[ ( $i + $daysForward + 1 ) ]->Total; - $churn = ( ( $activeForwardDays + $newForwardDaysPlusOne ) - $activeForwardDaysPlusOne ); + if( $activeForwardDaysPlusOne > 0 ){ + $churn = ( ( $activeForwardDays + $newForwardDaysPlusOne ) - $activeForwardDaysPlusOne ); + } else { + $churn = 0; + } + $data[] = ( object ) array( 'Label' => $activeUsers[ $i ]->Label, 'Total' => $churn, 'Type' => 'Users' ); }