protected override void OnRestoreInstanceState(Android.OS.Bundle savedInstanceState)
 {
     base.OnRestoreInstanceState(savedInstanceState);
     mDataset = savedInstanceState.GetSerializable("dataset") as XYMultipleSeriesDataset;
     mRenderer = savedInstanceState.GetSerializable("renderer") as XYMultipleSeriesRenderer;
     mCurrentSeries = savedInstanceState.GetSerializable("current_series") as XYSeries;
     mCurrentRenderer = savedInstanceState.GetSerializable("current_renderer") as XYSeriesRenderer;
 }
 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);
     }
 }
 private XYMultipleSeriesDataset GetDemoDataset()
 {
     XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
     const int nr = 10;
     Random r = new Random();
     for (int i = 0; i < SERIES_NR; i++)
     {
         XYSeries series = new XYSeries("Demo series " + (i + 1));
         for (int k = 0; k < nr; k++)
         {
             series.Add(k, 20 + r.Next() % 100);
         }
         dataset.AddSeries(series);
     }
     return dataset;
 }
        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;
        }
        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();
            };
        }