private void InitializeUIHandlers()
        {
            ((UsingThemeManagerLayout)View).SelectThemeButton.TouchUpInside += (sender, args) =>
            {
                var actionSheetAlert = UIAlertController.Create("Select Theme", null, UIAlertControllerStyle.ActionSheet);

                foreach (var themeName in ThemeNames)
                {
                    var themeAction = UIAlertAction.Create(themeName, UIAlertActionStyle.Default, action =>
                    {
                        SCIThemeManager.ApplyTheme(Surface, ThemeKeys[Array.IndexOf(ThemeNames, themeName)]);
                        ((UsingThemeManagerLayout)View).SelectThemeButton.SetTitle(themeName, UIControlState.Normal);
                    });
                    actionSheetAlert.AddAction(themeAction);
                }

                actionSheetAlert.AddAction(UIAlertAction.Create("Cansel", UIAlertActionStyle.Cancel, null));

                if (actionSheetAlert.PopoverPresentationController != null)
                {
                    actionSheetAlert.PopoverPresentationController.SourceView = View;
                    actionSheetAlert.PopoverPresentationController.SourceRect = ((UIButton)sender).Frame;
                }

                ((UsingThemeManagerLayout)View).Window.RootViewController.PresentViewController(actionSheetAlert, true, null);
            };
        }
        protected override void InitExample()
        {
            InitializeChartAndData();

            // Apply a theme to the chart
            // The custom theme is named SciChart_BerryBlue and is included as a .plist in the application resources
            // The .plist contains all the keys for theme colors and brushes and styles to apply to the chart
            SCIThemeManager.ApplyTheme(Surface, SCIChart_BerryBlueStyleKey);
        }
