private void InitChart(SCIChartSurface surface, BasePaneModel model, bool isMainPain)
        {
            _axisAreaSizeSync.AttachSurface(surface);

            var xAxis = new SCICategoryDateTimeAxis {
                IsVisible = isMainPain, GrowBy = new SCIDoubleRange(0, 0.05)
            };

            _axisRangeSync.AttachAxis(xAxis);

            using (surface.SuspendUpdates())
            {
                surface.XAxes.Add(xAxis);
                surface.YAxes.Add(model.YAxis);
                surface.RenderableSeries = model.RenderableSeries;
                surface.Annotations      = model.Annotations;

                surface.ChartModifiers = new SCIChartModifierCollection
                {
                    new SCIXAxisDragModifier {
                        DragMode = SCIAxisDragMode.Pan, ClipModeX = SCIClipMode.StretchAtExtents
                    },
                    new SCIPinchZoomModifier {
                        Direction = SCIDirection2D.XDirection
                    },
                    new SCIZoomPanModifier(),
                    new SCIZoomExtentsModifier(),
                    new SCILegendModifier {
                        ShowCheckBoxes = false
                    }
                };
            }
        }
        private void CreateOverviewChart(out SCIBoxAnnotation leftAreaAnnotation, out SCIBoxAnnotation rightAreaAnnotation)
        {
            // Create an XAxis and YAxis for our chart
            var xAxis1 = new SCICategoryDateTimeAxis {
                AutoRange = SCIAutoRange.Always
            };
            var yAxis1 = new SCINumericAxis {
                GrowBy = new SCIDoubleRange(0.1, 0.1), AutoRange = SCIAutoRange.Always
            };

            // Create the mountain chart for the overview , using the same price data but zoomed out
            var mountainSeries = new SCIFastMountainRenderableSeries {
                DataSeries = _ohlcDataSeries, AreaStyle = new SCILinearGradientBrushStyle(0x883a668f, 0xff20384f, SCILinearGradientDirection.Vertical)
            };

            // Create some annotations to visualize the selected area on the main price chart
            leftAreaAnnotation = new SCIBoxAnnotation
            {
                CoordinateMode = SCIAnnotationCoordinateMode.RelativeY,
                Y1Value        = 0,
                Y2Value        = 1,
                Style          = new SCIBoxAnnotationStyle
                {
                    FillBrush = new SCISolidBrushStyle(0x33FFFFFF),
                },
            };

            rightAreaAnnotation = new SCIBoxAnnotation
            {
                CoordinateMode = SCIAnnotationCoordinateMode.RelativeY,
                Y1Value        = 0,
                Y2Value        = 1,
                Style          = new SCIBoxAnnotationStyle
                {
                    FillBrush = new SCISolidBrushStyle(0x33FFFFFF),
                },
            };

            // Populate the chart with Axis, RenderableSeries. The chart automatically updates when any property changes
            using (OverviewSurface.SuspendUpdates())
            {
                OverviewSurface.XAxes.Add(xAxis1);
                OverviewSurface.YAxes.Add(yAxis1);
                OverviewSurface.RenderableSeries.Add(mountainSeries);

                OverviewSurface.Annotations.Add(leftAreaAnnotation);
                OverviewSurface.Annotations.Add(rightAreaAnnotation);
            }
        }
Exemple #3
0
        protected override void InitExample()
        {
            var priceSeries = DataManager.Instance.GetPriceDataIndu();

            var dataSeries = new OhlcDataSeries <DateTime, double>();

            dataSeries.Append(priceSeries.TimeData, priceSeries.OpenData, priceSeries.HighData, priceSeries.LowData, priceSeries.CloseData);

            var size  = priceSeries.Count;
            var xAxis = new SCICategoryDateTimeAxis {
                VisibleRange = new SCIDoubleRange(size - 30, size), GrowBy = new SCIDoubleRange(0, 0.1)
            };
            var yAxis = new SCINumericAxis {
                GrowBy = new SCIDoubleRange(0, 0.1), AutoRange = SCIAutoRange.Always
            };

            var renderSeries = new SCIFastCandlestickRenderableSeries
            {
                DataSeries         = dataSeries,
                StrokeUpStyle      = new SCISolidPenStyle(0xFF00AA00, 1f),
                StrokeDownStyle    = new SCISolidPenStyle(0xFFFF0000, 1f),
                FillUpBrushStyle   = new SCISolidBrushStyle(0x8800AA00),
                FillDownBrushStyle = new SCISolidBrushStyle(0x88FF0000)
            };

            var animation = new SCIWaveRenderableSeriesAnimation(3, SCIAnimationCurve.EaseOut);

            animation.StartAfterDelay(0.3f);
            renderSeries.AddAnimation(animation);

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

                Surface.ChartModifiers = new SCIChartModifierCollection
                {
                    new SCIZoomPanModifier(),
                    new SCIPinchZoomModifier(),
                    new SCIZoomExtentsModifier()
                };
            }
        }
