コード例 #1
0
        protected override void InitExample()
        {
            View.FindViewById <Button>(Resource.Id.start).Click += (sender, args) => Start();
            View.FindViewById <Button>(Resource.Id.pause).Click += (sender, args) => Pause();
            View.FindViewById <Button>(Resource.Id.reset).Click += (sender, args) => Reset();

            var xAxis = new NumericAxis(Activity)
            {
                AutoRange = AutoRange.Always
            };
            var yAxis = new NumericAxis(Activity)
            {
                AutoRange = AutoRange.Always
            };

            var rs1 = new FastLineRenderableSeries {
                DataSeries = _mainSeries, StrokeStyle = new SolidPenStyle(0xFF4083B7, 2f.ToDip(Activity))
            };
            var rs2 = new FastLineRenderableSeries {
                DataSeries = _maLowSeries, StrokeStyle = new SolidPenStyle(0xFFFFA500, 2f.ToDip(Activity))
            };
            var rs3 = new FastLineRenderableSeries {
                DataSeries = _maHighSeries, StrokeStyle = new SolidPenStyle(0xFFE13219, 2f.ToDip(Activity))
            };

            _textView = new TextView(Activity);
            _textView.SetPadding(20, 20, 20, 20);
            var annotation = new CustomAnnotation(Activity)
            {
                CoordinateMode = AnnotationCoordinateMode.Relative,
                ZIndex         = -1,
                X1Value        = 0,
                Y1Value        = 0,
            };

            annotation.SetContentView(_textView);

            using (Surface.SuspendUpdates())
            {
                Surface.XAxes.Add(xAxis);
                Surface.YAxes.Add(yAxis);
                Surface.RenderableSeries.Add(rs1);
                Surface.RenderableSeries.Add(rs2);
                Surface.RenderableSeries.Add(rs3);
                Surface.Annotations.Add(annotation);
            }
            Start();
        }
