private void CreateOverviewChart(out BoxAnnotation leftAreaAnnotation, out BoxAnnotation rightAreaAnnotation)
        {
            // Create an XAxis and YAxis for our chart
            var xAxis1 = new CategoryDateAxis(Activity)
            {
                AutoRange = AutoRange.Always
            };
            var yAxis1 = new NumericAxis(Activity)
            {
                GrowBy = new DoubleRange(0.1, 0.1), AutoRange = AutoRange.Always
            };

            // Create the mountain chart for the overview , using the same price data but zoomed out
            var mountainSeries = new FastMountainRenderableSeries {
                DataSeries = _ohlcDataSeries
            };

            // Create some annotations to visualize the selected area on the main price chart
            leftAreaAnnotation = new BoxAnnotation(Activity)
            {
                CoordinateMode = AnnotationCoordinateMode.RelativeY,
                Y1Value        = 0,
                Y2Value        = 1,
                Background     = Activity.GetDrawableCompat(Resource.Drawable.example_gray_box_annotation_background)
            };

            rightAreaAnnotation = new BoxAnnotation(Activity)
            {
                CoordinateMode = AnnotationCoordinateMode.RelativeY,
                Y1Value        = 0,
                Y2Value        = 1,
                Background     = Activity.GetDrawableCompat(Resource.Drawable.example_gray_box_annotation_background)
            };

            // 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);
            }
        }
Ejemplo n.º 2
0
    private static BoxAnnotation createAnnotation(string annotationText_, double valueX_, double valueY_,bool isLastOfSeries, Color color_)
    {
      var box = new BoxAnnotation();
      box.Text = annotationText_;
      box.Location.Type = Infragistics.UltraChart.Shared.Styles.LocationType.DataValues;
      box.Location.ValueX = valueX_;
      box.Location.ValueY = valueY_;
      box.TextStyle.FontColor = color_;
      box.TextStyle.FontSizeBestFit = true;
      box.Border.Thickness = 0;
      box.TextStyle.Font = new Font("Arial", 5F); 

      if (annotationText_.Length > 2)
      {
        box.TextStyle.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
      }
      if (isLastOfSeries)
          box.TextStyle.Font = new Font("Arial", 14F); 
      
      return box;
    }
