Exemplo n.º 1
0
        private void createSeries()
        {
            int       Max             = 180;
            const int lowerThreshold  = 70;
            const int lowerTherapy    = 80;
            const int higherThreshold = 250;
            const int higherTherapy   = 140;


            for (int i = 0; i < Max; i++)
            {
                firstSeries.Add(i, lowerThreshold);
                secondSeries.Add(i, lowerTherapy);
                thirdSeries.Add(i, higherTherapy);
                fourthSeries.Add(i, higherThreshold);
            }

            int index = 0;

            if (_latestTrendData != null)
            {
                foreach (CGMMeasurementModel cgmModel in _latestTrendData)
                {
                    if (cgmModel != null)
                    {
                        var offsetTime = cgmModel.OffsetTime;
                        var CGMValue   = cgmModel.CGMValue;
                        Log.Error("MainActivity :", "CGMValue:" + CGMValue);

                        CGMSeries.Add(offsetTime, (double)CGMValue);
                        index++;
                    }
                }
            }

            //CGMMeasurementModel.CGMValue

            // Adding First Series to the dataset
            dataset.AddSeries(firstSeries);
            // Adding Second Series to dataset
            dataset.AddSeries(secondSeries);
            // Adding Third Series to dataset
            dataset.AddSeries(thirdSeries);
            // Adding Fourth Series to dataset
            dataset.AddSeries(fourthSeries);
            dataset.AddSeries(CGMSeries);
        }
        /// <summary>
        /// Executes the chart demo.
        /// </summary>
        /// <param name="context"> the context </param>
        /// <returns> the built intent </returns>
        public override Intent Execute(Context context)
        {
            XYMultipleSeriesDataset series          = new XYMultipleSeriesDataset();
            XYValueSeries           newTicketSeries = new XYValueSeries("New Tickets");

            newTicketSeries.Add(1f, 2, 14);
            newTicketSeries.Add(2f, 2, 12);
            newTicketSeries.Add(3f, 2, 18);
            newTicketSeries.Add(4f, 2, 5);
            newTicketSeries.Add(5f, 2, 1);
            series.AddSeries(newTicketSeries);
            XYValueSeries fixedTicketSeries = new XYValueSeries("Fixed Tickets");

            fixedTicketSeries.Add(1f, 1, 7);
            fixedTicketSeries.Add(2f, 1, 4);
            fixedTicketSeries.Add(3f, 1, 18);
            fixedTicketSeries.Add(4f, 1, 3);
            fixedTicketSeries.Add(5f, 1, 1);
            series.AddSeries(fixedTicketSeries);

            XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();

            renderer.AxisTitleTextSize  = 16;
            renderer.ChartTitleTextSize = 20;
            renderer.LabelsTextSize     = 15;
            renderer.LegendTextSize     = 15;
            renderer.SetMargins(new int[] { 20, 30, 15, 0 });
            XYSeriesRenderer newTicketRenderer = new XYSeriesRenderer();

            newTicketRenderer.Color = Color.Blue;
            renderer.AddSeriesRenderer(newTicketRenderer);
            XYSeriesRenderer fixedTicketRenderer = new XYSeriesRenderer();

            fixedTicketRenderer.Color = Color.Green;
            renderer.AddSeriesRenderer(fixedTicketRenderer);

            SetChartSettings(renderer, "Project work status", "Priority", "", 0.5, 5.5, 0, 5, Color.Gray, Color.LightGray);
            renderer.XLabels = 7;
            renderer.YLabels = 0;
            renderer.SetShowGrid(false);
            return(ChartFactory.GetBubbleChartIntent(context, series, renderer, "Project tickets"));
        }
Exemplo n.º 3
0
        private XYMultipleSeriesDataset GetBarDemoDataset()
        {
            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
            const int nr = 10;
            Random    r  = new Random();

            for (int i = 0; i < SERIES_NR; i++)
            {
                CategorySeries series = new CategorySeries("Demo series " + (i + 1));
                for (int k = 0; k < nr; k++)
                {
                    series.Add(100 + r.Next() % 100);
                }
                dataset.AddSeries(series.ToXYSeries());
            }
            return(dataset);
        }