コード例 #2
0
        protected override void InitExample()
        {
            using (Surface.SuspendUpdates())
            {
                Surface.XAxes.Add(new NumericAxis(Activity)
                {
                    VisibleRange = new DoubleRange(0, 10), GrowBy = new DoubleRange(0.1, 0.1), TextFormatting = "0.0#"
                });
                Surface.YAxes.Add(new NumericAxis(Activity)
                {
                    VisibleRange = new DoubleRange(0, 10), GrowBy = new DoubleRange(0.1, 0.1), TextFormatting = "0.0#"
                });

                var customAnnotation1 = new CustomAnnotation(Activity)
                {
                    X1Value = 8d,
                    Y1Value = 5.5,
                };
                customAnnotation1.SetContentId(Resource.Layout.Example_Custom_Annotation_View);

                var customAnnotation2 = new CustomAnnotation(Activity)
                {
                    X1Value = 7.5,
                    Y1Value = 5d,
                };
                customAnnotation2.SetContentView(new CustomView2(Activity));

                Surface.Annotations = new AnnotationCollection()
                {
                    // Watermark
                    new TextAnnotation(Activity)
                    {
                        X1Value               = 0.5,
                        Y1Value               = 0.5,
                        FontStyle             = new FontStyle(Activity, Typeface.DefaultBold, 42, 0x22FFFFFF.ToColor()),
                        Text                  = "Create \nWatermarks",
                        CoordinateMode        = AnnotationCoordinateMode.Relative,
                        HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
                        VerticalAnchorPoint   = VerticalAnchorPoint.Center
                    },

                    // Text annotations
                    new TextAnnotation(Activity)
                    {
                        X1Value   = 0.3,
                        Y1Value   = 9.7,
                        FontStyle = new FontStyle(Activity, 24, Color.White),
                        Text      = "Annotations are Easy!"
                    },
                    new TextAnnotation(Activity)
                    {
                        X1Value   = 1.9,
                        Y1Value   = 9.0,
                        FontStyle = new FontStyle(Activity, 10, Color.White),
                        Text      = "You can create text"
                    },

                    // Text with Anchor Points
                    new TextAnnotation(Activity)
                    {
                        X1Value = 5d,
                        Y1Value = 8d,
                        HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
                        VerticalAnchorPoint   = VerticalAnchorPoint.Bottom,
                        Text = "Anchor Center (X1, Y1)"
                    },
                    new TextAnnotation(Activity)
                    {
                        X1Value = 5d,
                        Y1Value = 8d,
                        HorizontalAnchorPoint = HorizontalAnchorPoint.Right,
                        VerticalAnchorPoint   = VerticalAnchorPoint.Top,
                        Text = "Anchor Right"
                    },
                    new TextAnnotation(Activity)
                    {
                        X1Value = 5d,
                        Y1Value = 8d,
                        HorizontalAnchorPoint = HorizontalAnchorPoint.Left,
                        VerticalAnchorPoint   = VerticalAnchorPoint.Top,
                        Text = "or Anchor Left"
                    },

                    // Line and LineArrow annotation
                    new TextAnnotation(Activity)
                    {
                        X1Value             = 0.3,
                        Y1Value             = 6.1,
                        FontStyle           = new FontStyle(Activity, 12, Color.White),
                        VerticalAnchorPoint = VerticalAnchorPoint.Bottom,
                        Text = "Draw Lines with \nor without arrows"
                    },
                    new LineAnnotation(Activity)
                    {
                        X1Value = 1d,
                        Y1Value = 4d,
                        X2Value = 2d,
                        Y2Value = 6d,
                        Stroke  = new SolidPenStyle(Activity, Color.Argb(0xFF, 0x55, 0x55, 0x55), thickness: 2)
                    },
                    new LineArrowAnnotation(Activity)
                    {
                        X1Value = 1.2,
                        Y1Value = 3.8,
                        X2Value = 2.5,
                        Y2Value = 6d,
                        Stroke  = new SolidPenStyle(Activity, Color.Argb(0xFF, 0x55, 0x55, 0x55), thickness: 2)
                    },

                    // Boxes
                    new TextAnnotation(Activity)
                    {
                        X1Value             = 3.5,
                        Y1Value             = 6.1,
                        Text                = "Draw Boxes",
                        VerticalAnchorPoint = VerticalAnchorPoint.Bottom
                    },
                    new BoxAnnotation(Activity)
                    {
                        X1Value    = 3.5,
                        Y1Value    = 4d,
                        X2Value    = 5d,
                        Y2Value    = 5d,
                        Background = Activity.GetDrawableCompat(Resource.Drawable.example_box_annotation_background_1)
                    },
                    new BoxAnnotation(Activity)
                    {
                        X1Value    = 4d,
                        Y1Value    = 4.5,
                        X2Value    = 5.5,
                        Y2Value    = 5.5,
                        Background = Activity.GetDrawableCompat(Resource.Drawable.example_box_annotation_background_2)
                    },
                    new BoxAnnotation(Activity)
                    {
                        X1Value    = 4.5,
                        Y1Value    = 5d,
                        X2Value    = 6d,
                        Y2Value    = 6d,
                        Background = Activity.GetDrawableCompat(Resource.Drawable.example_box_annotation_background_3)
                    },

                    // Custom Shapes
                    new TextAnnotation(Activity)
                    {
                        X1Value             = 7d,
                        Y1Value             = 6.1,
                        FontStyle           = new FontStyle(Activity, 12, Color.White),
                        VerticalAnchorPoint = VerticalAnchorPoint.Bottom,
                        Text = "Or Custom Shapes"
                    },
                    customAnnotation1,
                    customAnnotation2,

                    // Horizontal Lines
                    new HorizontalLineAnnotation(Activity)
                    {
                        X1Value           = 5d,
                        Y1Value           = 3.2,
                        HorizontalGravity = GravityFlags.Right,
                        Stroke            = new SolidPenStyle(Activity, Color.Orange, thickness: 2),

                        AnnotationLabels = new AnnotationLabelCollection
                        {
                            new AnnotationLabel(Activity)
                            {
                                LabelPlacement = LabelPlacement.TopLeft,
                                Text           = "Right Aligned, with text on left"
                            }
                        }
                    },
                    new HorizontalLineAnnotation(Activity)
                    {
                        X1Value = 7d,
                        Y1Value = 2.8,
                        Stroke  = new SolidPenStyle(Activity, Color.Orange, thickness: 2),

                        AnnotationLabels = new AnnotationLabelCollection
                        {
                            new AnnotationLabel(Activity)
                            {
                                LabelPlacement = LabelPlacement.Axis
                            }
                        }
                    },

                    // Vertical Lines
                    new VerticalLineAnnotation(Activity)
                    {
                        X1Value         = 9d,
                        Y1Value         = 4d,
                        VerticalGravity = GravityFlags.Bottom,
                        Stroke          = new SolidPenStyle(Activity, Color.Brown, thickness: 2),

                        AnnotationLabels = new AnnotationLabelCollection
                        {
                            new AnnotationLabel(Activity)
                        }
                    },
                    new VerticalLineAnnotation(Activity)
                    {
                        X1Value = 9.5d,
                        Y1Value = 3d,
                        Stroke  = new SolidPenStyle(Activity, Color.Brown, thickness: 2),

                        AnnotationLabels = new AnnotationLabelCollection
                        {
                            new AnnotationLabel(Activity),
                            new AnnotationLabel(Activity)
                            {
                                LabelPlacement = LabelPlacement.TopRight,
                                Text           = "Bottom-aligned",
                                RotationAngle  = 90
                            }
                        }
                    }
                };

                Surface.ChartModifiers = new ChartModifierCollection
                {
                    new ZoomPanModifier(),
                    new PinchZoomModifier(),
                    new ZoomExtentsModifier(),
                };
            }
        }