public override Android.Content.Intent Execute(Android.Content.Context context)
 {
     String[] titles = new String[] { "Series 1", "Series 2", "Series 3", "Series 4", "Series 5" };
     IList<double[]> x = new List<double[]>();
     IList<double[]> values = new List<double[]>();
     int count = 20;
     int length = titles.Length;
     Random r = new Random();
     for (int i = 0; i < length; i++)
     {
         double[] xValues = new double[count];
         double[] yValues = new double[count];
         for (int k = 0; k < count; k++)
         {
             xValues[k] = k + r.Next() % 10;
             yValues[k] = k * 2 + r.Next() % 10;
         }
         x.Add(xValues);
         values.Add(yValues);
     }
     int[] colors = new int[] { Color.Blue, Color.Cyan, Color.Magenta, Color.LightGray, Color.Green };
     PointStyle[] styles = new PointStyle[] { PointStyle.X, PointStyle.Diamond, PointStyle.Triangle, PointStyle.Square, PointStyle.Circle };
     XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles);
     SetChartSettings(renderer, "Scatter chart", "X", "Y", -10, 30, -10, 51, Color.Gray, Color.LightGray);
     renderer.XLabels = 10;
     renderer.YLabels = 10;
     length = renderer.SeriesRendererCount;
     for (int i = 0; i < length; i++)
     {
         ((XYSeriesRenderer)renderer.GetSeriesRendererAt(i)).FillPoints = true;
     }
     return ChartFactory.GetScatterChartIntent(context, BuildDataset(titles, x, values), renderer);
 }
        public override Android.Content.Intent Execute(Android.Content.Context context)
        {
            String[] titles = new String[] { "Crete", "Corfu", "Thassos", "Skiathos" };
            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[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 });
            values.Add(new double[] { 5, 5.3, 8, 12, 17, 22, 24.2, 24, 19, 15, 9, 6 });
            values.Add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 });
            int[] colors = new int[] { Color.Blue, Color.Green, Color.Cyan, Color.Yellow };
            PointStyle[] styles = new PointStyle[] { PointStyle.Circle, PointStyle.Diamond, PointStyle.Triangle, PointStyle.Square };
            XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles);
            int length = renderer.SeriesRendererCount;
            for (int i = 0; i < length; i++)
            {
                ((XYSeriesRenderer)renderer.GetSeriesRendererAt(i)).FillPoints = true;
            }
            SetChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, -10, 40, Color.Gray, Color.Gray);
            renderer.XLabels = 12;
            renderer.YLabels = 10;
            renderer.SetShowGrid(true);
            renderer.ZoomButtonsVisible = true;
            renderer.SetPanLimits(new double[] { -10, 20, -10, 40 });
            renderer.SetZoomLimits(new double[] { -10, 20, -10, 40 });

            XYMultipleSeriesDataset dataset = BuildDataset(titles, x, values);
            XYSeries series = dataset.GetSeriesAt(0);
            series.AddAnnotation("Vacation", 6, 30);
            Intent intent = ChartFactory.GetLineChartIntent(context, dataset, renderer, "Average temperature");
            return intent;
        }
 public override Android.Content.Intent Execute(Android.Content.Context context)
 {
     String[] titles = new String[] { "Crete", "Corfu", "Thassos", "Skiathos" };
     IList<double[]> x = new List<double[]>();
     for (int i = 0; i < titles.Length; i++)
     {
         x.Add(new[] { 1d, 2d, 3d, 4d, 5d, 6d, 7d, 8d, 9d, 10d, 11d, 12d });
     }
     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[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 });
     values.Add(new double[] { 5, 5.3, 8, 12, 17, 23, 24.2, 24, 19, 15, 9, 6 });
     values.Add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 });
     int[] colors = new int[] { Color.Blue, Color.Green, Color.Cyan, Color.Yellow };
     PointStyle[] styles = new PointStyle[] { PointStyle.Circle, PointStyle.Diamond, PointStyle.Triangle, PointStyle.Square };
     XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles);
     int length = renderer.SeriesRendererCount;
     for (int i = 0; i < length; i++)
     {
         ((XYSeriesRenderer)renderer.GetSeriesRendererAt(i)).FillPoints = true;
     }
     SetChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, 0, 32, Color.Gray, Color.Gray);
     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 });
     Intent intent = ChartFactory.GetCubicLineChartIntent(context, BuildDataset(titles, x, values), renderer, 0.33f, "Average temperature");
     return intent;
 }
 public override Android.Content.Intent Execute(Android.Content.Context context)
 {
     String[] titles = new String[] { "sin", "cos" };
     IList<double[]> x = new List<double[]>();
     IList<double[]> values = new List<double[]>();
     int step = 4;
     int count = 360 / step + 1;
     x.Add(new double[count]);
     x.Add(new double[count]);
     double[] sinValues = new double[count];
     double[] cosValues = new double[count];
     values.Add(sinValues);
     values.Add(cosValues);
     for (int i = 0; i < count; i++)
     {
         int angle = i * step;
         x[0][i] = angle;
         x[1][i] = angle;
         double rAngle = Math.Tan(angle);
         sinValues[i] = Math.Sin(rAngle);
         cosValues[i] = Math.Cos(rAngle);
     }
     int[] colors = new int[] { Color.Blue, Color.Cyan };
     PointStyle[] styles = new PointStyle[] { PointStyle.Point, PointStyle.Point };
     XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles);
     SetChartSettings(renderer, "Trigonometric functions", "X (in degrees)", "Y", 0, 360, -1, 1, Color.Gray, Color.LightGray);
     renderer.XLabels = 20;
     renderer.YLabels = 10;
     return ChartFactory.GetLineChartIntent(context, BuildDataset(titles, x, values), renderer);
 }
        public override Android.Content.Intent Execute(Android.Content.Context context)
        {
            String[] titles = new String[] { "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 });
            int[] colors = new int[] { Color.Blue, Color.Yellow };
            PointStyle[] styles = new PointStyle[] { PointStyle.Point, PointStyle.Point };
            XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(2);
            SetRenderer(renderer, colors, styles);
            int length = renderer.SeriesRendererCount;
            for (int i = 0; i < length; i++)
            {
                XYSeriesRenderer r = (XYSeriesRenderer)renderer.GetSeriesRendererAt(i);
                r.LineWidth = 3f;
            }
            SetChartSettings(renderer, "Average temperaturs", "Month", "Temperature", 0.5, 12.5, 0, 32, 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 });
            renderer.ZoomRate = 1f;
            renderer.LabelsColor = Color.White;
            renderer.XLabelsColor = Color.Green;
            renderer.SetYLabelsColor(0, colors[0]);
            renderer.SetYLabelsColor(0, colors[1]);

            renderer.SetYTitle("Hours", 1);
            renderer.SetYAxisAlign(Android.Graphics.Paint.Align.Right, 1);
            renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Left, 1);

            XYMultipleSeriesDataset dataset = BuildDataset(titles, x, values);
            values.Clear();
            values.Add(new double[] { 4.3, 4.9, 5.9, 8.8, 10.8, 11.9, 13.6, 12.8, 11.4, 9.5, 7.5, 5.5 });
            AddXYSeries(dataset, new string[] { "Sunshine hours" }, x, values, 1);

            Intent intent = ChartFactory.GetCubicLineChartIntent(context, dataset, renderer, 0.3f, "Average temperature");
            return intent;
        }
 protected void SetRenderer(XYMultipleSeriesRenderer renderer, int[] colors, PointStyle[] styles)
 {
     renderer.AxisTitleTextSize = 16;
     renderer.ChartTitleTextSize = 20;
     renderer.LabelsTextSize = 15;
     renderer.LegendTextSize = 15;
     renderer.PointSize = 5f;
     renderer.SetMargins(new[] { 20, 30, 15, 20 });
     int length = colors.Length;
     for (int i = 0; i < length; i++)
     {
         XYSeriesRenderer r = new XYSeriesRenderer();
         r.Color = colors[i];
         r.PointStyle = styles[i];
         renderer.AddSeriesRenderer(r);
     }
 }
        public override Android.Content.Intent Execute(Android.Content.Context context)
        {
            String[] titles = new String[] { "Sales for 2008", "Sales for 2007", "Difference between 2008 and 2007 sales" };
            IList<double[]> values = new List<double[]>();
            values.Add(new double[] { 14230, 12300, 14240, 15244, 14900, 12200, 11030, 12000, 12500, 15500, 14600, 15000 });
            values.Add(new double[] { 10230, 10900, 11240, 12540, 13500, 14200, 12530, 11200, 10500, 12500, 11600, 13500 });
            int length = values[0].Length;
            double[] diff = new double[length];
            for (int i = 0; i < length; i++)
            {
                diff[i] = values[0][i] - values[1][i];
            }
            values.Add(diff);
            int[] colors = new int[] { Color.Blue, Color.Cyan, Color.Green };
            PointStyle[] styles = new PointStyle[] { PointStyle.Point, PointStyle.Point, PointStyle.Point };
            XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles);
            SetChartSettings(renderer, "Monthly sales int the last 2 years", "Month", "Units sold", 0.75, 12.25, -5000, 19000, Color.Gray, Color.LightGray);
            renderer.XLabels = 12;
            renderer.YLabels = 10;
            renderer.ChartTitleTextSize = 20;
            renderer.SetTextTypeface("sans_serif", (int)TypefaceStyle.Bold);
            renderer.LabelsTextSize = 14f;
            renderer.AxisTitleTextSize = 15;
            renderer.LegendTextSize = 15;
            length = renderer.SeriesRendererCount;

            for (int i = 0; i < length; i++)
            {
                XYSeriesRenderer seriesRenderer = (XYSeriesRenderer)renderer.GetSeriesRendererAt(i);
                if (i == length - 1)
                {
                    Org.Achartengine.Renderer.XYSeriesRenderer.FillOutsideLine fill = new XYSeriesRenderer.FillOutsideLine(Org.Achartengine.Renderer.XYSeriesRenderer.FillOutsideLine.Type.BoundsAll);
                    fill.Color = Color.Green;
                    seriesRenderer.AddFillOutsideLine(fill);
                }
                seriesRenderer.LineWidth = 2.5f;
                seriesRenderer.DisplayChartValues = true;
                seriesRenderer.ChartValuesTextSize = 10f;
            }
            return ChartFactory.GetCubicLineChartIntent(context, BuildBarDataset(titles, values), renderer, 0.5f);
        }
        public override Android.Content.Intent Execute(Android.Content.Context context)
        {
            String[] titles = new String[] { "Inside", "Outside" };
            long now = new Date().Time / DAY * DAY;
            IList<Date[]> x = new List<Date[]>();
            for (int i = 0; i < titles.Length; i++)
            {
                Date[] dates = new Date[HOURS];
                for (int j = 0; j < HOURS; j++)
                {
                    dates[j] = new Date(now - (HOURS - j) * HOUR);
                }
                x.Add(dates);
            }
            IList<double[]> values = new List<double[]>();

            values.Add(new double[] {21.2, 21.5, 21.7, 21.5, 21.4, 21.4, 21.3, 21.1, 20.6, 20.3, 20.2,
                19.9, 19.7, 19.6, 19.9, 20.3, 20.6, 20.9, 21.2, 21.6, 21.9, 22.1, 21.7, 21.5 });
            values.Add(new double[] {1.9, 1.2, 0.9, 0.5, 0.1, -0.5, -0.6, MathHelper.NullValue,
                MathHelper.NullValue, -1.8, -0.3, 1.4, 3.4, 4.9, 7.0, 6.4, 3.4, 2.0, 1.5, 0.9, -0.5,
                MathHelper.NullValue, -1.9, -2.5, -4.3 });

            int[] colors = new int[] { Color.Green, Color.Blue };
            PointStyle[] styles = new PointStyle[] { PointStyle.Circle, PointStyle.Diamond };
            XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles);
            int length = renderer.SeriesRendererCount;
            for (int i = 0; i < length; i++)
            {
                ((XYSeriesRenderer)renderer.GetSeriesRendererAt(i)).FillPoints = true;
            }
            SetChartSettings(renderer, "Sensor temperature", "Hour", "Celsius degrees", x[0][0].Time, x[0][HOURS - 1].Time, -5, 30, Color.LightGray, Color.LightGray);
            renderer.XLabels = 10;
            renderer.YLabels = 10;
            renderer.SetShowGrid(true);
            renderer.XLabelsAlign = Android.Graphics.Paint.Align.Center;
            renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Right);
            return ChartFactory.GetTimeChartIntent(context, BuildDateDataset(titles, x, values), renderer, "h:mm a");
        }
        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 XYMultipleSeriesRenderer BuildRenderer(int[] colors, PointStyle[] styles)
 {
     XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
     SetRenderer(renderer, colors, styles);
     return renderer;
 }