private void InitializeChart()
        {
            if (supportLineChart != null && supportLineChart.ChartData != null && lineChart != null)
            {
                SupportChart.OnInitializeChart(supportLineChart, lineChart);


                var data         = supportLineChart.ChartData;
                var dataSetItems = new List <LineChartDataSet>();

                foreach (var itemChild in data.IF_GetDataSet())
                {
                    var entryOriginal            = itemChild.IF_GetEntry().Select(item => new iOSCharts.ChartDataEntry(item.GetXPosition(), item.GetYPosition()));
                    LineChartDataSet lineDataSet = new LineChartDataSet(entryOriginal.ToArray(), itemChild.IF_GetTitle());
                    lineDataSet.SetColor(itemChild.IF_GetDataColor().ToUIColor());
                    lineDataSet.Mode               = (SupportChart.GetDrawLineMode(itemChild.IF_GetDrawMode()));
                    lineDataSet.CircleRadius       = itemChild.IF_GetCircleRadius();
                    lineDataSet.CircleHoleRadius   = itemChild.IF_GetCircleHoleRadius();
                    lineDataSet.DrawCirclesEnabled = (itemChild.IF_GetDrawCircle());
                    lineDataSet.DrawValuesEnabled  = (itemChild.IF_GetDrawValue());

                    var arrColor = itemChild.IF_GetCircleColors().Select(item => item.ToUIColor());
                    lineDataSet.SetCircleColor(itemChild.IF_GetCircleColor().ToUIColor());
                    dataSetItems.Add(lineDataSet);
                }

                LineChartData lineData = new LineChartData(dataSetItems.ToArray());
                lineChart.Data = lineData;
            }
        }
        void SetData()
        {
            List <ChartDataEntry> entries       = new List <ChartDataEntry>();
            List <ChartDataEntry> secondEntries = new List <ChartDataEntry>();
            List <ChartDataEntry> thirdEntries  = new List <ChartDataEntry>();
            List <ChartDataEntry> fourthEntries = new List <ChartDataEntry>();

            entries.Add(new ChartDataEntry(0, 8));
            entries.Add(new ChartDataEntry(1, 3));
            entries.Add(new ChartDataEntry(2, 1));
            entries.Add(new ChartDataEntry(3, -1));
            secondEntries.Add(new ChartDataEntry(3, -1));
            secondEntries.Add(new ChartDataEntry(4, -7));
            secondEntries.Add(new ChartDataEntry(5, -2));
            secondEntries.Add(new ChartDataEntry(6, -3));
            secondEntries.Add(new ChartDataEntry(7, -4));
            thirdEntries.Add(new ChartDataEntry(7, 2));
            thirdEntries.Add(new ChartDataEntry(8, 2.6f));
            thirdEntries.Add(new ChartDataEntry(9, 3.6f));
            thirdEntries.Add(new ChartDataEntry(10, 2.8f));
            thirdEntries.Add(new ChartDataEntry(11, 3.8f));

            LineChartDataSet set1 = null;

            set1                   = new LineChartDataSet(entries.ToArray(), " ");
            set1.LineWidth         = 3f;
            set1.CircleRadius      = 5f;
            set1.Mode              = LineChartMode.CubicBezier;
            set1.DrawValuesEnabled = false;
            set1.SetColor(UIColor.White);
            set1.DrawFilledEnabled = true;
            set1.CircleHoleColor   = UIColor.White;
            set1.SetCircleColor(UIColor.White);
            set1.DrawHorizontalHighlightIndicatorEnabled = false;

            LineChartDataSet set2 = null;

            set2                   = new LineChartDataSet(secondEntries.ToArray(), " ");
            set2.LineWidth         = 3f;
            set2.CircleRadius      = 5f;
            set2.Mode              = LineChartMode.CubicBezier;
            set2.DrawValuesEnabled = false;
            set2.SetColor(UIColor.White);
            set2.DrawFilledEnabled = true;
            set2.CircleHoleColor   = UIColor.White;
            set2.SetCircleColor(UIColor.White);
            set2.DrawHorizontalHighlightIndicatorEnabled = false;

            LineChartDataSet set3 = null;

            set3                   = new LineChartDataSet(thirdEntries.ToArray(), " ");
            set3.LineWidth         = 3f;
            set3.CircleRadius      = 5f;
            set3.Mode              = LineChartMode.CubicBezier;
            set3.DrawValuesEnabled = false;
            set3.SetColor(UIColor.White);
            set3.DrawFilledEnabled = true;
            set3.CircleHoleColor   = UIColor.White;
            set3.SetCircleColor(UIColor.White);
            set3.DrawHorizontalHighlightIndicatorEnabled = false;

            LineChartDataSet set4 = null;

            set4                    = new LineChartDataSet(fourthEntries.ToArray(), " ");
            set4.LineWidth          = 3f;
            set4.Mode               = LineChartMode.CubicBezier;
            set4.DrawValuesEnabled  = false;
            set4.DrawCirclesEnabled = false;
            set4.SetColor(UIColor.White);
            set4.DrawFilledEnabled = true;
            set4.CircleHoleColor   = UIColor.White;
            set4.SetCircleColor(UIColor.Red);
            set4.DrawHorizontalHighlightIndicatorEnabled = false;

            List <LineChartDataSet> dataSets = new List <LineChartDataSet>();

            dataSets.Add(set1);
            dataSets.Add(set2);
            dataSets.Add(set3);
            dataSets.Add(set4);
            var t             = (IInterfaceChartDataSet[])dataSets.ToArray();
            var lineChartData = new LineChartData(t);
            var barChartData  = GenerateBarData();

            var data = new CombinedChartData();

            data.LineData = lineChartData;
            data.BarData  = barChartData;

            _chart.Data = data;

            _chart.SetVisibleXRangeMaximum(7);
        }
