Beispiel #1
0
            public static ChartTypeModel NewHorizontallyStackedColumns(PenStyle.Builder penBuilder)
            {
                var seriesCollection = new HorizontallyStackedColumnsCollection();

                for (var i = 0; i < 5; i++)
                {
                    var dataSeries = new XyDataSeries <double, double> {
                        SeriesName = "Series " + (i + 1)
                    };
                    dataSeries.Append(DashboardDataHelper.XValues, DashboardDataHelper.YValues[i]);

                    var rSeries = new StackedColumnRenderableSeries
                    {
                        DataSeries     = dataSeries,
                        StrokeStyle    = penBuilder.WithColor(new Color(SeriesColors[i * 2])).WithThickness(1f, ComplexUnitType.Dip).Build(),
                        FillBrushStyle = new LinearGradientBrushStyle(0, 0, 0, 1, new Color(SeriesColors[i * 2 + 1]), new Color(SeriesColors[i * 2]), TileMode.Clamp)
                    };
                    seriesCollection.Add(rSeries);
                }

                const string name = "Stacked columns side-by-side";

                return(new ChartTypeModel(seriesCollection, name));
            }
            public static ChartTypeModel NewHorizontallyStackedColumns(Context context)
            {
                var seriesCollection = new HorizontallyStackedColumnsCollection();

                for (var i = 0; i < 5; i++)
                {
                    var dataSeries = new XyDataSeries <double, double> {
                        SeriesName = "Series " + (i + 1)
                    };
                    dataSeries.Append(DashboardDataHelper.XValues, DashboardDataHelper.YValues[i]);

                    var rSeries = new StackedColumnRenderableSeries
                    {
                        DataSeries     = dataSeries,
                        StrokeStyle    = new SolidPenStyle(context, new Color(SeriesColors[i * 2])),
                        FillBrushStyle = new LinearGradientBrushStyle(0, 0, 0, 1, new Color(SeriesColors[i * 2 + 1]), new Color(SeriesColors[i * 2]))
                    };
                    seriesCollection.Add(rSeries);
                }

                const string name = "Stacked columns side-by-side";

                return(new ChartTypeModel(seriesCollection, name));
            }
        protected override void InitExample()
        {
            var xAxis = new NumericAxis(Activity)
            {
                AutoTicks      = false,
                MajorDelta     = 1d.FromComparable(),
                MinorDelta     = 0.5d.FromComparable(),
                DrawMajorBands = true,
                LabelProvider  = new YearsLabelProvider(),
            };
            var yAxis = new NumericAxis(Activity)
            {
                AutoRange      = AutoRange.Always,
                AxisTitle      = "billions of People",
                GrowBy         = new DoubleRange(0, 0.1),
                DrawMajorBands = true,
            };

            var china          = new[] { 1.269, 1.330, 1.356, 1.304 };
            var india          = new[] { 1.004, 1.173, 1.236, 1.656 };
            var usa            = new[] { 0.282, 0.310, 0.319, 0.439 };
            var indonesia      = new[] { 0.214, 0.243, 0.254, 0.313 };
            var brazil         = new[] { 0.176, 0.201, 0.203, 0.261 };
            var pakistan       = new[] { 0.146, 0.184, 0.196, 0.276 };
            var nigeria        = new[] { 0.123, 0.152, 0.177, 0.264 };
            var bangladesh     = new[] { 0.130, 0.156, 0.166, 0.234 };
            var russia         = new[] { 0.147, 0.139, 0.142, 0.109 };
            var japan          = new[] { 0.126, 0.127, 0.127, 0.094 };
            var restOfTheWorld = new[] { 2.466, 2.829, 3.005, 4.306 };

            var chinaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "China"
            };
            var indiaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "India"
            };
            var usaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "USA"
            };
            var indonesiaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Indonesia"
            };
            var brazilDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Brazil"
            };
            var pakistanDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Pakistan"
            };
            var nigeriaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Nigeria"
            };
            var bangladeshDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Bangladesh"
            };
            var russiaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Russia"
            };
            var japanDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Japan"
            };
            var restOfTheWorldDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Rest Of The World"
            };
            var totalDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Total"
            };

            for (var i = 0; i < 4; i++)
            {
                double xValue = i;
                chinaDataSeries.Append(xValue, china[i]);
                if (i != 2)
                {
                    indiaDataSeries.Append(xValue, india[i]);
                    usaDataSeries.Append(xValue, usa[i]);
                    indonesiaDataSeries.Append(xValue, indonesia[i]);
                    brazilDataSeries.Append(xValue, brazil[i]);
                }
                else
                {
                    indiaDataSeries.Append(xValue, Double.NaN);
                    usaDataSeries.Append(xValue, Double.NaN);
                    indonesiaDataSeries.Append(xValue, Double.NaN);
                    brazilDataSeries.Append(xValue, Double.NaN);
                }
                pakistanDataSeries.Append(xValue, pakistan[i]);
                nigeriaDataSeries.Append(xValue, nigeria[i]);
                bangladeshDataSeries.Append(xValue, bangladesh[i]);
                russiaDataSeries.Append(xValue, russia[i]);
                japanDataSeries.Append(xValue, japan[i]);
                restOfTheWorldDataSeries.Append(xValue, restOfTheWorld[i]);
                totalDataSeries.Append(xValue, china[i] + india[i] + usa[i] + indonesia[i] + brazil[i] + pakistan[i] + nigeria[i] + bangladesh[i] + russia[i] + japan[i] + restOfTheWorld[i]);
            }

            var columnsCollection = new HorizontallyStackedColumnsCollection();

            columnsCollection.Add(GetRenderableSeries(chinaDataSeries, 0xff3399ff, 0xff2D68BC));
            columnsCollection.Add(GetRenderableSeries(indiaDataSeries, 0xff014358, 0xff013547));
            columnsCollection.Add(GetRenderableSeries(usaDataSeries, 0xff1f8a71, 0xff1B5D46));
            columnsCollection.Add(GetRenderableSeries(indonesiaDataSeries, 0xffbdd63b, 0xff7E952B));
            columnsCollection.Add(GetRenderableSeries(brazilDataSeries, 0xffffe00b, 0xffAA8F0B));
            columnsCollection.Add(GetRenderableSeries(pakistanDataSeries, 0xfff27421, 0xffA95419));
            columnsCollection.Add(GetRenderableSeries(nigeriaDataSeries, 0xffbb0000, 0xff840000));
            columnsCollection.Add(GetRenderableSeries(bangladeshDataSeries, 0xff550033, 0xff370018));
            columnsCollection.Add(GetRenderableSeries(russiaDataSeries, 0xff339933, 0xff2D732D));
            columnsCollection.Add(GetRenderableSeries(japanDataSeries, 0xff00aba9, 0xff006C6A));
            columnsCollection.Add(GetRenderableSeries(restOfTheWorldDataSeries, 0xff560068, 0xff3D0049));

            var legendModifier = new LegendModifier(Activity);

            legendModifier.SetLegendPosition(GravityFlags.Top | GravityFlags.Left, 10);

            using (Surface.SuspendUpdates())
            {
                Surface.XAxes.Add(xAxis);
                Surface.YAxes.Add(yAxis);
                Surface.RenderableSeries.Add(columnsCollection);
                Surface.ChartModifiers.Add(legendModifier);
                Surface.ChartModifiers.Add(new TooltipModifier());
            }
        }