Exemplo n.º 4
0
        public void AddXYSeries(XYMultipleSeriesDataset dataset, String[] titles, IList <double[]> xValues, IList <double[]> yValues, int scale)
        {
            int length = titles.Length;

            for (int i = 0; i < length; i++)
            {
                XYSeries series       = new XYSeries(titles[i], scale);
                double[] xV           = xValues[i];
                double[] yV           = yValues[i];
                int      seriesLength = xV.Length;
                for (int j = 0; j < seriesLength; j++)
                {
                    series.Add(xV[j], yV[j]);
                }
                dataset.AddSeries(series);
            }
        }
Exemplo n.º 5
0
        private XYMultipleSeriesDataset GetDateDemoDataset()
        {
            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
            const int nr    = 10;
            long      value = new Java.Util.Date().Time - 3 * TimeChart.Day;
            Random    r     = new Random();

            for (int i = 0; i < SERIES_NR; i++)
            {
                TimeSeries series = new TimeSeries("Demo series " + (i + 1));
                for (int k = 0; k < nr; k++)
                {
                    series.Add(new Java.Util.Date(value + k * TimeChart.Day / 4), 20 + r.Next() % 100);
                }
                dataset.AddSeries(series);
            }
            return(dataset);
        }
Exemplo n.º 6
0
        protected XYMultipleSeriesDataset BuildBarDataset(String[] title, IList <double[]> values)
        {
            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
            int length = title.Length;

            for (int i = 0; i < length; i++)
            {
                CategorySeries series       = new CategorySeries(title[i]);
                double[]       v            = values[i];
                int            seriesLength = v.Length;
                for (int k = 0; k < seriesLength; k++)
                {
                    series.Add(v[k]);
                }
                dataset.AddSeries(series.ToXYSeries());
            }
            return(dataset);
        }
        public override Android.Content.Intent Execute(Android.Content.Context context)
        {
            double[] minValues = new double[] { -24, -19, -10, -1, 7, 12, 15, 14, 9, 1, -11, -16 };
            double[] maxValues = new double[] { 7, 12, 24, 28, 33, 35, 37, 36, 28, 19, 11, 4 };

            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
            RangeCategorySeries     series  = new RangeCategorySeries("Temperature");
            int length = minValues.Length;

            for (int k = 0; k < length; k++)
            {
                series.Add(minValues[k], maxValues[k]);
            }
            dataset.AddSeries(series.ToXYSeries());
            int[] colors = new int[] { Color.Cyan };
            XYMultipleSeriesRenderer renderer = BuildBarRenderer(colors);

            SetChartSettings(renderer, "Monthly temperature range", "Month", "Celsius degrees", 0.5, 12.5, -30, 45, Color.Gray, Color.LightGray);
            renderer.BarSpacing = 0.5;
            renderer.XLabels    = 0;
            renderer.YLabels    = 10;
            renderer.AddXTextLabel(1, "Jan");
            renderer.AddXTextLabel(3, "Mar");
            renderer.AddXTextLabel(5, "May");
            renderer.AddXTextLabel(7, "Jul");
            renderer.AddXTextLabel(10, "Oct");
            renderer.AddXTextLabel(12, "Dec");
            renderer.AddYTextLabel(-25, "Very cold");
            renderer.AddYTextLabel(-10, "Cold");
            renderer.AddYTextLabel(5, "OK");
            renderer.AddYTextLabel(20, "Noci");
            renderer.SetMargins(new int[] { 30, 70, 10, 0 });
            renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Right);
            SimpleSeriesRenderer r = renderer.GetSeriesRendererAt(0);

            r.DisplayChartValues  = true;
            r.ChartValuesTextSize = 12;
            r.ChartValuesSpacing  = 3;
            r.GradientEnabled     = true;
            r.SetGradientStart(-20, Color.Blue);
            r.SetGradientStop(20, Color.Green);
            return(ChartFactory.GetRangeBarChartIntent(context, dataset, renderer, BarChart.Type.Default, "Temperatur range"));
        }
