private void CreateGlucoseChart()
        {
            if (_bloodGlucoseDataList.Count == 0)
            {
                _lineChart.Data.ClearValues();
                _lineChart.Clear();
                _lineChart.Invalidate();

                return;
            }
            var glucoseEntries = _bloodGlucoseDataList.Select((t, i) => new BarEntry(i, t.Avg)).Cast <Entry>().ToList();

            var glucoseDataSet = new LineDataSet(glucoseEntries, "Glucoza")
            {
                ValueTextSize  = 14f,
                ValueTextColor = Color.White,
                LineWidth      = 3f,
                AxisDependency = YAxis.AxisDependency.Left
            };

            glucoseDataSet.SetMode(LineDataSet.Mode.HorizontalBezier);
            glucoseDataSet.SetColors(Resources.GetColor(Resource.Color.accent, Theme));
            glucoseDataSet.SetCircleColor(Resources.GetColor(Resource.Color.accent, Theme));
            var barData = new LineData(glucoseDataSet);

            _lineChart.Data = barData;

            _lineChart.SetOnChartValueSelectedListener(this);
            _lineChart.SetDrawBorders(false);
            _lineChart.SetDrawGridBackground(false);
            _lineChart.SetNoDataText("Nu exista date");
            _lineChart.Description.Enabled = false;
            _lineChart.AxisLeft.SetDrawGridLines(false);
            _lineChart.AxisRight.SetDrawGridLines(false);
            _lineChart.XAxis.SetDrawGridLines(false);

            _lineChart.XAxis.Enabled     = false;
            _lineChart.AxisLeft.Enabled  = false;
            _lineChart.AxisRight.Enabled = false;

            _lineChart.AnimateXY(3000, 3000); // animate horizontal and vertical 3000 milliseconds
            _lineChart.SetPinchZoom(false);
            SetLegend();
            _lineChart.Invalidate();
        }
        private void CreateBloodPresureChart()
        {
            if (_bloodPressureDataList.Count == 0)
            {
                _lineChart.Data.ClearValues();
                _lineChart.Clear();
                _lineChart.Invalidate();

                return;
            }
            var systolicEntries  = new List <Entry>();
            var diastolicEntries = new List <Entry>();

            for (var i = 0; i < _bloodPressureDataList.Count; i++)
            {
                systolicEntries.Add(new BarEntry(i, _bloodPressureDataList[i].Systolic));
                diastolicEntries.Add(new BarEntry(i, _bloodPressureDataList[i].Diastolic));
            }

            var systolicDataSet = new LineDataSet(systolicEntries, "Sistola")
            {
                ValueTextSize  = 14f,
                ValueTextColor = Color.White,
                LineWidth      = 3f,
                AxisDependency = YAxis.AxisDependency.Left
            };

            systolicDataSet.SetMode(LineDataSet.Mode.HorizontalBezier);
            systolicDataSet.SetColors(Resources.GetColor(Resource.Color.accent, Theme));
            systolicDataSet.SetCircleColor(Resources.GetColor(Resource.Color.accent, Theme));
            var diastolicDataSet = new LineDataSet(diastolicEntries, "Diastola")
            {
                ValueTextSize  = 14f,
                ValueTextColor = Color.White,
                LineWidth      = 3f,
                AxisDependency = YAxis.AxisDependency.Left
            };

            diastolicDataSet.SetMode(LineDataSet.Mode.HorizontalBezier);
            diastolicDataSet.SetColors(Color.White);
            diastolicDataSet.SetCircleColor(Color.White);
            var barData = new LineData(systolicDataSet, diastolicDataSet);

            _lineChart.Data = barData;

            _lineChart.SetOnChartValueSelectedListener(this);
            _lineChart.SetDrawBorders(false);
            _lineChart.SetDrawGridBackground(false);
            _lineChart.SetNoDataText("Nu exista date");
            _lineChart.Description.Enabled = false;
            _lineChart.AxisLeft.SetDrawGridLines(false);
            _lineChart.AxisRight.SetDrawGridLines(false);
            _lineChart.XAxis.SetDrawGridLines(false);

            _lineChart.XAxis.Enabled     = false;
            _lineChart.AxisLeft.Enabled  = false;
            _lineChart.AxisRight.Enabled = false;

            _lineChart.AnimateXY(1000, 1000); // animate horizontal and vertical 3000 milliseconds
            _lineChart.SetPinchZoom(false);
            SetLegend();
            _lineChart.Invalidate();
        }
        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);
        }