public LineChart SetupChartData(DateTime startDate, DateTime endDate) { //when first entered into this activity the default is the past weeks data, so we need to get that Globals dbHelp = null; try { if (_lineChart != null) { Log.Info(TAG, "SetupChartData: Found _progressChart"); DateTime loopDate = startDate; //this next array will contain the string labels for the X axis, which is the date of the point List <string> pointsDates = new List <string>(); if (GlobalData.MoodListItems != null) { dbHelp = new Globals(); dbHelp.OpenDatabase(); LineDataSet moodDataSet = null; List <ILineDataSet> moodLineDataSets = new List <ILineDataSet>(); var daysDifference = endDate.Subtract(startDate).Days; Log.Info(TAG, "SetupChartData: Attempting to get " + daysDifference.ToString() + " days data from " + startDate.ToShortDateString() + " to " + endDate.ToShortDateString()); for (var a = 0; a <= daysDifference; a++) { pointsDates.Add(loopDate.ToShortDateString()); Log.Info(TAG, "SetupChartData: Added '" + loopDate.ToShortDateString() + " to date list"); loopDate = loopDate.AddDays(1); } Log.Info(TAG, "SetupChartData: MoodListItems global list contains " + GlobalData.MoodListItems.Count.ToString() + " items"); foreach (var item in GlobalData.MoodListItems) { Log.Info(TAG, "SetupChartData: Attempting to retrieve data points for " + item.MoodName.Trim()); moodDataSet = GetDataPoints(item.MoodId, startDate, endDate, item.MoodName); if (moodDataSet != null) { int[] colorList = new int[1] { GlobalData.ColourList[item.MoodId - 1] }; moodDataSet.SetColors(colorList); moodLineDataSets.Add(moodDataSet); Log.Info(TAG, "SetupChartData: Added " + item.MoodName + " to data sets list"); } else { Log.Info(TAG, "SetupChartData: No data set returned for " + item.MoodName + "!"); } } LineData moodLineData = new LineData(pointsDates, moodLineDataSets); Log.Info(TAG, "SetupChartData: Created LineData containing date list and mood data sets"); _lineChart.Data = moodLineData; _lineChart.Legend.WordWrapEnabled = true; _lineChart.SetDescriptionColor(Color.White); _lineChart.SetDescription(_activity.GetString(Resource.String.MyProgressGraphDescription) + " " + startDate.ToShortDateString() + " - " + endDate.ToShortDateString()); _lineChart.XAxis.TextColor = Color.White; _lineChart.XAxis.AxisLineColor = Color.White; _lineChart.XAxis.GridColor = Color.White; _lineChart.AxisLeft.AxisLineColor = Color.White; _lineChart.AxisRight.AxisLineColor = Color.White; _lineChart.AxisLeft.GridColor = Color.White; _lineChart.AxisRight.GridColor = Color.White; _lineChart.AxisLeft.TextColor = Color.White; _lineChart.AxisRight.TextColor = Color.White; _lineChart.AxisLeft.TextSize = 10f; _lineChart.AxisRight.TextSize = 10f; var yaxis1 = _lineChart.GetAxis(YAxis.AxisDependency.Left); yaxis1.AxisLineColor = Color.White; yaxis1.GridColor = Color.White; yaxis1.TextColor = Color.White; yaxis1.TextSize = 10f; var yaxis2 = _lineChart.GetAxis(YAxis.AxisDependency.Right); yaxis2.AxisLineColor = Color.White; yaxis2.GridColor = Color.White; yaxis2.TextColor = Color.White; yaxis1.TextSize = 10f; _lineChart.SetBorderColor(Color.White); moodLineData.SetValueTextColor(Color.White); moodLineData.SetValueTextSize(10f); _lineChart.Invalidate(); dbHelp.CloseDatabase(); Log.Info(TAG, "SetupChartData: Finished retrieving chart data"); } } } catch (Exception e) { if (dbHelp != null) { if (dbHelp.GetSQLiteDatabase().IsOpen) { dbHelp.CloseDatabase(); } } Log.Error(TAG, "SetupChartData: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(_activity, e, "Setting data for chart", "ProgressChartHelper.SetupChartData"); } } return(_lineChart); }