Ejemplo n.º 3
0
    private BoxAnnotation createAnnotation(string annotationText_, double valueX_, double valueY_, Color color_)
    {
      var box = new BoxAnnotation
      {
        Location =
        {
          Type = Infragistics.UltraChart.Shared.Styles.LocationType.DataValues,
          ValueX = valueX_,
          ValueY = valueY_
        },
        Text=annotationText_,
      };
      box.TextStyle.FontColor = color_;
      box.Border.Thickness = 0;

      if (annotationText_.Length > 1)
      {
        box.TextStyle.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
      }
      return box;
    }
        protected override void InitExample()
        {
            var xAxis = new NumericAxis(Activity)
            {
                VisibleRange = new DoubleRange(150d, 165d)
            };
            var yAxis = new NumericAxis(Activity)
            {
                LabelProvider = new ThousandsLabelProvider(),
                GrowBy        = new DoubleRange(0, 0.1),
                AutoRange     = AutoRange.Always
            };

            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, double>()
            {
                SeriesName = "Column Series"
            };
            var scatterDataSeries = new XyDataSeries <double, double>()
            {
                SeriesName = "Scatter Series"
            };
            var candlestickDataSeries = new OhlcDataSeries <double, double>()
            {
                SeriesName = "Candlestick Series"
            };
            var ohlcDataSeries = new OhlcDataSeries <double, double>()
            {
                SeriesName = "OHLC Series"
            };

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

            mountainDataSeries.Append(xValues, priceBars.LowData.Select(x => x - 2000d));
            lineDataSeries.Append(xValues, priceBars.CloseData.Select(x => x + 1000d));
            ohlcDataSeries.Append(xValues, priceBars.OpenData, priceBars.HighData, priceBars.LowData, priceBars.CloseData);
            candlestickDataSeries.Append(xValues, priceBars.OpenData.Select(x => x - 1000d), priceBars.HighData.Select(x => x - 1000d), priceBars.LowData.Select(x => x - 1000d), priceBars.CloseData.Select(x => x - 1000d));
            columnDataSeries.Append(xValues, priceBars.CloseData.Select(x => x - 3000d));
            scatterDataSeries.Append(xValues, priceBars.OpenData.Select(x => x - 2500d));

            var annotation = new BoxAnnotation(Activity)
            {
                X1Value        = 152d,
                Y1Value        = 0d,
                X2Value        = 158d,
                Y2Value        = 1d,
                Background     = Activity.GetDrawableCompat(Resource.Drawable.example_box_annotation_background_1),
                IsEditable     = true,
                CoordinateMode = AnnotationCoordinateMode.RelativeY
            };

            annotation.SetOnAnnotationDragListener(new AnnotationDragListener());

            var mountainSeries = new FastMountainRenderableSeries
            {
                DataSeries      = mountainDataSeries,
                AreaStyle       = new SolidBrushStyle(0x9787CEEB),
                StrokeStyle     = new SolidPenStyle(Color.Magenta),
                PaletteProvider = new XyCustomPaletteProvider(Color.Red, annotation)
            };

            var lineSeries = new FastLineRenderableSeries
            {
                DataSeries  = lineDataSeries,
                StrokeStyle = new SolidPenStyle(Color.Blue),
                PointMarker = new EllipsePointMarker()
                {
                    FillStyle   = new SolidBrushStyle(Color.Red),
                    StrokeStyle = new SolidPenStyle(Color.Orange, 2f.ToDip(Activity)),
                    Width       = (int)10f.ToDip(Activity),
                    Height      = (int)10f.ToDip(Activity)
                },
                PaletteProvider = new XyCustomPaletteProvider(Color.Red, annotation)
            };

            var ohlcSeries = new FastOhlcRenderableSeries()
            {
                DataSeries      = ohlcDataSeries,
                PaletteProvider = new OhlcCustomPaletteProvider(Color.CornflowerBlue, annotation)
            };

            var candlestickSeries = new FastCandlestickRenderableSeries
            {
                DataSeries      = candlestickDataSeries,
                PaletteProvider = new OhlcCustomPaletteProvider(Color.Green, annotation)
            };

            var columnSeries = new FastColumnRenderableSeries
            {
                DataSeries      = columnDataSeries,
                StrokeStyle     = new SolidPenStyle(Color.Blue),
                FillBrushStyle  = new SolidBrushStyle(Color.Blue),
                ZeroLineY       = 6000,
                DataPointWidth  = 0.8,
                PaletteProvider = new XyCustomPaletteProvider(Color.Purple, annotation)
            };

            var scatterSeries = new XyScatterRenderableSeries()
            {
                DataSeries  = scatterDataSeries,
                PointMarker = new SquarePointMarker()
                {
                    FillStyle   = new SolidBrushStyle(Color.Red),
                    StrokeStyle = new SolidPenStyle(Color.Orange, 2f.ToDip(Activity)),
                    Width       = (int)7f.ToDip(Activity),
                    Height      = (int)7f.ToDip(Activity)
                },
                PaletteProvider = new XyCustomPaletteProvider(Color.LimeGreen, annotation)
            };


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

                Surface.RenderableSeries.Add(mountainSeries);
                Surface.RenderableSeries.Add(lineSeries);
                Surface.RenderableSeries.Add(ohlcSeries);
                Surface.RenderableSeries.Add(candlestickSeries);
                Surface.RenderableSeries.Add(columnSeries);
                Surface.RenderableSeries.Add(scatterSeries);

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

                Surface.Annotations.Add(annotation);
            }
        }
 public OhlcCustomPaletteProvider(Color color, BoxAnnotation annotation)
 {
     _color      = color.ToArgb();
     _annotation = annotation;
 }