Beispiel #4
0
        protected override void InitExample()
        {
            var xAxis = new NumericAxis(Activity);
            var yAxis = new NumericAxis(Activity);

            var porkData     = new double[] { 10, 13, 7, 16, 4, 6, 20, 14, 16, 10, 24, 11 };
            var vealData     = new double[] { 12, 17, 21, 15, 19, 18, 13, 21, 22, 20, 5, 10 };
            var tomatoesData = new double[] { 7, 30, 27, 24, 21, 15, 17, 26, 22, 28, 21, 22 };
            var cucumberData = new double[] { 16, 10, 9, 8, 22, 14, 12, 27, 25, 23, 17, 17 };
            var pepperData   = new double[] { 7, 24, 21, 11, 19, 17, 14, 27, 26, 22, 28, 16 };

            var ds1 = new XyDataSeries <double, double> {
                SeriesName = "Pork Series"
            };
            var ds2 = new XyDataSeries <double, double> {
                SeriesName = "Veal Series"
            };
            var ds3 = new XyDataSeries <double, double> {
                SeriesName = "Tomato Series"
            };
            var ds4 = new XyDataSeries <double, double> {
                SeriesName = "Cucumber Series"
            };
            var ds5 = new XyDataSeries <double, double> {
                SeriesName = "Pepper Series"
            };

            const int data = 1992;

            for (var i = 0; i < porkData.Length; i++)
            {
                ds1.Append(data + i, porkData[i]);
                ds2.Append(data + i, vealData[i]);
                ds3.Append(data + i, tomatoesData[i]);
                ds4.Append(data + i, cucumberData[i]);
                ds5.Append(data + i, pepperData[i]);
            }

            var porkSeries     = GetRenderableSeries(ds1, Color.Rgb(0x22, 0x57, 0x9D), Color.Rgb(0x22, 0x6f, 0xb7));
            var vealSeries     = GetRenderableSeries(ds1, Color.Rgb(0xBE, 0x64, 0x2D), Color.Rgb(0xff, 0x9a, 0x2e));
            var tomatoSeries   = GetRenderableSeries(ds1, Color.Rgb(0xA3, 0x36, 0x31), Color.Rgb(0xdc, 0x44, 0x3f));
            var cucumberSeries = GetRenderableSeries(ds1, Color.Rgb(0x73, 0x95, 0x3D), Color.Rgb(0xaa, 0xd3, 0x4f));
            var pepperSeries   = GetRenderableSeries(ds1, Color.Rgb(0x64, 0x45, 0x8A), Color.Rgb(0x85, 0x62, 0xb4));

            var verticalCollection1 = new VerticallyStackedColumnsCollection();

            verticalCollection1.Add(porkSeries);
            verticalCollection1.Add(vealSeries);

            var verticalCollection2 = new VerticallyStackedColumnsCollection();

            verticalCollection2.Add(tomatoSeries);
            verticalCollection2.Add(cucumberSeries);
            verticalCollection2.Add(pepperSeries);

            var columnsCollection = new HorizontallyStackedColumnsCollection();

            columnsCollection.Add(verticalCollection1);
            columnsCollection.Add(verticalCollection2);

            using (Surface.SuspendUpdates())
            {
                Surface.XAxes.Add(xAxis);
                Surface.YAxes.Add(yAxis);
                Surface.RenderableSeries.Add(columnsCollection);

                Surface.ChartModifiers = new ChartModifierCollection
                {
                    new RolloverModifier(),
                    new ZoomExtentsModifier(),
                };
            }
        }