Exemple #4
0
        protected override void InitExampleInternal()
        {
            Surface = new SCIChartSurface(_exampleViewLayout.SciChartSurfaceView);
            StyleHelper.SetSurfaceDefaultStyle(Surface);

            var data = DataManager.Instance.GetPriceDataIndu();

            var dataSeries = new OhlcDataSeries <DateTime, double>(TypeOfSeries.XCategory);

            dataSeries.Append(data.TimeData, data.OpenData, data.HighData, data.LowData, data.CloseData);

            var axisStyle = StyleHelper.GetDefaultAxisStyle();
            var xAxis     = new SCICategoryDateTimeAxis {
                IsXAxis = true, Style = axisStyle
            };
            var yAxis = new SCINumericAxis {
                GrowBy = new SCIDoubleRange(0.1, 0.1), Style = axisStyle
            };

            var renderSeries = new SCIFastCandlestickRenderableSeries
            {
                DataSeries = dataSeries,
                Style      =
                {
                    StrokeUpStyle      = new SCIPenSolid(UIColor.Green,    1f),
                    StrokeDownStyle    = new SCIPenSolid(UIColor.Red,      1f),
                    FillUpBrushStyle   = new SCIBrushSolid(UIColor.Green),
                    FillDownBrushStyle = new SCIBrushSolid(UIColor.Red)
                }
            };

            Surface.AttachAxis(xAxis, true);
            Surface.AttachAxis(yAxis, false);
            Surface.AttachRenderableSeries(renderSeries);

            Surface.ChartModifier = new SCIModifierGroup(new ISCIChartModifierProtocol[]
            {
                new SCIZoomPanModifier(),
                new SCIPinchZoomModifier(),
                new SCIZoomExtentsModifier()
            });

            Surface.InvalidateElement();
        }
        protected override void InitExampleInternal()
        {
            Surface = new SCIChartSurface(_exampleViewLayout.SciChartSurfaceView);
            StyleHelper.SetSurfaceDefaultStyle(Surface);

            var dataSeries = new OhlcDataSeries <DateTime, double>();

            foreach (var priceBar in DataManager.Instance.GetPriceDataIndu().Take(100))
            {
                dataSeries.Append(priceBar.DateTime, priceBar.Open, priceBar.High, priceBar.Low, priceBar.Close);
            }

            var axisStyle = StyleHelper.GetDefaultAxisStyle();
            var xAxis     = new SCICategoryDateTimeAxis {
                IsXAxis = true, VisibleRange = new SCIDoubleRange(0, 199), Style = axisStyle
            };
            var yAxis = new SCINumericAxis {
                VisibleRange = new SCIDoubleRange(30, 37), Style = axisStyle
            };

            Surface.AttachAxis(xAxis, true);
            Surface.AttachAxis(yAxis, false);
            Surface.AttachRenderableSeries(new SCIFastCandlestickRenderableSeries {
                DataSeries = dataSeries
            });

            Surface.Annotation = new SCIAnnotationGroup(new NSObject[]
            {
                new SCITextAnnotation
                {
                    CoordMode = SCIAnnotationCoordMode.Relative,
                    //HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
                    Text      = "EUR.USD",
                    XPosition = 0.5,
                    YPosition = 0.5,
                    Style     =
                    {
                        TextStyle = { FontSize = 72 },
                        TextColor = UIColor.FromRGB(0xFF, 0xFF, 0xFF)
                    }

                    //FontStyle = new FontStyle.Builder(Activity).WithTextSize(72).WithTextColor(Color.Argb(0x77, 0xFF, 0xFF, 0xFF)).Build(),
                },
                new SCITextAnnotation
                {
                    //Editable = true,
                    Text      = "Buy",
                    XPosition = 10d,
                    YPosition = 30.5d,
                    //VerticalAnchorPoint = VerticalAnchorPoint.Bottom,
                    Style =
                    {
                        TextStyle = { FontSize = 20 },
                        TextColor = UIColor.FromRGB(0xFF, 0xFF, 0xFF)
                    }

                    //FontStyle = new FontStyle.Builder(Activity).WithTextSize(20).WithTextColor(Color.White).Build()
                },
                new SCITextAnnotation
                {
                    //Editable = true,
                    Text      = "Sell!",
                    XPosition = 50d,
                    YPosition = 34d,
                    Style     =
                    {
                        BackgroundColor = UIColor.FromRGBA(0x02, 0x00, 0x5a, 0x7f),
                        TextStyle       = { FontSize = 20 },
                        TextColor       = UIColor.FromRGB(0xFF,  0xFF, 0xFF)
                    },
                    //FontStyle = new FontStyle.Builder(Activity).WithTextSize(20).WithTextColor(Color.White).Build(),
                },
                new SCIBoxAnnotation
                {
                    //Editable = true,
                    //Background = Activity.GetDrawable(Resource.Drawable.example_box_annotation_background_4),
                    Style =
                    {
                        FillBrush = new SCIBrushSolid(UIColor.FromRGBA(0x02, 0x00, 0x59, 0x7f)),
                    },
                    XStart = 50,
                    YStart = 35.5,
                    XEnd   = 120,
                    YEnd   = 32,
                },
                new SCILineAnnotation
                {
                    //Editable = true,
                    Style =
                    {
                        LinePen = new SCIPenSolid(UIColor.FromRGBA(0xFF, 0x66, 0x00, 0xAA), 2f),
                    },
                    //Stroke = new PenStyle.Builder(Activity).WithThickness(2f).WithColor(Color.Argb(0xAA, 0xFF, 0x66, 0x00)).Build(),
                    XStart = 40,
                    YStart = 30.5,
                    XEnd   = 60,
                    YEnd   = 33.5,
                },
                new SCILineAnnotation
                {
                    //Editable = true,
                    Style =
                    {
                        LinePen = new SCIPenSolid(UIColor.FromRGBA(0xFF, 0x66, 0x00, 0xAA), 2f),
                    },
                    //Stroke = new PenStyle.Builder(Activity).WithThickness(2f).WithColor(Color.Argb(0xAA, 0xFF, 0x66, 0x00)).Build(),
                    XStart = 120,
                    YStart = 30.5,
                    XEnd   = 175,
                    YEnd   = 36,
                },
                //new LineArrowAnnotation(Activity)
                //{
                //    Editable = true,
                //    HeadLength = 8,
                //    HeadWidth = 16,
                //    X1Value = 50,
                //    Y1Value = 35,
                //    X2Value = 80,
                //    Y2Value = 31.4,
                //},
                new SCIAxisMarkerAnnotation
                {
                    //Editable = true,
                    Position = 32.7,
                    Style    =
                    {
                    }
                },
                //new SCIAxisMarkerAnnotation
                //{
                //    AnnotationSurface = AnnotationSurfaceEnum.XAxis,
                //    FormattedValue = "Horizontal",
                //    Editable = true,
                //    X1Value = 100
                //},
                //new HorizontalLineAnnotation(Activity)
                //{
                //    X1Value = 150,
                //    Y1Value = 32.2,
                //    Stroke = new PenStyle.Builder(Activity).WithThickness(2f).WithColor(Color.Red).Build(),
                //    HorizontalGravity = GravityFlags.Right,
                //    Editable = true
                //},
                //new HorizontalLineAnnotation(Activity)
                //{
                //    X1Value = 130,
                //    X2Value = 160,
                //    Y1Value = 33.9,
                //    Stroke = new PenStyle.Builder(Activity).WithThickness(2f).WithColor(Color.Blue).Build(),
                //    HorizontalGravity = GravityFlags.CenterHorizontal,
                //    Editable = true
                //},
                //new VerticalLineAnnotation(Activity)
                //{
                //    X1Value = 20,
                //    Y1Value = 35,
                //    Y2Value = 33,
                //    Stroke = new PenStyle.Builder(Activity).WithThickness(2f).WithColor(Color.DarkGreen).Build(),
                //    VerticalGravity = GravityFlags.CenterVertical,
                //    Editable = true,

                //},
                //new VerticalLineAnnotation(Activity)
                //{
                //    X1Value = 40,
                //    Y1Value = 34,
                //    Stroke = new PenStyle.Builder(Activity).WithThickness(2f).WithColor(Color.Green).Build(),
                //    VerticalGravity = GravityFlags.Top,
                //    Editable = true,
                //},
                new SCITextAnnotation
                {
                    XPosition = 50,
                    YPosition = 37,
                    //Editable = true,
                    Text = "Rotated text",
                    //FontStyle = new FontStyle.Builder(Activity).WithTextSize(20).WithTextColor(Color.White).Build(),
                    Style =
                    {
                        TextStyle = { FontSize = 20 },
                        TextColor = UIColor.FromRGB(0xFF, 0xFF, 0xFF),
                    },
                    //RotationAngle = 30
                }
            });

            Surface.InvalidateElement();
        }
        private void CreateMainPriceChart()
        {
            // Create an XAxis and YAxis for our chart
            var xAxis = new SCICategoryDateTimeAxis
            {
                Style  = { DrawMajorGridLines = false },
                GrowBy = new SCIDoubleRange(0, 0.1)
            };
            var yAxis = new SCINumericAxis {
                AutoRange = SCIAutoRange.Always
            };

            // Create RenderableSeries to render the data
            var ohlcSeries = new SCIFastOhlcRenderableSeries
            {
                DataSeries      = _ohlcDataSeries,
                StrokeUpStyle   = new SCISolidPenStyle(StrokeUpColor, StrokeThickness),
                StrokeDownStyle = new SCISolidPenStyle(StrokeDownColor, StrokeThickness),
            };

            var movingAverage50Series = new SCIFastLineRenderableSeries {
                DataSeries = _xyDataSeries, StrokeStyle = new SCISolidPenStyle(0xFFFF6600, 1.0f)
            };

            // Create axis markers annotations to show the last values on real-time chart
            //TODO Position -> Y1Value, color property should be on annotation itself
            _smaAxisMarker = new SCIAxisMarkerAnnotation {
                Position = 0d, YAxisId = yAxis.AxisId
            };
            _smaAxisMarker.Style.BackgroundColor = SmaSeriesColor.ToColor();

            _ohlcAxisMarker = new SCIAxisMarkerAnnotation {
                Position = 0d, YAxisId = yAxis.AxisId
            };
            _ohlcAxisMarker.Style.BackgroundColor = StrokeUpColor.ToColor();

            using (MainSurface.SuspendUpdates())
            {
                MainSurface.XAxes.Add(xAxis);
                MainSurface.YAxes.Add(yAxis);
                MainSurface.RenderableSeries.Add(ohlcSeries);
                MainSurface.RenderableSeries.Add(movingAverage50Series);
                MainSurface.Annotations.Add(_ohlcAxisMarker);
                MainSurface.Annotations.Add(_smaAxisMarker);

                // Populate some pinch and touch interactions. Pinch to zoom, drag to pan and double-tap to zoom extents
                MainSurface.ChartModifiers = new SCIChartModifierCollection
                {
                    new SCIXAxisDragModifier(),
                    new SCIZoomPanModifier {
                        Direction = SCIDirection2D.XDirection
                    },
                    new SCIZoomExtentsModifier(),
                    new SCILegendModifier
                    {
                        Orientation     = SCIOrientation.Horizontal,
                        Position        = SCILegendPosition.Bottom,
                        StyleOfItemCell = new SCILegendCellStyle {
                            SeriesNameFont = UIFont.FromName("Helvetica", 10f)
                        }
                    }
                };
            }
        }