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);
        }
Beispiel #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);
        }
Beispiel #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);
        }