Exemplo n.º 8
0
        protected XYMultipleSeriesDataset BuildDateDataset(String[] titles, IList <Date[]> xValues, IList <double[]> yValues)
        {
            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
            int length = titles.Length;

            for (int i = 0; i < length; i++)
            {
                TimeSeries series       = new TimeSeries(titles[i]);
                Date[]     xV           = xValues[i];
                double[]   yV           = yValues[i];
                int        seriesLength = xV.Length;
                for (int j = 0; j < seriesLength; j++)
                {
                    series.Add(xV[j], yV[j]);
                }
                dataset.AddSeries(series);
            }
            return(dataset);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Builds an XY multiple time dataset using the provided values.
        /// </summary>
        /// <param name="titles"> the series titles </param>
        /// <param name="xValues"> the values for the X axis </param>
        /// <param name="yValues"> the values for the Y axis </param>
        /// <returns> the XY multiple time dataset </returns>
        protected internal virtual XYMultipleSeriesDataset BuildDateDataset(string[] titles, IList <Java.Util.Date[]> xValues, IList <double[]> yValues)
        {
            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
            int length = titles.Length;

            for (int i = 0; i < length; i++)
            {
                TimeSeries       series = new TimeSeries(titles[i]);
                Java.Util.Date[] xV     = xValues[i];
                double[]         yV     = yValues[i];
                int seriesLength        = xV.Length;
                for (int k = 0; k < seriesLength; k++)
                {
                    series.Add(xV[k], yV[k]);
                }
                dataset.AddSeries(series);
            }
            return(dataset);
        }
Exemplo n.º 10
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.xy_chart);

            mX   = FindViewById <EditText>(Resource.Id.xValue);
            mY   = FindViewById <EditText>(Resource.Id.yValue);
            mAdd = FindViewById <Button>(Resource.Id.add);

            mRenderer.ApplyBackgroundColor = true;
            mRenderer.BackgroundColor      = Color.Argb(100, 50, 50, 50);
            mRenderer.AxisTitleTextSize    = 16;
            mRenderer.ChartTitleTextSize   = 20;
            mRenderer.LabelsTextSize       = 15;
            mRenderer.LegendTextSize       = 15;
            mRenderer.SetMargins(new int[] { 20, 30, 15, 0 });
            mRenderer.ZoomButtonsVisible = true;
            mRenderer.PointSize          = 5;

            mNewSeries        = FindViewById <Button>(Resource.Id.new_series);
            mNewSeries.Click += (e, s) =>
            {
                String   seriesTitle = "Series " + mDataset.SeriesCount + 1;
                XYSeries series      = new XYSeries(seriesTitle);
                mDataset.AddSeries(series);
                mCurrentSeries = series;
                XYSeriesRenderer renderer = new XYSeriesRenderer();
                mRenderer.AddSeriesRenderer(renderer);
                renderer.PointStyle                 = PointStyle.Circle;
                renderer.FillPoints                 = true;
                renderer.DisplayChartValues         = true;
                renderer.DisplayChartValuesDistance = 10;
                mCurrentRenderer = renderer;
                SetSeriesWidgetsEnabled(true);
                mChartView.Repaint();
            };

            mAdd.Click += (e, s) =>
            {
                double x = 0;
                double y = 0;
                try
                {
                    x = Double.Parse(mX.Text);
                }
                catch (Exception)
                {
                    mX.RequestFocus();
                    return;
                }
                try
                {
                    y = double.Parse(mY.Text);
                }
                catch (Exception)
                {
                    mY.RequestFocus();
                    return;
                }
                mCurrentSeries.Add(x, y);
                mX.Text = "";
                mY.Text = "";
                mX.RequestFocus();
                mChartView.Repaint();
            };
        }
