private void PopulateTeamComparisonChart()
        {
            teamComparisonEntries.Clear();
            int index = 0;

            if (Teammembers.Count > 0)
            {
                foreach (Teammember member in Teammembers)
                {
                    int g_nbr = GoalStats.GetNbrCompletedGoals(member.Goals, selectedMonth);
                    teamComparisonEntries.Add(new ChartEntry(g_nbr)
                    {
                        Label = member.FirstName + " " + member.LastName, ValueLabel = g_nbr.ToString("D"), Color = SKColor.Parse(App.donutChartColors[index])
                    });
                    index++;
                    if (index >= App.donutChartColors.Count)
                    {
                        index = 0;
                    }
                }
                chartViewTeamComparison.Chart = new DonutChart()
                {
                    Entries = teamComparisonEntries, LabelTextSize = 24
                };
            }
        }
        void PopulateStandardCharts()
        {
            goalsCompletedEntries.Clear();
            goalsCompletedEntries.Add(new ChartEntry(GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 4))
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 4), ValueLabel = GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 4).ToString(), Color = SKColor.Parse("#FF7562")
            });
            goalsCompletedEntries.Add(new ChartEntry(GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 3))
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 3), ValueLabel = GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 3).ToString(), Color = SKColor.Parse("#FF7562")
            });
            goalsCompletedEntries.Add(new ChartEntry(GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 2))
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 2), ValueLabel = GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 2).ToString(), Color = SKColor.Parse("#FF7562")
            });
            goalsCompletedEntries.Add(new ChartEntry(GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 1))
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 1), ValueLabel = GoalStats.GetNbrCompletedGoals(goals, selectedMonth + 1).ToString(), Color = SKColor.Parse("#FF7562")
            });
            goalsCompletedEntries.Add(new ChartEntry(GoalStats.GetNbrCompletedGoals(goals, selectedMonth))
            {
                Label = GoalStats.GetShortMonthName(selectedMonth), ValueLabel = GoalStats.GetNbrCompletedGoals(goals, selectedMonth).ToString(), Color = SKColor.Parse("#FF7562")
            });

            chartViewCompleted.Chart = new LineChart()
            {
                Entries = goalsCompletedEntries, LabelTextSize = 24, ValueLabelOrientation = Orientation.Horizontal
            };

            goalsCompletionEntries.Clear();
            goalsCompletionEntries.Add(new ChartEntry(GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 4) * 100)
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 4), ValueLabel = (GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 4)).ToString("F1") + "%", Color = SKColor.Parse("#FF7562")
            });
            goalsCompletionEntries.Add(new ChartEntry(GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 3) * 100)
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 3), ValueLabel = (GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 3)).ToString("F1") + "%", Color = SKColor.Parse("#FF7562")
            });
            goalsCompletionEntries.Add(new ChartEntry(GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 2) * 100)
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 2), ValueLabel = (GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 2)).ToString("F1") + "%", Color = SKColor.Parse("#FF7562")
            });
            goalsCompletionEntries.Add(new ChartEntry(GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 1) * 100)
            {
                Label = GoalStats.GetShortMonthName(selectedMonth + 1), ValueLabel = (GoalStats.GetGoalCompletionRatio(goals, selectedMonth + 1)).ToString("F1") + "%", Color = SKColor.Parse("#FF7562")
            });
            goalsCompletionEntries.Add(new ChartEntry(GoalStats.GetGoalCompletionRatio(goals, selectedMonth) * 100)
            {
                Label = GoalStats.GetShortMonthName(selectedMonth), ValueLabel = (GoalStats.GetGoalCompletionRatio(goals, selectedMonth)).ToString("F1") + "%", Color = SKColor.Parse("#FF7562")
            });

            chartViewCompletionRatio.Chart = new LineChart()
            {
                Entries = goalsCompletionEntries, LabelTextSize = 24, ValueLabelOrientation = Orientation.Horizontal
            };
        }
        private async void UpdateStats()
        {
            if (goals != null)
            {
                monthLabel.Text           = GoalStats.GetMonthName(selectedMonth);
                completionRatioLabel.Text = GoalStats.GetGoalCompletionRatio(goals, selectedMonth).ToString("F0") + "%";
                goalsCreatedLabel.Text    = GoalStats.GetNbrCreatedGoals(goals, selectedMonth).ToString();
                goalsClosedLabel.Text     = GoalStats.GetNbrClosedGoals(goals, selectedMonth).ToString();
                goalsCompletedLabel.Text  = GoalStats.GetNbrCompletedGoals(goals, selectedMonth).ToString();

                int createdChallenges = 0;
                foreach (GoalModel goal in goals)
                {
                    var challenge = (await App.client.GetTable <ChallengeModel>().Where(c => c.Id == goal.ChallengeId).ToListAsync()).FirstOrDefault();
                    if (challenge != null)
                    {
                        createdChallenges += GoalStats.GetNbrCreatedChallenges(goal, selectedMonth, challenge.OwnerId);
                    }
                }
                challengesCreatedLabel.Text = createdChallenges.ToString();
            }
        }
        private void PopulateRecurrentGoalChart(List <GoalModel> recGoal)
        {
            recurrentGoalEntries.Clear();
            recurrentGoalEntriesAck.Clear();
            List <string> participants = new List <string>();

            var count = recGoal.Count;

            count += recurrentGoalStartIndex;
            if (count > 15)
            {
                count = 15;
                recurrentGoalStartIndex--;
            }

            if (count == 0)
            {
                recurrentGoalStartIndex++;
            }

            //if (selectedTeam != null)
            //{
            //    foreach (var g in recGoal)
            //    {
            //        var user = (await App.client.GetTable<UserModel>().Where(u => u.Id == g.UserId).ToListAsync()).FirstOrDefault();
            //        participants.Add(user.FirstName + " " + user.LastName);
            //    }
            //    participantsCollectionView.ItemsSource = participants;
            //}

            int ackValue = 0;

            if (recGoal[0].WeeklyOrMonthly == 1)
            {
                for (int i = (count - 1); i >= 0; i--)
                {
                    recurrentGoalEntries.Add(new ChartEntry(GoalStats.GetRecurrentGoalResult(recGoal, i))
                    {
                        Label = GoalStats.GetShortMonthName(i), ValueLabel = (GoalStats.GetRecurrentGoalResult(recGoal, i)).ToString("D"), Color = SKColor.Parse("#FF7562")
                    });
                    ackValue += GoalStats.GetRecurrentGoalResult(recGoal, i);
                    recurrentGoalEntriesAck.Add(new ChartEntry(ackValue)
                    {
                        Label = GoalStats.GetShortMonthName(i), ValueLabel = ackValue.ToString("D"), Color = SKColor.Parse("#FF7562")
                    });
                }
            }
            else
            {
                for (int i = (count - 1); i >= 0; i--)
                {
                    recurrentGoalEntries.Add(new ChartEntry(GoalStats.GetRecurrentGoalResult(recGoal, i))
                    {
                        Label = "Week " + GoalStats.GetWeekNumber(i), ValueLabel = (GoalStats.GetRecurrentGoalResult(recGoal, i)).ToString("D"), Color = SKColor.Parse("#FF7562")
                    });
                    ackValue += GoalStats.GetRecurrentGoalResult(recGoal, i);
                    recurrentGoalEntriesAck.Add(new ChartEntry(ackValue)
                    {
                        Label = "Week " + GoalStats.GetWeekNumber(i), ValueLabel = ackValue.ToString("D"), Color = SKColor.Parse("#FF7562")
                    });
                }
            }
            if (count > 0)
            {
                chartViewRecurrentGoals.Chart = new BarChart()
                {
                    Entries = recurrentGoalEntries, LabelTextSize = 24
                };
                chartViewRecurrentGoalsAck.Chart = new LineChart()
                {
                    Entries = recurrentGoalEntriesAck, LabelTextSize = 24
                };
            }
        }