protected override void InitExample() { var data = DataManager.Instance.GetPriceDataIndu(); var dataSeries = new OhlcDataSeries <DateTime, double>(); dataSeries.Append(data.TimeData, data.OpenData, data.HighData, data.LowData, data.CloseData); var xAxis = new CategoryDateAxis(Activity); var yAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0, 0.1) }; var rs = new FastCandlestickRenderableSeries { DataSeries = dataSeries, StrokeUpStyle = new PenStyle.Builder(Activity).WithColor(Color.Green).Build(), StrokeDownStyle = new PenStyle.Builder(Activity).WithColor(Color.Red).Build(), FillUpBrushStyle = new SolidBrushStyle(Color.Green), FillDownBrushStyle = new SolidBrushStyle(Color.Red) }; Surface.XAxes.Add(xAxis); Surface.YAxes.Add(yAxis); Surface.RenderableSeries.Add(rs); Surface.ChartModifiers = new ChartModifierCollection() { new ZoomPanModifier(), new PinchZoomModifier(), new ZoomExtentsModifier(), }; }
public static void SetChartViewModelPriceData(IList <Candle> candles, ChartViewModel cvm) { var priceDataSeries = new OhlcDataSeries <DateTime, double>(); var xvalues = new List <DateTime>(); var openValues = new List <double>(); var highValues = new List <double>(); var lowValues = new List <double>(); var closeValues = new List <double>(); var atr = new AverageTrueRange(); for (var i = 0; i < candles.Count; i++) { var time = new DateTime(candles[i].CloseTimeTicks, DateTimeKind.Utc).ToLocalTime(); xvalues.Add(time); openValues.Add((double)candles[i].OpenBid); highValues.Add((double)candles[i].HighBid); lowValues.Add((double)candles[i].LowBid); closeValues.Add((double)candles[i].CloseBid); } priceDataSeries.Append(xvalues, openValues, highValues, lowValues, closeValues); priceDataSeries.SeriesName = "Price"; var pricePaneVm = cvm.ChartPaneViewModels.Count > 0 ? cvm.ChartPaneViewModels[0] : null; var atrPaneVm = cvm.ChartPaneViewModels.Count > 1 ? cvm.ChartPaneViewModels[1] : null; if (pricePaneVm == null) { pricePaneVm = new ChartPaneViewModel(cvm, cvm.ViewportManager) { IsFirstChartPane = true, IsLastChartPane = false }; var series = new FastCandlestickRenderableSeries { AntiAliasing = false }; series.SetValue(FilteringLegendModifier.IncludeSeriesProperty, false); series.SeriesColor = Colors.DarkBlue; pricePaneVm.ChartSeriesViewModels.Add(new ChartSeriesViewModel(priceDataSeries, series)); cvm.ChartPaneViewModels.Add(pricePaneVm); } else { pricePaneVm.ChartSeriesViewModels.Clear(); var renderableSeries = new FastCandlestickRenderableSeries { AntiAliasing = false }; renderableSeries.SetValue(FilteringLegendModifier.IncludeSeriesProperty, false); pricePaneVm.ChartSeriesViewModels.Add(new ChartSeriesViewModel(priceDataSeries, renderableSeries)); } }
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 CategoryDateAxis(Activity) { VisibleRange = new DoubleRange(size - 30, size), GrowBy = new DoubleRange(0, 0.1) }; var yAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0, 0.1), AutoRange = AutoRange.Always }; var rSeries = new FastCandlestickRenderableSeries { DataSeries = dataSeries, StrokeUpStyle = new SolidPenStyle(0xFF00AA00, 1.ToDip(Activity)), StrokeDownStyle = new SolidPenStyle(0xFFFF0000, 1.ToDip(Activity)), FillUpBrushStyle = new SolidBrushStyle(0x8800AA00), FillDownBrushStyle = new SolidBrushStyle(0x88FF0000) }; using (Surface.SuspendUpdates()) { Surface.XAxes.Add(xAxis); Surface.YAxes.Add(yAxis); Surface.RenderableSeries.Add(rSeries); Surface.ChartModifiers = new ChartModifierCollection { new ZoomPanModifier(), new PinchZoomModifier(), new ZoomExtentsModifier(), }; new WaveAnimatorBuilder(rSeries) { Interpolator = new DecelerateInterpolator(), Duration = 3000, StartDelay = 350 }.Start(); } }
private void SetupRenderableSeries() { 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 mountainSeries = new FastMountainRenderableSeries { DataSeries = mountainDataSeries, YAxisId = "PrimaryAxisId" }; var lineSeries = new FastLineRenderableSeries { DataSeries = lineDataSeries, YAxisId = "PrimaryAxisId" }; var columnSeries = new FastColumnRenderableSeries { DataSeries = columnDataSeries, YAxisId = "SecondaryAxisId" }; var candlestickSeries = new FastCandlestickRenderableSeries { DataSeries = candlestickDataSeries, YAxisId = "PrimaryAxisId" }; var legendModifier = new LegendModifier(Activity); legendModifier.SetShowCheckboxes(false); using (Surface.SuspendUpdates()) { Surface.RenderableSeries.Add(mountainSeries); Surface.RenderableSeries.Add(lineSeries); Surface.RenderableSeries.Add(columnSeries); Surface.RenderableSeries.Add(candlestickSeries); Surface.ChartModifiers = new ChartModifierCollection { legendModifier, new CursorModifier(), new PinchZoomModifier(), new ZoomExtentsModifier(), }; new ScaleAnimatorBuilder(mountainSeries, 10500d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); new ScaleAnimatorBuilder(candlestickSeries, 11700d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); new ScaleAnimatorBuilder(lineSeries, 12250d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); new ScaleAnimatorBuilder(columnSeries, 10500d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); } }
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); } }
protected override void InitExample() { InitializeUIHandlers(); var xAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0.1, 0.1), VisibleRange = new DoubleRange(150, 180) }; var yRightAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0.1, 0.1), AxisAlignment = AxisAlignment.Right, AutoRange = AutoRange.Always, AxisId = "PrimaryAxisId", DrawMajorTicks = false, DrawMinorTicks = false, LabelProvider = new ThousandsLabelProvider(), }; var yLeftAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0, 3d), AxisAlignment = AxisAlignment.Left, AutoRange = AutoRange.Always, AxisId = "SecondaryAxisId", 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 FastMountainRenderableSeries { DataSeries = mountainDataSeries, YAxisId = "PrimaryAxisId" }; var lineRenderableSeries = new FastLineRenderableSeries { DataSeries = lineDataSeries, YAxisId = "PrimaryAxisId" }; var columnRenderableSeries = new FastColumnRenderableSeries { DataSeries = columnDataSeries, YAxisId = "SecondaryAxisId" }; var candlestickRenderableSeries = new FastCandlestickRenderableSeries { DataSeries = candlestickDataSeries, YAxisId = "PrimaryAxisId" }; var legendModifier = new LegendModifier(Activity); legendModifier.SetShowCheckboxes(false); 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 ChartModifierCollection { legendModifier, new CursorModifier(), new ZoomExtentsModifier(), }; } }
protected override void InitExample() { // Apply a theme to the chart // The custom theme is named SciChart_BerryBlue and is included as a number of resource files in the application resources // The xml resources contain all the keys for theme colors and brushes and styles to apply to the chart Surface.Theme = Resource.Style.SciChart_BerryBlue; // The rest of this example is setting up the chart with some axis, and data var xAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0.1, 0.1), VisibleRange = new DoubleRange(150, 180) }; var yRightAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0.1, 0.1), AxisAlignment = AxisAlignment.Right, AutoRange = AutoRange.Always, AxisId = "PrimaryAxisId", DrawMajorTicks = false, DrawMinorTicks = false, LabelProvider = new ThousandsLabelProvider(), }; var yLeftAxis = new NumericAxis(Activity) { GrowBy = new DoubleRange(0, 3d), AxisAlignment = AxisAlignment.Left, AutoRange = AutoRange.Always, AxisId = "SecondaryAxisId", 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 mountainSeries = new FastMountainRenderableSeries { DataSeries = mountainDataSeries, YAxisId = "PrimaryAxisId" }; var lineSeries = new FastLineRenderableSeries { DataSeries = lineDataSeries, YAxisId = "PrimaryAxisId" }; var columnSeries = new FastColumnRenderableSeries { DataSeries = columnDataSeries, YAxisId = "SecondaryAxisId" }; var candlestickSeries = new FastCandlestickRenderableSeries { DataSeries = candlestickDataSeries, YAxisId = "PrimaryAxisId" }; var legendModifier = new LegendModifier(Activity); legendModifier.SetShowCheckboxes(false); using (Surface.SuspendUpdates()) { Surface.XAxes.Add(xAxis); Surface.YAxes.Add(yRightAxis); Surface.YAxes.Add(yLeftAxis); Surface.RenderableSeries.Add(mountainSeries); Surface.RenderableSeries.Add(lineSeries); Surface.RenderableSeries.Add(columnSeries); Surface.RenderableSeries.Add(candlestickSeries); Surface.ChartModifiers = new ChartModifierCollection { legendModifier, new CursorModifier(), new ZoomExtentsModifier(), }; new ScaleAnimatorBuilder(mountainSeries, 10500d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); new ScaleAnimatorBuilder(candlestickSeries, 11700d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); new ScaleAnimatorBuilder(lineSeries, 12250d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); new ScaleAnimatorBuilder(columnSeries, 10500d) { Interpolator = new OvershootInterpolator(), Duration = 1000, StartDelay = 600 }.Start(); } }