Example #3
0
        private void InitializeGraph()
        {
            // init shared resources
            var oxygenColor      = UIColor.Blue;
            var temperatureColor = UIColor.Red;
            var pressureColor    = UIColor.Green;

            // init surface
            _chartSurface = new SCIChartSurface()
            {
                RenderableSeriesAreaBorderStyle = new SCISolidPenStyle(UIColor.Black, 0)
            };

            // init axes
            var dateAxis = new SCIDateAxis()
            {
                AutoRange          = _native.IsZoomable ? SCIAutoRange.Once : SCIAutoRange.Always,
                GrowBy             = new SCIDoubleRange(0.05, 0.05),
                DrawMinorGridLines = false,
                TickLabelStyle     = new SCIFontStyle(14, UIColor.Black),
                TitleStyle         = new SCIFontStyle(14, UIColor.Black),
                AxisId             = X_AXIS_ID
            };
            var oxygenAxis = new SCINumericAxis()
            {
                AutoRange          = _native.IsZoomable ? SCIAutoRange.Once : SCIAutoRange.Always,
                AxisAlignment      = SCIAxisAlignment.Left,
                GrowBy             = new SCIDoubleRange(0.05, 0.05),
                AxisId             = OXYGEN_AXIS_ID,
                AxisTitle          = "Oxygen",
                IsVisible          = _native.IsOxygenVisible,
                TickLabelStyle     = new SCIFontStyle(14, oxygenColor),
                TitleStyle         = new SCIFontStyle(14, oxygenColor),
                DrawMinorGridLines = false,
                IsPrimaryAxis      = true
            };
            var temperatureAxis = new SCINumericAxis()
            {
                AutoRange          = _native.IsZoomable ? SCIAutoRange.Once : SCIAutoRange.Always,
                AxisAlignment      = SCIAxisAlignment.Right,
                GrowBy             = new SCIDoubleRange(0.05, 0.05),
                AxisId             = TEMPERATURE_AXIS_ID,
                AxisTitle          = "Temperature",
                IsVisible          = _native.IsTemperatureVisible,
                TickLabelStyle     = new SCIFontStyle(14, temperatureColor),
                TitleStyle         = new SCIFontStyle(14, temperatureColor),
                DrawMinorGridLines = false,
                IsPrimaryAxis      = false
            };
            var pressureAxis = new SCINumericAxis()
            {
                AutoRange          = _native.IsZoomable ? SCIAutoRange.Once : SCIAutoRange.Always,
                AxisAlignment      = SCIAxisAlignment.Right,
                GrowBy             = new SCIDoubleRange(0.05, 0.05),
                AxisId             = PRESSURE_AXIS_ID,
                AxisTitle          = "Pressure",
                IsVisible          = _native.IsPressureVisible,
                TickLabelStyle     = new SCIFontStyle(14, pressureColor),
                TitleStyle         = new SCIFontStyle(14, pressureColor),
                DrawMinorGridLines = false,
                IsPrimaryAxis      = false
            };

            // init data
            _oxygenData = new XyDataSeries <DateTime, double> {
                SeriesName = "Oxygen"
            };
            _temperatureData = new XyDataSeries <DateTime, double> {
                SeriesName = "Temperature"
            };
            _pressureData = new XyDataSeries <DateTime, double> {
                SeriesName = "Pressure"
            };

            // init series
            _oxygenSeries = new SCIFastLineRenderableSeries
            {
                XAxisId     = X_AXIS_ID,
                YAxisId     = OXYGEN_AXIS_ID,
                DataSeries  = _oxygenData,
                IsVisible   = _native.IsOxygenVisible,
                StrokeStyle = new SCISolidPenStyle(oxygenColor, 1.5f)
            };
            _temperatureSeries = new SCIFastLineRenderableSeries
            {
                XAxisId     = X_AXIS_ID,
                YAxisId     = TEMPERATURE_AXIS_ID,
                DataSeries  = _temperatureData,
                IsVisible   = _native.IsTemperatureVisible,
                StrokeStyle = new SCISolidPenStyle(temperatureColor, 1.5f)
            };
            _pressureSeries = new SCIFastLineRenderableSeries
            {
                XAxisId     = X_AXIS_ID,
                YAxisId     = PRESSURE_AXIS_ID,
                DataSeries  = _pressureData,
                IsVisible   = _native.IsPressureVisible,
                StrokeStyle = new SCISolidPenStyle(pressureColor, 1.5f)
            };

            // add chart components to chart
            _chartSurface.XAxes.Add(dateAxis);
            _chartSurface.YAxes.Add(oxygenAxis);
            _chartSurface.YAxes.Add(temperatureAxis);
            _chartSurface.YAxes.Add(pressureAxis);
            _chartSurface.RenderableSeries.Add(_oxygenSeries);
            _chartSurface.RenderableSeries.Add(_temperatureSeries);
            _chartSurface.RenderableSeries.Add(_pressureSeries);

            // apply theme
            SCIThemeManager.ApplyTheme(_chartSurface, SCIThemeManager.Bright_Spark);

            // add modifiers
            if (_native.IsZoomable)
            {
                _chartSurface.ChartModifiers = new SCIChartModifierCollection
                {
                    new SCIZoomPanModifier()
                    {
                        ClipModeX    = SCIClipMode.None,
                        ClipModeY    = SCIClipMode.None,
                        ZoomExtentsY = false
                    },
                    new SCIPinchZoomModifier()
                    {
                        Direction = SCIDirection2D.XyDirection
                    },
                    new SCIZoomExtentsModifier
                    {
                        IsAnimated = true
                    }
                };
            }

            // load!
            SetNativeControl(_chartSurface);
        }