Exemplo n.º 11
0
        public override Android.Content.Intent Execute(Android.Content.Context context)
        {
            String[]         titles = new String[] { "Crete Air Temperature", "Skiathos Air Temperature" };
            IList <double[]> x      = new List <double[]>();

            for (int i = 0; i < titles.Length; i++)
            {
                x.Add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
            }
            IList <double[]> values = new List <double[]>();

            values.Add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 });
            values.Add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 });
            int[]                    colors   = new int[] { Color.Green, Color.Rgb(200, 150, 0) };
            PointStyle[]             styles   = new PointStyle[] { PointStyle.Circle, PointStyle.Diamond };
            XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles);

            renderer.PointSize = 5.5f;
            int length = renderer.SeriesRendererCount;

            for (int i = 0; i < length; i++)
            {
                XYSeriesRenderer r = (XYSeriesRenderer)renderer.GetSeriesRendererAt(i);
                r.LineWidth  = 5;
                r.FillPoints = true;
            }
            SetChartSettings(renderer, "Weather data", "Month", "Temperature", 0.5, 12.5, 0, 40, Color.LightGray, Color.LightGray);
            renderer.XLabels = 12;
            renderer.YLabels = 10;
            renderer.SetShowGrid(true);
            renderer.XLabelsAlign = Android.Graphics.Paint.Align.Right;
            renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Right);
            renderer.ZoomButtonsVisible = true;
            renderer.SetPanLimits(new double[] { -10, 20, -10, 40 });
            renderer.SetZoomLimits(new double[] { -10, 20, -10, 40 });

            XYValueSeries sunSeries = new XYValueSeries("Sunshine hours");

            sunSeries.Add(1f, 35, 4.3);
            sunSeries.Add(2f, 35, 4.9);
            sunSeries.Add(3f, 35, 5.9);
            sunSeries.Add(4f, 35, 8.8);
            sunSeries.Add(5f, 35, 10.8);
            sunSeries.Add(6f, 35, 11.9);
            sunSeries.Add(7f, 35, 13.6);
            sunSeries.Add(8f, 35, 12.8);
            sunSeries.Add(9f, 35, 11.4);
            sunSeries.Add(10f, 35, 9.5);
            sunSeries.Add(11f, 35, 7.5);
            sunSeries.Add(12f, 35, 5.5);
            XYSeriesRenderer lightRenderer = new XYSeriesRenderer();

            lightRenderer.Color = Color.Yellow;

            XYSeries waterSeries = new XYSeries("Water Temperature");

            waterSeries.Add(1, 16);
            waterSeries.Add(2, 15);
            waterSeries.Add(3, 16);
            waterSeries.Add(4, 17);
            waterSeries.Add(5, 20);
            waterSeries.Add(6, 23);
            waterSeries.Add(7, 25);
            waterSeries.Add(8, 25.5);
            waterSeries.Add(9, 26.5);
            waterSeries.Add(10, 24);
            waterSeries.Add(11, 22);
            waterSeries.Add(12, 18);
            renderer.BarSpacing = 0.5;
            XYSeriesRenderer waterRenderer = new XYSeriesRenderer();

            waterRenderer.Color = Color.Argb(250, 0, 210, 250);

            XYMultipleSeriesDataset dataset = BuildDataset(titles, x, values);

            dataset.AddSeries(0, sunSeries);
            dataset.AddSeries(0, waterSeries);
            renderer.AddSeriesRenderer(0, lightRenderer);
            renderer.AddSeriesRenderer(0, waterRenderer);
            waterRenderer.DisplayChartValues  = true;
            waterRenderer.ChartValuesTextSize = 10;

            String[] types  = new String[] { "Bar", BubbleChart.Type, LineChart.Type, CubicLineChart.Type };
            Intent   intent = ChartFactory.GetCombinedXYChartIntent(context, dataset, renderer, types, "Weather parameters");

            return(intent);
        }