Beispiel #5
0
        protected override void InitExample()
        {
            var xAxis = new NumericAxis(Activity)
            {
                AutoTicks = false,
                //MajorDelta = 1,
                //MinorDelta = 0.5,
                DrawMajorBands = true,
                //LabelProvider = new YearsLabelProvider(),
            };
            var yAxis = new NumericAxis(Activity)
            {
                AutoRange      = AutoRange.Always,
                AxisTitle      = "billions of People",
                GrowBy         = new DoubleRange(0, 0.1),
                DrawMajorBands = true,
            };

            var china          = new[] { 1.269, 1.330, 1.356, 1.304 };
            var india          = new[] { 1.004, 1.173, 1.236, 1.656 };
            var usa            = new[] { 0.282, 0.310, 0.319, 0.439 };
            var indonesia      = new[] { 0.214, 0.243, 0.254, 0.313 };
            var brazil         = new[] { 0.176, 0.201, 0.203, 0.261 };
            var pakistan       = new[] { 0.146, 0.184, 0.196, 0.276 };
            var nigeria        = new[] { 0.123, 0.152, 0.177, 0.264 };
            var bangladesh     = new[] { 0.130, 0.156, 0.166, 0.234 };
            var russia         = new[] { 0.147, 0.139, 0.142, 0.109 };
            var japan          = new[] { 0.126, 0.127, 0.127, 0.094 };
            var restOfTheWorld = new[] { 2.466, 2.829, 3.005, 4.306 };

            var chinaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "China"
            };
            var indiaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "India"
            };
            var usaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "USA"
            };
            var indonesiaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Indonesia"
            };
            var brazilDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Brazil"
            };
            var pakistanDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Pakistan"
            };
            var nigeriaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Nigeria"
            };
            var bangladeshDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Bangladesh"
            };
            var russiaDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Russia"
            };
            var japanDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Japan"
            };
            var restOfTheWorldDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Rest Of The World"
            };
            var totalDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Total"
            };

            for (var i = 0; i < 4; i++)
            {
                double xValue = i;
                chinaDataSeries.Append(xValue, china[i]);
                if (i != 2)
                {
                    indiaDataSeries.Append(xValue, india[i]);
                    usaDataSeries.Append(xValue, usa[i]);
                    indonesiaDataSeries.Append(xValue, indonesia[i]);
                    brazilDataSeries.Append(xValue, brazil[i]);
                }
                else
                {
                    indiaDataSeries.Append(xValue, Double.NaN);
                    usaDataSeries.Append(xValue, Double.NaN);
                    indonesiaDataSeries.Append(xValue, Double.NaN);
                    brazilDataSeries.Append(xValue, Double.NaN);
                }
                pakistanDataSeries.Append(xValue, pakistan[i]);
                nigeriaDataSeries.Append(xValue, nigeria[i]);
                bangladeshDataSeries.Append(xValue, bangladesh[i]);
                russiaDataSeries.Append(xValue, russia[i]);
                japanDataSeries.Append(xValue, japan[i]);
                restOfTheWorldDataSeries.Append(xValue, restOfTheWorld[i]);
                totalDataSeries.Append(xValue, china[i] + india[i] + usa[i] + indonesia[i] + brazil[i] + pakistan[i] + nigeria[i] + bangladesh[i] + russia[i] + japan[i] + restOfTheWorld[i]);
            }

            var columnsCollection = new HorizontallyStackedColumnsCollection();

            columnsCollection.Add(GetRenderableSeries(chinaDataSeries, Color.Rgb(0x2D, 0x68, 0xBC), Color.Rgb(0x33, 0x99, 0xff)));
            columnsCollection.Add(GetRenderableSeries(indiaDataSeries, Color.Rgb(0x01, 0x35, 0x47), Color.Rgb(0x01, 0x43, 0x58)));
            columnsCollection.Add(GetRenderableSeries(usaDataSeries, Color.Rgb(0x1B, 0x5D, 0x46), Color.Rgb(0x1f, 0x8a, 0x71)));
            columnsCollection.Add(GetRenderableSeries(indonesiaDataSeries, Color.Rgb(0x7E, 0x95, 0x2B), Color.Rgb(0xbd, 0xd6, 0x3b)));
            columnsCollection.Add(GetRenderableSeries(brazilDataSeries, Color.Rgb(0xAA, 0x8F, 0x0B), Color.Rgb(0xff, 0xe0, 0x0b)));
            columnsCollection.Add(GetRenderableSeries(pakistanDataSeries, Color.Rgb(0xA9, 0x54, 0x19), Color.Rgb(0xf2, 0x74, 0x21)));
            columnsCollection.Add(GetRenderableSeries(nigeriaDataSeries, Color.Rgb(0x84, 0x00, 0x00), Color.Rgb(0xbb, 0x00, 0x00)));
            columnsCollection.Add(GetRenderableSeries(bangladeshDataSeries, Color.Rgb(0x37, 0x00, 0x18), Color.Rgb(0x55, 0x00, 0x33)));
            columnsCollection.Add(GetRenderableSeries(russiaDataSeries, Color.Rgb(0x2D, 0x73, 0x2D), Color.Rgb(0x33, 0x99, 0x33)));
            columnsCollection.Add(GetRenderableSeries(japanDataSeries, Color.Rgb(0x00, 0x6C, 0x6A), Color.Rgb(0x00, 0xab, 0xa9)));
            columnsCollection.Add(GetRenderableSeries(restOfTheWorldDataSeries, Color.Rgb(0x3D, 0x00, 0x49), Color.Rgb(0x56, 0x00, 0x68)));

            using (Surface.SuspendUpdates())
            {
                Surface.XAxes.Add(xAxis);
                Surface.YAxes.Add(yAxis);
                Surface.RenderableSeries.Add(columnsCollection);

                Surface.ChartModifiers = new ChartModifierCollection {
                    new TooltipModifier()
                };
            }
        }