Example #4
0
        protected override void InitExample()
        {
            var xAxis = new SCINumericAxis {
                GrowBy = new SCIDoubleRange(0.1, 0.1), VisibleRange = new SCIDoubleRange(150, 180)
            };

            var yRightAxis = new SCINumericAxis
            {
                GrowBy        = new SCIDoubleRange(0.1, 0.1),
                AxisAlignment = SCIAxisAlignment.Right,
                AutoRange     = SCIAutoRange.Always,
                AxisId        = "PrimaryAxisId",
                Style         =
                {
                    DrawMajorTicks = false,
                    DrawMinorTicks = false,
                },
                LabelProvider = new ThousandsLabelProvider()
            };

            var yLeftAxis = new SCINumericAxis
            {
                GrowBy        = new SCIDoubleRange(0, 3d),
                AxisAlignment = SCIAxisAlignment.Left,
                AutoRange     = SCIAutoRange.Always,
                AxisId        = "SecondaryAxisId",
                Style         =
                {
                    DrawMajorTicks = false,
                    DrawMinorTicks = false,
                },
                LabelProvider = new BillionsLabelProvider()
            };

            var dataManager = DataManager.Instance;
            var priceBars   = dataManager.GetPriceDataIndu();

            var mountainDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Mountain Series"
            };
            var lineDataSeries = new XyDataSeries <double, double> {
                SeriesName = "Line Series"
            };
            var columnDataSeries = new XyDataSeries <double, long> {
                SeriesName = "Column Series"
            };
            var candlestickDataSeries = new OhlcDataSeries <double, double> {
                SeriesName = "Candlestick Series"
            };

            var xValues = Enumerable.Range(0, priceBars.Count).Select(x => (double)x).ToArray();

            mountainDataSeries.Append(xValues, priceBars.LowData.Select(x => x - 1000d));
            lineDataSeries.Append(xValues, dataManager.ComputeMovingAverage(priceBars.CloseData, 50));
            columnDataSeries.Append(xValues, priceBars.VolumeData);
            candlestickDataSeries.Append(xValues, priceBars.OpenData, priceBars.HighData, priceBars.LowData, priceBars.CloseData);

            var mountainRenderableSeries = new SCIFastMountainRenderableSeries {
                DataSeries = mountainDataSeries, YAxisId = "PrimaryAxisId"
            };
            var lineRenderableSeries = new SCIFastLineRenderableSeries {
                DataSeries = lineDataSeries, YAxisId = "PrimaryAxisId"
            };
            var columnRenderableSeries = new SCIFastColumnRenderableSeries {
                DataSeries = columnDataSeries, YAxisId = "SecondaryAxisId"
            };
            var candlestickRenderableSeries = new SCIFastCandlestickRenderableSeries {
                DataSeries = candlestickDataSeries, YAxisId = "PrimaryAxisId"
            };

            using (Surface.SuspendUpdates())
            {
                Surface.XAxes.Add(xAxis);
                Surface.YAxes.Add(yRightAxis);
                Surface.YAxes.Add(yLeftAxis);
                Surface.RenderableSeries.Add(mountainRenderableSeries);
                Surface.RenderableSeries.Add(lineRenderableSeries);
                Surface.RenderableSeries.Add(columnRenderableSeries);
                Surface.RenderableSeries.Add(candlestickRenderableSeries);
                Surface.ChartModifiers = new SCIChartModifierCollection
                {
                    new SCILegendModifier {
                        ShowCheckBoxes = false
                    },
                    new SCICursorModifier(),
                    new SCIZoomExtentsModifier()
                };
            }

            SCIThemeManager.ApplyTheme(Surface, customThemeKey);
        }