Exemple #3
0
        void SetData()
        {
            List <ChartDataEntry> entries       = new List <ChartDataEntry>();
            List <ChartDataEntry> secondEntries = new List <ChartDataEntry>();
            List <ChartDataEntry> thirdEntries  = new List <ChartDataEntry>();
            List <ChartDataEntry> fourthEntries = new List <ChartDataEntry>();

            entries.Add(new ChartDataEntry(0, 0.613));
            entries.Add(new ChartDataEntry(1, 0.365));
            entries.Add(new ChartDataEntry(2, 0.334));
            entries.Add(new ChartDataEntry(3, 0.538));
            secondEntries.Add(new ChartDataEntry(3, 0.538));
            secondEntries.Add(new ChartDataEntry(4, 0.932));
            secondEntries.Add(new ChartDataEntry(5, 1.421));
            secondEntries.Add(new ChartDataEntry(6, 1.891));
            secondEntries.Add(new ChartDataEntry(7, 2.241));
            thirdEntries.Add(new ChartDataEntry(7, 2.241));
            thirdEntries.Add(new ChartDataEntry(8, 2.397));
            thirdEntries.Add(new ChartDataEntry(9, 2.327));
            thirdEntries.Add(new ChartDataEntry(10, 2.047));
            thirdEntries.Add(new ChartDataEntry(11, 1.618));
            thirdEntries.Add(new ChartDataEntry(12, 1.146));
            thirdEntries.Add(new ChartDataEntry(13, 0.753));
            thirdEntries.Add(new ChartDataEntry(14, 0.542));
            thirdEntries.Add(new ChartDataEntry(15, 0.562));
            thirdEntries.Add(new ChartDataEntry(16, 0.797));
            thirdEntries.Add(new ChartDataEntry(17, 1.169));
            fourthEntries.Add(new ChartDataEntry(18, 1.574));

            LineChartDataSet set1 = null;

            set1                   = new LineChartDataSet(entries.ToArray(), " ");
            set1.LineWidth         = 3f;
            set1.CircleRadius      = 5f;
            set1.Mode              = LineChartMode.CubicBezier;
            set1.DrawValuesEnabled = false;
            set1.SetColor(UIColor.White);
            set1.DrawFilledEnabled = true;
            set1.FillColor         = UIColor.FromRGB(13, 168, 83);
            set1.FillAlpha         = 255;
            set1.CircleHoleColor   = UIColor.White;
            set1.SetCircleColor(UIColor.White);
            set1.DrawHorizontalHighlightIndicatorEnabled = false;

            LineChartDataSet set2 = null;

            set2                   = new LineChartDataSet(secondEntries.ToArray(), " ");
            set2.LineWidth         = 3f;
            set2.CircleRadius      = 5f;
            set2.Mode              = LineChartMode.CubicBezier;
            set2.DrawValuesEnabled = false;
            set2.SetColor(UIColor.White);
            set2.DrawFilledEnabled = true;
            set2.FillColor         = UIColor.FromRGB(165, 43, 38);
            set2.FillAlpha         = 255;
            set2.CircleHoleColor   = UIColor.White;
            set2.SetCircleColor(UIColor.White);
            set2.DrawHorizontalHighlightIndicatorEnabled = false;

            LineChartDataSet set3 = null;

            set3                   = new LineChartDataSet(thirdEntries.ToArray(), " ");
            set3.LineWidth         = 3f;
            set3.CircleRadius      = 5f;
            set3.Mode              = LineChartMode.CubicBezier;
            set3.DrawValuesEnabled = false;
            set3.SetColor(UIColor.White);
            set3.DrawFilledEnabled = true;
            set3.FillColor         = UIColor.FromRGB(13, 168, 83);
            set3.FillAlpha         = 255;
            set3.CircleHoleColor   = UIColor.White;
            set3.SetCircleColor(UIColor.White);
            set3.DrawHorizontalHighlightIndicatorEnabled = false;

            LineChartDataSet set4 = null;

            set4                    = new LineChartDataSet(fourthEntries.ToArray(), " ");
            set4.LineWidth          = 3f;
            set4.Mode               = LineChartMode.CubicBezier;
            set4.DrawValuesEnabled  = false;
            set4.DrawCirclesEnabled = false;
            set4.SetColor(UIColor.White);
            set4.DrawFilledEnabled = true;
            set4.FillColor         = UIColor.FromRGB(13, 168, 83);
            set4.FillAlpha         = 255;
            set4.CircleHoleColor   = UIColor.White;
            set4.SetCircleColor(UIColor.Red);
            set4.DrawHorizontalHighlightIndicatorEnabled = false;

            List <LineChartDataSet> dataSets = new List <LineChartDataSet>();

            dataSets.Add(set1);
            dataSets.Add(set2);
            dataSets.Add(set3);
            dataSets.Add(set4);
            var           t    = (IInterfaceChartDataSet[])dataSets.ToArray();
            LineChartData data = new LineChartData(t);

            _chart.Data = data;
        }