Beispiel #6
0
        protected override void InitExample()
        {
            var xAxis = new NumericAxis(Activity);
            var yAxis = new NumericAxis(Activity);

            var porkData     = new double[] { 10, 13, 7, 16, 4, 6, 20, 14, 16, 10, 24, 11 };
            var vealData     = new double[] { 12, 17, 21, 15, 19, 18, 13, 21, 22, 20, 5, 10 };
            var tomatoesData = new double[] { 7, 30, 27, 24, 21, 15, 17, 26, 22, 28, 21, 22 };
            var cucumberData = new double[] { 16, 10, 9, 8, 22, 14, 12, 27, 25, 23, 17, 17 };
            var pepperData   = new double[] { 7, 24, 21, 11, 19, 17, 14, 27, 26, 22, 28, 16 };

            var ds1 = new XyDataSeries <double, double> {
                SeriesName = "Pork Series"
            };
            var ds2 = new XyDataSeries <double, double> {
                SeriesName = "Veal Series"
            };
            var ds3 = new XyDataSeries <double, double> {
                SeriesName = "Tomato Series"
            };
            var ds4 = new XyDataSeries <double, double> {
                SeriesName = "Cucumber Series"
            };
            var ds5 = new XyDataSeries <double, double> {
                SeriesName = "Pepper Series"
            };

            const int data = 1992;

            for (var i = 0; i < porkData.Length; i++)
            {
                ds1.Append(data + i, porkData[i]);
                ds2.Append(data + i, vealData[i]);
                ds3.Append(data + i, tomatoesData[i]);
                ds4.Append(data + i, cucumberData[i]);
                ds5.Append(data + i, pepperData[i]);
            }

            var porkSeries     = GetRenderableSeries(ds1, 0xFF22579D, 0xFF226FB7);
            var vealSeries     = GetRenderableSeries(ds2, 0xFFBE642D, 0xFFFF9A2E);
            var tomatoSeries   = GetRenderableSeries(ds3, 0xFFA33631, 0xFFDC443F);
            var cucumberSeries = GetRenderableSeries(ds4, 0xFF73953D, 0xFFAAD34F);
            var pepperSeries   = GetRenderableSeries(ds5, 0xFF64458A, 0xFF8562B4);

            var verticalCollection1 = new VerticallyStackedColumnsCollection();

            verticalCollection1.Add(porkSeries);
            verticalCollection1.Add(vealSeries);

            var verticalCollection2 = new VerticallyStackedColumnsCollection();

            verticalCollection2.Add(tomatoSeries);
            verticalCollection2.Add(cucumberSeries);
            verticalCollection2.Add(pepperSeries);

            var columnsCollection = new HorizontallyStackedColumnsCollection();

            columnsCollection.Add(verticalCollection1);
            columnsCollection.Add(verticalCollection2);

            using (Surface.SuspendUpdates())
            {
                Surface.XAxes.Add(xAxis);
                Surface.YAxes.Add(yAxis);
                Surface.RenderableSeries.Add(columnsCollection);
                Surface.ChartModifiers = new ChartModifierCollection
                {
                    new RolloverModifier(),
                    new ZoomExtentsModifier(),
                };

                new WaveAnimatorBuilder(porkSeries)
                {
                    Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350
                }.Start();
                new WaveAnimatorBuilder(vealSeries)
                {
                    Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350
                }.Start();
                new WaveAnimatorBuilder(tomatoSeries)
                {
                    Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350
                }.Start();
                new WaveAnimatorBuilder(cucumberSeries)
                {
                    Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350
                }.Start();
                new WaveAnimatorBuilder(pepperSeries)
                {
                    Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350
                }.Start();
            }
        }