Exemplo n.º 12
0
        private void openChart()
        {
            int[] x       = { 0, 1, 2, 3, 4, 5, 6, 7 };
            int[] income  = { 2000, 2500, 2700, 3000, 2800, 3500, 3700, 3800 };
            int[] expense = { 2200, 2700, 2900, 2800, 2600, 3000, 3300, 3400 };

            // Creating an  XYSeries for Income
            XYSeries incomeSeries = new XYSeries("Income");
            // Creating an  XYSeries for Expense
            XYSeries expenseSeries = new XYSeries("Expense");

            // Adding data to Income and Expense Series
            for (int i = 0; i < x.Length; i++)
            {
                incomeSeries.Add(i, income[i]);
                expenseSeries.Add(i, expense[i]);
            }

            // Creating a dataset to hold each series
            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

            // Adding Income Series to the dataset
            dataset.AddSeries(incomeSeries);
            // Adding Expense Series to dataset
            dataset.AddSeries(expenseSeries);

            // Creating XYSeriesRenderer to customize incomeSeries
            XYSeriesRenderer incomeRenderer = new XYSeriesRenderer();

            incomeRenderer.Color              = Color.Rgb(130, 130, 230);
            incomeRenderer.FillPoints         = true;
            incomeRenderer.LineWidth          = 2;
            incomeRenderer.DisplayChartValues = true;

            // Creating XYSeriesRenderer to customize expenseSeries
            XYSeriesRenderer expenseRenderer = new XYSeriesRenderer();

            expenseRenderer.Color              = Color.Rgb(220, 80, 80);
            expenseRenderer.FillPoints         = true;
            expenseRenderer.LineWidth          = 2;
            expenseRenderer.DisplayChartValues = true;

            // Creating a XYMultipleSeriesRenderer to customize the whole chart
            XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();

            multiRenderer.XLabels            = 0;
            multiRenderer.ChartTitle         = "Income vs Expense Chart";
            multiRenderer.XTitle             = "Year 2012";
            multiRenderer.YTitle             = "Amount in Dollars";
            multiRenderer.ZoomButtonsVisible = true;
            multiRenderer.BackgroundColor    = Color.Transparent;
            for (int i = 0; i < x.Length; i++)
            {
                multiRenderer.AddXTextLabel(i, mMonth[i]);
            }

            // Adding incomeRenderer and expenseRenderer to multipleRenderer
            // Note: The order of adding dataseries to dataset and renderers to multipleRenderer
            // should be same
            multiRenderer.AddSeriesRenderer(incomeRenderer);
            multiRenderer.AddSeriesRenderer(expenseRenderer);

            // Creating an intent to plot bar chart using dataset and multipleRenderer
            Intent intent = ChartFactory.GetBarChartIntent(this, dataset, multiRenderer, BarChart.Type.Default);

            // Start Activity
            StartActivity(intent);
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Chart);
            db = new DataDB(this);

            mDataSet.AddSeries(SeriesCreate("DataOne"));
            mDataSet.AddSeries(SeriesCreate("DataTwo"));
            mDataSet.AddSeries(SeriesCreate("DataThree"));
            XYSeriesRenderer renderOne   = singleRenderer(255, 000, 000);
            XYSeriesRenderer renderTwo   = singleRenderer(000, 255, 000);
            XYSeriesRenderer renderThree = singleRenderer(000, 000, 255);

            mRenderer.SetMargins(new int[] { 10, 60, 100, 30 });
            mRenderer.XLabels              = 0;
            mRenderer.ChartTitle           = "Data Chart";
            mRenderer.XTitle               = "UserID";
            mRenderer.YTitle               = "Data Inputs";
            mRenderer.AxisTitleTextSize    = 32;
            mRenderer.ChartTitleTextSize   = 40;
            mRenderer.LabelsTextSize       = 32;
            mRenderer.PointSize            = 3;
            mRenderer.ShowLegend           = false;
            mRenderer.ShowGridX            = true;
            mRenderer.ShowGridY            = true;
            mRenderer.ZoomButtonsVisible   = true;
            mRenderer.ApplyBackgroundColor = true;
            mRenderer.AxesColor            = Color.Black;
            mRenderer.LabelsColor          = Color.Black;
            mRenderer.MarginsColor         = Color.White;
            mRenderer.GridColor            = Color.Black;
            mRenderer.SetYLabelsColor(0, Color.Black);
            mRenderer.XLabelsColor    = Color.Black;
            mRenderer.BackgroundColor = Color.White;
            for (int i = 0; i < db.Count(); i++)
            {
                mRenderer.AddXTextLabel(i, db.readPrimary("UserID", i));
            }
            mRenderer.AddSeriesRenderer(renderOne);
            mRenderer.AddSeriesRenderer(renderTwo);
            mRenderer.AddSeriesRenderer(renderThree);
            if (mChartView == null)
            {
                chartLayout = FindViewById <LinearLayout>(Resource.Id.chart);
                mChartView  = ChartFactory.GetLineChartView(this, mDataSet, mRenderer);
                chartLayout.AddView(mChartView, new LinearLayout.LayoutParams(
                                        Android.Views.ViewGroup.LayoutParams.FillParent,
                                        Android.Views.ViewGroup.LayoutParams.FillParent));
            }

            listView = FindViewById <ListView>(Resource.Id.DataList);
            tableItems.Add(new TableItem()
            {
                DataName = "DataOne", ID = 9001, Red = 255, Green = 000, Blue = 000
            });
            tableItems.Add(new TableItem()
            {
                DataName = "DataTwo", ID = 9002, Red = 000, Green = 255, Blue = 000
            });
            tableItems.Add(new TableItem()
            {
                DataName = "DataThree", ID = 9003, Red = 000, Green = 000, Blue = 255
            });
            listView.Adapter = new ChartActivityAdapter(this, tableItems);

            btnSave        = FindViewById <Button>(Resource.Id.btnSave);
            btnSave.Click += BtnSave_Click;
        }