Example #5
0
        protected override void InitExample()
        {
            var dataSeries = new OhlcDataSeries <DateTime, double>();

            var marketDataService = new MarketDataService(new DateTime(2000, 08, 01, 12, 00, 00), 5, 5);
            var data = marketDataService.GetHistoricalData(200);

            dataSeries.Append(data.Select(x => x.DateTime), data.Select(x => x.Open), data.Select(x => x.High), data.Select(x => x.Low), data.Select(x => x.Close));

            Surface.XAxes.Add(new SCICategoryDateTimeAxis());
            Surface.YAxes.Add(new SCINumericAxis {
                VisibleRange = new SCIDoubleRange(30, 37)
            });
            Surface.RenderableSeries.Add(new SCIFastCandlestickRenderableSeries {
                DataSeries = dataSeries
            });
            Surface.ChartModifiers = new SCIChartModifierCollection
            {
                new SCIZoomPanModifier(),
                new SCIPinchZoomModifier(),
                new SCIZoomExtentsModifier()
            };
            SCIThemeManager.ApplyDefaultTheme(Surface);

            var horizontalLine1 = new SCIHorizontalLineAnnotation
            {
                X1Value             = 150,
                Y1Value             = 32.2,
                HorizontalAlignment = SCIHorizontalLineAnnotationAlignment.Right,
                Style = new SCILineAnnotationStyle {
                    LinePen = new SCISolidPenStyle(ColorUtil.Red, 2f)
                },
                IsEditable = true
            };

            horizontalLine1.AddLabel(new SCILineAnnotationLabel
            {
                Style =
                {
                    TextStyle       = new SCITextFormattingStyle {
                        Color       = UIColor.White
                    },
                    LabelPlacement  = SCILabelPlacement.Axis,
                    BackgroundColor = ColorUtil.Red.ToColor()
                }
            });

            var horizontalLine2 = new SCIHorizontalLineAnnotation
            {
                X1Value             = 130,
                X2Value             = 160,
                Y1Value             = 33.9,
                HorizontalAlignment = SCIHorizontalLineAnnotationAlignment.Center,
                Style = new SCILineAnnotationStyle {
                    LinePen = new SCISolidPenStyle(ColorUtil.Blue, 2f)
                },
                IsEditable = true,
            };

            horizontalLine2.AddLabel(new SCILineAnnotationLabel
            {
                Style =
                {
                    TextStyle       = new SCITextFormattingStyle {
                        Color       = UIColor.Blue
                    },
                    LabelPlacement  = SCILabelPlacement.Top,
                    BackgroundColor = UIColor.Clear
                },
                Text = "Top",
            });
            horizontalLine2.AddLabel(new SCILineAnnotationLabel
            {
                Style =
                {
                    TextStyle       = new SCITextFormattingStyle {
                        Color       = UIColor.Blue
                    },
                    LabelPlacement  = SCILabelPlacement.Left,
                    BackgroundColor = UIColor.Clear
                },
                Text = "Left",
            });
            horizontalLine2.AddLabel(new SCILineAnnotationLabel
            {
                Style =
                {
                    TextStyle       = new SCITextFormattingStyle {
                        Color       = UIColor.Blue
                    },
                    LabelPlacement  = SCILabelPlacement.Right,
                    BackgroundColor = UIColor.Clear
                },
                Text = "Right",
            });

            var verticalLine1 = new SCIVerticalLineAnnotation
            {
                X1Value           = 40,
                Y1Value           = 34,
                VerticalAlignment = SCIVerticalLineAnnotationAlignment.Top,
                Style             = new SCILineAnnotationStyle {
                    LinePen = new SCISolidPenStyle(ColorUtil.Green, 2f)
                },
                IsEditable = true,
            };

            verticalLine1.AddLabel(new SCILineAnnotationLabel
            {
                Style =
                {
                    TextStyle       = new SCITextFormattingStyle {
                        Color       = UIColor.Green
                    },
                    LabelPlacement  = SCILabelPlacement.Top,
                    BackgroundColor = UIColor.Clear
                },
            });

            Surface.Annotations = new SCIAnnotationCollection
            {
                new SCITextAnnotation
                {
                    CoordinateMode        = SCIAnnotationCoordinateMode.Relative,
                    HorizontalAnchorPoint = SCIHorizontalAnchorPoint.Center,
                    Text    = "EUR.USD",
                    X1Value = 0.5,
                    Y1Value = 0.5,
                    Style   = new SCITextAnnotationStyle
                    {
                        TextColor = 0x77FFFFFF.ToColor(),
                        TextStyle = new SCITextFormattingStyle {
                            FontSize = 72
                        },
                        BackgroundColor = UIColor.Clear
                    },
                },
                new SCITextAnnotation
                {
                    CoordinateMode        = SCIAnnotationCoordinateMode.Absolute,
                    IsEditable            = true,
                    EditableText          = false,
                    Text                  = "Buy!",
                    X1Value               = 10d,
                    Y1Value               = 30.5d,
                    VerticalAnchorPoint   = SCIVerticalAnchorPoint.Bottom,
                    HorizontalAnchorPoint = SCIHorizontalAnchorPoint.Left,
                    Style                 =
                    {
                        TextStyle       = { FontSize = 20 },
                        TextColor       = ColorUtil.White.ToColor(),
                        BackgroundColor = UIColor.Clear
                    },
                },
                new SCITextAnnotation
                {
                    CoordinateMode = SCIAnnotationCoordinateMode.Absolute,
                    IsEditable     = true,
                    EditableText   = false,
                    Text           = "Sell!",
                    X1Value        = 50d,
                    Y1Value        = 34d,
                    Style          =
                    {
                        TextStyle       = { FontSize = 20 },
                        TextColor       = ColorUtil.White.ToColor(),
                        BackgroundColor = 0x33FF3333.ToColor()
                    },
                },
                new SCIBoxAnnotation
                {
                    IsEditable = true,
                    Style      =
                    {
                        FillBrush = new SCISolidBrushStyle(UIColor.FromRGBA(0xFF, 0x66, 0x00, 0x33)),
                        BorderPen = new SCISolidPenStyle(UIColor.FromRGBA(0xFF,   0x66, 0x00,  0x77), 1.0f)
                    },
                    X1Value = 50,
                    Y1Value = 35.5,
                    X2Value = 120,
                    Y2Value = 32,
                },
                new SCILineAnnotation
                {
                    IsEditable = true,
                    Style      = { LinePen = new SCISolidPenStyle(0xAAFF6600, 2f) },
                    X1Value    = 40,
                    Y1Value    = 30.5,
                    X2Value    = 60,
                    Y2Value    = 33.5,
                },
                new SCILineAnnotation
                {
                    IsEditable = true,
                    Style      = { LinePen = new SCISolidPenStyle(0xAAFF6600, 2f) },
                    X1Value    = 120,
                    Y1Value    = 30.5,
                    X2Value    = 175,
                    Y2Value    = 36,
                },
                // TODO LineArrow annotaiton
                new SCILineAnnotation
                {
                    IsEditable = true,
                    Style      = { LinePen = new SCISolidPenStyle(0xAAFF6600, 2f) },
                    X1Value    = 50,
                    Y1Value    = 35,
                    X2Value    = 80,
                    Y2Value    = 31.4,
                },
                new SCIAxisMarkerAnnotation
                {
                    CoordinateMode = SCIAnnotationCoordinateMode.Absolute,
                    IsEditable     = true,
                    Position       = 32.7,
                },
                new SCIAxisMarkerAnnotation
                {
                    Style          = { AnnotationSurface = SCIAnnotationSurfaceEnum.XAxis },
                    FormattedValue = "Horizontal",
                    IsEditable     = true,
                    Position       = 100,
                },

                horizontalLine1,
                horizontalLine2,
                new SCIVerticalLineAnnotation
                {
                    X1Value           = 20,
                    Y1Value           = 35,
                    Y2Value           = 33,
                    VerticalAlignment = SCIVerticalLineAnnotationAlignment.Center,
                    Style             = new SCILineAnnotationStyle {
                        LinePen = new SCISolidPenStyle(ColorUtil.DarkGreen, 2f)
                    },
                    IsEditable = true,
                },
                verticalLine1,
                new SCITextAnnotation
                {
                    X1Value      = 50,
                    Y1Value      = 37,
                    IsEditable   = true,
                    EditableText = false,
                    Text         = "Rotated text",
                    Style        =
                    {
                        TextStyle       = { FontSize = 20 },
                        TextColor       = ColorUtil.White.ToColor(),
                        BackgroundColor = UIColor.Clear
                    },
                    //RotationAngle = 30
                }
            };
        }