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

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

                foreach (var itemChild in data.IF_GetDataSet())
                {
                    var         entryOriginal = itemChild.IF_GetEntry().Select(item => new MikePhil.Charting.Data.Entry(item.GetXPosition(), item.GetYPosition()));
                    LineDataSet lineDataSet   = new LineDataSet(entryOriginal.ToArray(), itemChild.IF_GetTitle());
                    lineDataSet.Color = itemChild.IF_GetDataColor().ToAndroid();
                    lineDataSet.SetMode(SupportChart.GetDrawLineMode(itemChild.IF_GetDrawMode()));
                    lineDataSet.CircleRadius     = itemChild.IF_GetCircleRadius();
                    lineDataSet.CircleHoleRadius = itemChild.IF_GetCircleHoleRadius();
                    lineDataSet.SetDrawCircles(itemChild.IF_GetDrawCircle());
                    lineDataSet.SetDrawValues(itemChild.IF_GetDrawValue());

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

                LineData lineData = new LineData(dataSetItems.ToArray());
                lineChart.Data = lineData;
            }
        }
Example #2
0
        private LineDataSet CreateLineDataSet(Color mcolor, string mLabel, List <float> MotionList)
        {
            LineDataSet set = new LineDataSet(null, "Data")
            {
                AxisDependency   = YAxis.AxisDependency.Left,
                LineWidth        = 2.5f,
                Color            = mcolor,
                HighlightEnabled = false,
                Label            = mLabel
            };

            set.SetDrawValues(false);
            set.SetDrawCircles(false);
            set.SetMode(LineDataSet.Mode.CubicBezier);
            set.CubicIntensity = 0.1f;

            if (MotionList.Count > max_OnCreateEntries)
            {
                for (int i = 0; i < max_OnCreateEntries; i++)
                {
                    set.AddEntry(new Entry(i, MotionList[i]));
                }
            }
            else
            {
                for (int i = 0; i < MotionList.Count; i++)
                {
                    set.AddEntry(new Entry(i, MotionList[i]));
                }
            }
            return(set);
        }
Example #3
0
        void UpdatePowerMonitorChart()
        {
            var chart = FindViewById <LineChart>(Resource.Id.lineChart);


            Entry[] values = new Entry[powerHistory.values.Length];

            for (int i = 0; i < values.Count(); i++)
            {
                values[i] = new Entry(i, powerHistory.values[i]);
            }

            LineDataSet set1;

            if (chart.Data != null &&
                chart.Data.DataSetCount > 0)
            {
                set1        = (LineDataSet)chart.Data.GetDataSetByIndex(0);
                set1.Values = values;
                chart.Data.NotifyDataChanged();
                chart.NotifyDataSetChanged();
            }
            else
            {
                // create a dataset and give it a type
                set1 = new LineDataSet(values, "Power Usage");

                set1.SetMode(LineDataSet.Mode.CubicBezier);
                set1.CubicIntensity = 0.2f;
                set1.SetDrawFilled(true);
                set1.SetDrawCircles(false);
                set1.LineWidth = 1.6f;
                //set1.CircleRadius = 4f;
                //set1.SetCircleColor(Color.White);
                set1.HighLightColor = Color.Rgb(244, 117, 117);
                set1.Color          = Color.ParseColor("#68B9C0");
                set1.FillColor      = Color.ParseColor("#68B9C0");
                set1.FillAlpha      = 100;
                set1.SetDrawHorizontalHighlightIndicator(false);
                set1.SetDrawVerticalHighlightIndicator(false);
                //    set1.FillFormatter = new IFillFormatter() {
                //    public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider)
                //    {
                //        return chart.getAxisLeft().getAxisMinimum();
                //    }
                //};

                // create a data object with the data sets
                LineData data = new LineData(set1);
                //data.setValueTypeface(tfLight);
                data.SetValueTextSize(12f);
                data.SetDrawValues(false);

                // set data
                chart.Data = data;
            }
            chart.SetViewPortOffsets(0, 0, 0, 0);
            chart.Invalidate();
        }
        private LineDataSet CreateLineDataSet(Color mcolor, string mLabel)
        {
            LineDataSet set = new LineDataSet(null, "Data")
            {
                AxisDependency   = YAxis.AxisDependency.Left,
                LineWidth        = 3f,
                Color            = mcolor,
                HighlightEnabled = false,
                Label            = mLabel
            };

            set.SetDrawValues(false);
            set.SetDrawCircles(false);
            set.SetMode(LineDataSet.Mode.CubicBezier);
            set.CubicIntensity = 0.2f;
            return(set);
        }
        private void OnIntializeDataSetLine(ILineDataSetXF source, LineDataSet original)
        {
            OnSettingsLineRadarDataSet(source, original);

            if (source.IF_GetMode().HasValue)
            {
                original.SetMode(GetDrawLineMode(source.IF_GetMode().Value));
            }

            if (source.IF_GetCircleColors() != null && source.IF_GetCircleColors().Count > 0)
            {
                original.SetCircleColors(source.IF_GetCircleColors().Select(item => item.ToAndroid().ToArgb()).ToArray());
            }

            if (source.IF_GetCircleHoleColor().HasValue)
            {
                original.CircleHoleColor = source.IF_GetCircleHoleColor().Value.ToAndroid();
            }

            if (source.IF_GetCircleRadius().HasValue)
            {
                original.CircleRadius = source.IF_GetCircleRadius().Value;
            }

            if (source.IF_GetCircleHoleRadius().HasValue)
            {
                original.CircleHoleRadius = source.IF_GetCircleHoleRadius().Value;
            }

            if (source.IF_GetCubicIntensity().HasValue)
            {
                original.CubicIntensity = source.IF_GetCubicIntensity().Value;
            }

            if (source.IF_GetDrawCircles().HasValue)
            {
                original.SetDrawCircles(source.IF_GetDrawCircles().Value);
            }

            if (source.IF_GetDrawCircleHole().HasValue)
            {
                original.SetDrawCircleHole(source.IF_GetDrawCircleHole().Value);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SessionData);

            // Layout have a object in which the chart will be displayed
            // Referencing that object
            lineChart = (LineChart)FindViewById(Resource.Id.linechart);

            List <Entry> yVals = new List <Entry>();

            double j = 0;

            for (int i = 0; i < 1000; i++)
            {
                // float x1 = float.Parse((Math.Sin(x)).ToString());
                float y = float.Parse((Math.Sin(j).ToString()));
                j++;
                yVals.Add(new Entry(i, y));
            }
            // Data for Ine Chart is set
            LineDataSet sety = new LineDataSet(yVals, "yData");

            // Enables chart to be clear
            sety.SetDrawCircles(false);
            // Displays scrollable chart
            sety.SetMode(LineDataSet.Mode.CubicBezier);
            // hides the x and y values for each point
            sety.SetDrawValues(false);
            LineData data = new LineData(sety);

            lineChart.Data = (data);
            lineChart.SetVisibleXRangeMaximum(65f);
            // Sets the background color
            lineChart.SetBackgroundColor(Color.FloralWhite);
            // Grid lines are made invisible
            lineChart.SetDrawGridBackground(false);
        }