public static Point AnnoPointToCoords(C1FlexChart flexChart, IAnnotationBase annotation, Point point) { Point pt = new Point(); switch (annotation.Attachment) { case AnnotationAttachment.Absolute: pt = point; break; case AnnotationAttachment.Relative: pt = new Point { X = (float)flexChart.PlotRect.Width * point.X, Y = (float)flexChart.PlotRect.Height * point.Y, }; break; case AnnotationAttachment.DataCoordinate: pt = new Point { X = (float)flexChart.AxisX.Convert(point.X), Y = (float)flexChart.AxisY.Convert(point.Y), }; break; } return(pt); }
internal static Rect GetRect(C1FlexChart flexChart, IAnnotationBase anno) { var annotaion = anno as AnnotationBase; Point point = new Point(); _Size size; Size sz; if (annotaion is Line) { return(GetRect(flexChart, annotaion as Line)); } else if (annotaion is Polygon) { return(GetRect(flexChart, annotaion as Polygon)); } else { size = anno.GetSize(); sz = new Size((float)size.Width, (float)size.Height); if (annotaion is Text) { TextBlock txtBlock = new TextBlock(); txtBlock.FontStyle = (((Text)annotaion).Style.FontStyle); txtBlock.Text = ((Text)annotaion).Content; txtBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); sz = txtBlock.DesiredSize; } Point loc = AnnoPointToCoords(flexChart, annotaion, annotaion.Location); point.X = (float)(loc.X - size.Width / 2); point.Y = (float)(loc.Y - size.Height / 2); } return(new Rect(point.X, point.Y, sz.Width, sz.Height)); }
public static Point CoordsToAnnoPoint(C1FlexChart flexChart, IAnnotationBase annotation, Point point) { Point pt = new Point(); switch (annotation.Attachment) { case AnnotationAttachment.Absolute: pt = point; break; case AnnotationAttachment.Relative: pt = new Point { X = point.X / (float)flexChart.PlotRect.Width, Y = point.Y / (float)flexChart.PlotRect.Height }; break; case AnnotationAttachment.DataCoordinate: double x = point.X; double y = point.Y; var xValue = (float)flexChart.AxisX.ConvertBack(x); var yValue = (float)flexChart.AxisY.ConvertBack(y); pt = new Point(xValue, yValue); break; } return(pt); }
private static Rect GetRect(C1FlexChart flexChart, Line line) { var start = AnnoPointToCoords(flexChart, line, line.Start); var end = AnnoPointToCoords(flexChart, line, line.End); var x = Math.Min(start.X, end.X); var y = Math.Min(start.Y, end.Y); var width = Math.Abs(start.X - end.X); var height = Math.Abs(start.Y - end.Y); Size contentSize = new Size(); if (!string.IsNullOrEmpty(line.Content)) { TextBlock txtBlock = new TextBlock(); txtBlock.FontStyle = line.Style.FontStyle; txtBlock.Text = line.Content; txtBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); contentSize = txtBlock.DesiredSize; } if (height == 0) //Horizontal line { height = (float)line.Style.StrokeThickness + contentSize.Height; y = y - height; } else if (width == 0) //Vertical line { width = (float)line.Style.StrokeThickness + contentSize.Height; } return(new Rect(x, y, width, height)); }
//Binding view mode property setting panel public static void BindingSettingsParams(C1FlexChart chart, object source, Type srcType, string srckey, IEnumerable <Data.PropertyParam> properties, Action propertyChangedCallback = null) { IEnumerable <Data.SettingParam> settings; if (ViewModel.ViewModel.Instance.Settings.TryGetValue(srckey, out settings)) { foreach (var param in properties) { var setting = (from p in settings where (param.Group == null) ? p.Key == param.Key : (p.Key == param.Key && p.Group == param.Group) select p).FirstOrDefault(); if (setting != null) { Queue <string> keys = new Queue <string>(param.Key.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)); KeyValuePair <System.Reflection.PropertyInfo, object> propertyInfo = GetPropertyInfo(source, srcType, keys); SetPropertyValue(setting, param, propertyInfo); setting.PropertyChanged += (o, e) => { SetPropertyValue(setting, param, propertyInfo); if (propertyChangedCallback != null) { propertyChangedCallback(); } chart.Invalidate(); }; } } } }
public EditableAnnotationLayer(C1FlexChart chart) { AllowMove = true; _flexChart = chart; Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; _flexChart.DoubleTapped += _flexChart_DoubleTapped; _flexChart.RightTapped += _flexChart_RighTapped; _flexChart.PointerPressed += _flexChart_PointerPressed; _flexChart.PointerReleased += _flexChart_PointerReleased; _flexChart.PointerMoved += _flexChart_PointerMoved; _flexChart.Rendered += OnChartRendered; Annotations.CollectionChanged += OnCollectionChanged; _rectCache = new List <AnnotationEx>(); _originalStyle = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) }; SelectionStyle = new ChartStyle() { Fill = new SolidColorBrush(Colors.White), Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 1, StrokeDashArray = new DoubleCollection() { 1, 2 } }; TextAnnoStyle = new ChartStyle() { FontSize = 12, Stroke = new SolidColorBrush(Colors.Black) }; Attachment = AnnotationAttachment.Absolute; //Popup to show Annotation editor EditorPopup = new Popup(); EditorPopup.IsLightDismissEnabled = true; FlexChart.KeyDown += (s1, e1) => { if (e1.Key == Windows.System.VirtualKey.Escape) { HideContentEditor(); } }; EditorPopup.Closed += (s1, e1) => { _flexChart.Invalidate(); }; }
public void Execute(object parameter) { C1FlexChart chart = _viewModel.MainChart; var code = parameter.ToString().Split(new char[] { ' ' }).FirstOrDefault(); if (chart == null || string.IsNullOrEmpty(code)) { return; } if (code.ToUpper() == _viewModel.MainSymbol.ToUpper()) { return; } _viewModel.AddCommandParamter = string.Empty; var theSymbol = from p in _viewModel.SymbolCollection where p.Code.ToUpper() == code.ToUpper() select p; if (theSymbol != null && theSymbol.Any()) { return; } CreateSysmbol(code, async(s) => { s.PropertyChanged += (o, e) => { if (e.PropertyName == "Visibility") { _viewModel.UpdateYRange(); } }; await chart.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { theSymbol = from p in _viewModel.SymbolCollection where p.Code.ToUpper() == s.Code.ToUpper() select p; if (theSymbol != null && theSymbol.Any()) { return; } _viewModel.Binding = "percentage"; InitSymbol(s, _viewModel.Binding); _viewModel.SymbolCollection.Add(s); chart.Series.Add(s.Series); chart.Series.Add(s.MovingAverage); s.Series.Dispose(); s.MovingAverage.Dispose(); if (_viewModel.SymbolCollection.Count > 4) { var symbol = _viewModel.SymbolCollection.FirstOrDefault(); _viewModel.SymbolCollection.Remove(symbol); } }); }); }
public ATRSeries(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); Axis axisY = new Axis(); axisY.TitleStyle = new ChartStyle(); axisY.TitleStyle.FontWeight = FontWeights.Bold; axisY.Position = C1.Chart.Position.Right; axisY.PlotAreaName = plotAreaName; axisY.Title = "ATR"; axisY.Labels = false; axisY.MajorTickMarks = axisY.MinorTickMarks = C1.Chart.TickMark.None; ATR series = new ATR(); series.ChartType = C1.Chart.Finance.FinancialChartType.Line; series.Style = new ChartStyle(); series.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); series.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); series.Style.StrokeThickness = 1; series.BindingX = "Date"; series.Binding = "High,Low,Close"; series.AxisY = axisY; Chart.Series.Add(series); Utilities.Helper.BindingSettingsParams(chart, series, typeof(ATR), "Average True Range (ATR)", new Data.PropertyParam[] { new Data.PropertyParam("Period", typeof(int)), new Data.PropertyParam("Style.Stroke", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); //binding series color to axis title. Binding binding = new Binding(); binding.Path = new Windows.UI.Xaml.PropertyPath("Stroke"); binding.Source = series.Style; BindingOperations.SetBinding(axisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series }; }
public EditableAnnotationLayer(C1FlexChart chart) { AllowMove = true; _flexChart = chart; _flexChart.PreviewMouseDown += OnPreviewMouseDown; _flexChart.MouseDown += OnMouseDown; _flexChart.PreviewMouseLeftButtonUp += _flexChart_PreviewMouseLeftButtonUp; _flexChart.MouseUp += OnMouseUp; _flexChart.MouseMove += OnMouseMove; _flexChart.MouseDoubleClick += OnMouseDoubleClick; _flexChart.Rendered += OnChartRendered; Annotations.CollectionChanged += OnCollectionChanged; _rectCache = new List <AnnotationEx>(); _originalStyle = new ChartStyle { Fill = Brushes.Red }; SelectionStyle = new ChartStyle { Fill = Brushes.White, Stroke = Brushes.Red, StrokeThickness = 1, StrokeDashArray = new DoubleCollection() { 1, 2 } }; Attachment = AnnotationAttachment.Absolute; //Popup to show Annotation editor EditorPopup = new Popup(); EditorPopup.AllowsTransparency = true; EditorPopup.Placement = PlacementMode.AbsolutePoint; EditorPopup.PlacementTarget = FlexChart; FlexChart.KeyDown += (s1, e1) => { if (e1.Key == Key.Escape) { HideContentEditor(); } }; EditorPopup.Closed += (s1, e1) => { _flexChart.Invalidate(); }; }
private static Rect GetRect(C1FlexChart flexChart, Polygon polygon) { Point point = new Point(); Size sz; var convertedPoints = polygon.Points.Select(x => AnnoPointToCoords(flexChart, polygon, x)); var arrayX = convertedPoints.Select(x => x.X).ToArray(); var arrayY = convertedPoints.Select(y => y.Y).ToArray(); point.X = arrayX.Min(); point.Y = arrayY.Min(); sz = new Size(arrayX.Max() - arrayX.Min(), arrayY.Max() - arrayY.Min()); return(new Rect(point.X, point.Y, sz.Width, sz.Height)); }
public WatermarkAdorner(UIElement adornedElement) : base(adornedElement) { chart = adornedElement as C1FlexChart; var resource = Application.GetResourceStream(new Uri("/" + new AssemblyName(Assembly.GetExecutingAssembly().FullName).Name + ";component/Resources/Img_WaterMark_C1Logo.png", UriKind.Relative)); var stream = resource.Stream; if (stream != null) { bmp = new BitmapImage(); bmp.BeginInit(); bmp.StreamSource = stream; bmp.EndInit(); } }
public AnnotationEx(C1FlexChart chart, AnnotationBase anno, Rect rect) { flexChart = chart; annotation = anno; BoundingRectangle = rect; }
public MassIndex(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "MI"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; series = new MassIndexSeries(); series.ChartType = C1.Chart.ChartType.Line; series.Style = new ChartStyle(); series.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); series.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); series.Style.StrokeThickness = 1; //dip.BindingX = "Date"; //dip.Binding = "High,Low,Close"; series.AxisY = AxisY; Chart.Series.Add(series); seriesThreshold = new IndicatorSeries.ThresholdSeries(); seriesThreshold.ChartType = C1.Chart.Finance.FinancialChartType.Line; seriesThreshold.Style = new ChartStyle(); seriesThreshold.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockGreen); seriesThreshold.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); seriesThreshold.Style.StrokeThickness = 1; seriesThreshold.AxisY = AxisY; Chart.Series.Add(seriesThreshold); Utilities.Helper.BindingSettingsParams(chart, series, typeof(MassIndexSeries), "Mass Index", new Data.PropertyParam[] { new Data.PropertyParam("Period", typeof(int)), new Data.PropertyParam("Style.Stroke", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, seriesThreshold, typeof(IndicatorSeries.ThresholdSeries), "Mass Index", new Data.PropertyParam[] { new Data.PropertyParam("Threshold", typeof(Object.Threshold)), }, () => { this.OnSettingParamsChanged(); } ); seriesThreshold.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; //binding series color to axis title. Binding binding = new Binding(); binding.Path = new Windows.UI.Xaml.PropertyPath("Stroke"); binding.Source = series.Style; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Object.Quote quote = ViewModel.ViewModel.Instance.CurrectQuote; if (quote != null) { MassIndexCalculator.Instance.Source = quote.Data; } series.Calculator = MassIndexCalculator.Instance; MassIndexCalculator.Instance.Period = series.Period; ViewModel.ViewModel.Instance.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrectQuote") { quote = ViewModel.ViewModel.Instance.CurrectQuote; MassIndexCalculator.Instance.Source = quote.Data; } }; Chart.EndUpdate(); this.Series = new Series[] { series, seriesThreshold }; }
public StochasticSeries(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "Stoc"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; series = new Stochastic(); series.DLineStyle = new ChartStyle(); series.DLineStyle.StrokeThickness = 1; series.KLineStyle = new ChartStyle(); series.KLineStyle.StrokeThickness = 1; series.ChartType = C1.Chart.Finance.FinancialChartType.Line; series.Style = new C1.WPF.Chart.ChartStyle(); series.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); series.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); series.Style.StrokeThickness = 1; series.BindingX = "Date"; series.Binding = "High,Low,Close"; series.AxisY = AxisY; Chart.Series.Add(series); ThresholdSeries overBought = new ThresholdSeries(); overBought.ChartType = C1.Chart.Finance.FinancialChartType.Line; overBought.Style = new C1.WPF.Chart.ChartStyle(); overBought.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockGreen); overBought.Style.StrokeThickness = 1; overBought.AxisY = AxisY; Chart.Series.Add(overBought); ThresholdSeries overSold = new ThresholdSeries(); overSold.ChartType = C1.Chart.Finance.FinancialChartType.Line; overSold.Style = new C1.WPF.Chart.ChartStyle(); overSold.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockRed); overSold.Style.StrokeThickness = 1; overSold.AxisY = AxisY; Chart.Series.Add(overSold); Utilities.Helper.BindingSettingsParams(chart, this, typeof(StochasticSeries), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("StochasticType", typeof(StochasticPresetType)), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, series, typeof(Stochastic), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("KPeriod", typeof(int)), new Data.PropertyParam("DPeriod", typeof(int)), new Data.PropertyParam("SmoothingPeriod", typeof(int)), new Data.PropertyParam("DLineStyle.Stroke", typeof(Brush)), new Data.PropertyParam("KLineStyle.Stroke", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overBought, typeof(ThresholdSeries), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverBought"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overSold, typeof(ThresholdSeries), "Stochastic", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverSold"), }, () => { this.OnSettingParamsChanged(); } ); overBought.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; overSold.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; //binding series color to axis title. Binding binding = new Binding("Stroke"); binding.Source = series.Style; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series, overBought, overSold }; }
public MacdSeries(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "MACD"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; Macd series = new Macd(); series.MacdLineStyle = new ChartStyle(); series.MacdLineStyle.StrokeThickness = 1; series.SignalLineStyle = new ChartStyle(); series.SignalLineStyle.StrokeThickness = 1; series.ChartType = C1.Chart.Finance.FinancialChartType.Line; series.Style = new C1.WPF.Chart.ChartStyle(); series.Style.StrokeThickness = 1; series.BindingX = "Date"; series.Binding = "High,Low,Close"; series.AxisY = AxisY; Chart.Series.Add(series); MacdHistogram histogram = new MacdHistogram(); histogram.Style = new C1.WPF.Chart.ChartStyle(); histogram.Style.StrokeThickness = 1; histogram.BindingX = "Date"; histogram.Binding = "High,Low,Close"; double[] values = null; ViewModel.ViewModel.Instance.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrectQuote") { values = histogram.GetValues(0); // this is the value; } }; histogram.SymbolRendering += (sender, ev) => { if (values == null) { values = histogram.GetValues(0); // this is the volume value; } if (values != null) { if (values[ev.Index] > 0) { if (IncreasingBar is SolidColorBrush) { Color c = (IncreasingBar as SolidColorBrush).Color; Color cf = Color.FromArgb(128, c.R, c.G, c.B); ev.Engine.SetStroke(c.ToArgb()); ev.Engine.SetFill(cf.ToArgb()); } } else { if (DecreasingBar is SolidColorBrush) { Color c = (DecreasingBar as SolidColorBrush).Color; Color cf = Color.FromArgb(128, c.R, c.G, c.B); ev.Engine.SetStroke(c.ToArgb()); ev.Engine.SetFill(cf.ToArgb()); } } } }; histogram.AxisY = AxisY; Chart.Series.Add(histogram); Utilities.Helper.BindingSettingsParams(chart, series, typeof(Macd), "MACD", new Data.PropertyParam[] { new Data.PropertyParam("FastPeriod", typeof(int)), new Data.PropertyParam("SlowPeriod", typeof(int)), new Data.PropertyParam("SmoothingPeriod", typeof(int)), new Data.PropertyParam("MacdLineStyle.Stroke", typeof(Brush), "Series"), new Data.PropertyParam("SignalLineStyle.Stroke", typeof(Brush), "Series"), }, () => { this.OnSettingParamsChanged(); } ); //Utilities.Helper.BindingSettingsParams(chart, histogram, typeof(MacdHistogram), "MACD", // new Data.PropertyParam[] // { // new Data.PropertyParam("Style.Stroke", typeof(Brush), "Histogram"), // new Data.PropertyParam("Style.Fill", typeof(Brush), "Histogram"), // }, // () => // { // this.OnSettingParamsChanged(); // } //); Utilities.Helper.BindingSettingsParams(chart, this, typeof(MacdSeries), "MACD", new Data.PropertyParam[] { new Data.PropertyParam("IncreasingBar", typeof(Brush)), new Data.PropertyParam("DecreasingBar", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); //binding series color to axis title. Binding binding = new Binding("Stroke"); binding.Source = series.MacdLineStyle; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series, histogram }; }
public PivotPoint(C1FlexChart chart, string plotAreaName = null) : base() { Chart = chart; Chart.BeginUpdate(); if (!string.IsNullOrEmpty(plotAreaName)) { this.AxisY = new Axis(); this.AxisY.TitleStyle = new ChartStyle(); this.AxisY.TitleStyle.FontWeight = FontWeights.Bold; this.AxisY.Position = C1.Chart.Position.Right; this.AxisY.PlotAreaName = plotAreaName; this.AxisY.Title = "P&P"; this.AxisY.Labels = false; this.AxisY.MajorTickMarks = this.AxisY.MinorTickMarks = C1.Chart.TickMark.None; } series = new PivotPointSeries(); series.SeriesName = "Pivot"; series.ChartType = C1.Chart.ChartType.Step; series.Style = new C1.WPF.Chart.ChartStyle(); series.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); series.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); series.Style.StrokeThickness = 1; series.AxisY = AxisY; Chart.Series.Add(series); r1 = new R1Series(); r1.SeriesName = "R1"; r1.ChartType = C1.Chart.ChartType.Step; r1.Style = new C1.WPF.Chart.ChartStyle(); r1.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); r1.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); r1.Style.StrokeThickness = 1; r1.AxisY = AxisY; Chart.Series.Add(r1); r2 = new R2Series(); r2.SeriesName = "R2"; r2.ChartType = C1.Chart.ChartType.Step; r2.Style = new C1.WPF.Chart.ChartStyle(); r2.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); r2.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); r2.Style.StrokeThickness = 1; r2.AxisY = AxisY; Chart.Series.Add(r2); r3 = new R3Series(); r3.SeriesName = "R3"; r3.ChartType = C1.Chart.ChartType.Step; r3.Style = new C1.WPF.Chart.ChartStyle(); r3.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); r3.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); r3.Style.StrokeThickness = 1; r3.AxisY = AxisY; Chart.Series.Add(r3); s1 = new S1Series(); s1.SeriesName = "S1"; s1.ChartType = C1.Chart.ChartType.Step; s1.Style = new C1.WPF.Chart.ChartStyle(); s1.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); s1.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); s1.Style.StrokeThickness = 1; s1.AxisY = AxisY; Chart.Series.Add(s1); s2 = new S2Series(); s2.SeriesName = "S2"; s2.ChartType = C1.Chart.ChartType.Step; s2.Style = new C1.WPF.Chart.ChartStyle(); s2.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); s2.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); s2.Style.StrokeThickness = 1; s2.AxisY = AxisY; Chart.Series.Add(s2); s3 = new S3Series(); s3.SeriesName = "S3"; s3.ChartType = C1.Chart.ChartType.Step; s3.Style = new C1.WPF.Chart.ChartStyle(); s3.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); s3.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); s3.Style.StrokeThickness = 1; s3.AxisY = AxisY; Chart.Series.Add(s3); Utilities.Helper.BindingSettingsParams(chart, this, typeof(PivotPoint), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("PivotType", typeof(PivotPointType)), }, () => { PivotPointCalculator.Instance.Create(); this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, series, typeof(PivotPointSeries), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("Style.Stroke", typeof(Brush), "Pivot"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, r1, typeof(PivotPointSeries), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("Style.Stroke", typeof(Brush), "R1"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, r2, typeof(PivotPointSeries), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("Style.Stroke", typeof(Brush), "R2"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, r3, typeof(PivotPointSeries), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("Style.Stroke", typeof(Brush), "R3"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, s1, typeof(PivotPointSeries), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("Style.Stroke", typeof(Brush), "S1"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, s2, typeof(PivotPointSeries), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("Style.Stroke", typeof(Brush), "S2"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, s3, typeof(PivotPointSeries), "Pivot Point", new Data.PropertyParam[] { new Data.PropertyParam("Style.Stroke", typeof(Brush), "S3"), }, () => { this.OnSettingParamsChanged(); } ); if (this.AxisY != null && this.AxisY.TitleStyle != null) { //binding series color to axis title. Binding binding = new Binding("Stroke"); binding.Source = series.Style; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); } Object.Quote quote = ViewModel.ViewModel.Instance.CurrectQuote; if (quote != null) { PivotPointCalculator.Instance.Source = quote.Data; } if (series != null) { series.Calculator = PivotPointCalculator.Instance; } if (r1 != null) { r1.Calculator = PivotPointCalculator.Instance; } if (r2 != null) { r2.Calculator = PivotPointCalculator.Instance; } if (r3 != null) { r3.Calculator = PivotPointCalculator.Instance; } if (s1 != null) { s1.Calculator = PivotPointCalculator.Instance; } if (s2 != null) { s2.Calculator = PivotPointCalculator.Instance; } if (s3 != null) { s3.Calculator = PivotPointCalculator.Instance; } ViewModel.ViewModel.Instance.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrectQuote") { quote = ViewModel.ViewModel.Instance.CurrectQuote; PivotPointCalculator.Instance.Source = quote.Data; } }; Chart.EndUpdate(); this.Series = new Series[] { series, r1, r2, r3, s1, s2, s3 }; }
public DataSource(C1FlexChart chart) { this.chart = chart; }
public ADX(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "ADX"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; DIPSeries dip = new DIPSeries(); dip.ChartType = C1.Chart.Finance.FinancialChartType.Line; dip.Style = new C1.WPF.Chart.ChartStyle(); dip.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); dip.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); dip.Style.StrokeThickness = 1; //dip.BindingX = "Date"; //dip.Binding = "High,Low,Close"; dip.AxisY = AxisY; Chart.Series.Add(dip); DINSeries din = new DINSeries(); din.ChartType = C1.Chart.Finance.FinancialChartType.Line; din.Style = new C1.WPF.Chart.ChartStyle(); din.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); din.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); din.Style.StrokeThickness = 1; //din.BindingX = "Date"; //din.Binding = "High,Low,Close"; din.AxisY = AxisY; Chart.Series.Add(din); ADXSeries adx = new ADXSeries(); adx.ChartType = C1.Chart.Finance.FinancialChartType.Line; adx.Style = new C1.WPF.Chart.ChartStyle(); adx.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.DefaultBorder); adx.Style.StrokeThickness = 1; //adx.BindingX = "Date"; //adx.Binding = "High,Low,Close"; adx.AxisY = AxisY; Chart.Series.Add(adx); Utilities.Helper.BindingSettingsParams(chart, dip, typeof(DIPSeries), "Average Directional Index (ADX)", new Data.PropertyParam[] { new Data.PropertyParam("Period", typeof(int)), new Data.PropertyParam("Style.Stroke", typeof(Brush), "D+"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, din, typeof(DINSeries), "Average Directional Index (ADX)", new Data.PropertyParam[] { new Data.PropertyParam("Period", typeof(int)), new Data.PropertyParam("Style.Stroke", typeof(Brush), "D-"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, adx, typeof(ADXSeries), "Average Directional Index (ADX)", new Data.PropertyParam[] { new Data.PropertyParam("Period", typeof(int)), new Data.PropertyParam("Style.Stroke", typeof(Brush), "ADX"), }, () => { this.OnSettingParamsChanged(); } ); //binding series color to axis title. Binding binding = new Binding("Stroke"); binding.Source = adx.Style; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { dip, din, adx }; Object.Quote quote = ViewModel.ViewModel.Instance.CurrectQuote; if (quote != null) { ADXCalculator.Instance.Source = quote.Data; } if (dip != null) { dip.Calculator = ADXCalculator.Instance; } if (din != null) { din.Calculator = ADXCalculator.Instance; } if (adx != null) { adx.Calculator = ADXCalculator.Instance; } ViewModel.ViewModel.Instance.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrectQuote") { quote = ViewModel.ViewModel.Instance.CurrectQuote; ADXCalculator.Instance.Source = quote.Data; } }; }
public AnnotationEx(C1FlexChart chart, AnnotationBase anno, Rect rect) { this.flexChart = chart; this.annotation = anno; this.BoundingRectangle = rect; }
public RSISeries(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = Windows.UI.Text.FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "RSI"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; RSI series = new RSI(); series.ChartType = C1.Chart.Finance.FinancialChartType.Line; series.Style = new ChartStyle(); series.Style.StrokeThickness = 1; series.BindingX = "Date"; series.Binding = "High,Low,Close"; series.AxisY = AxisY; Chart.Series.Add(series); ThresholdSeries overBought = new ThresholdSeries(); overBought.ChartType = C1.Chart.Finance.FinancialChartType.Line; overBought.Style = new ChartStyle(); overBought.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockGreen); overBought.Style.StrokeThickness = 1; overBought.AxisY = AxisY; Chart.Series.Add(overBought); ThresholdSeries overSold = new ThresholdSeries(); overSold.ChartType = C1.Chart.Finance.FinancialChartType.Line; overSold.Style = new ChartStyle(); overSold.Style.Stroke = new SolidColorBrush(ViewModel.IndicatorPalettes.StockRed); overSold.Style.StrokeThickness = 1; overSold.AxisY = AxisY; Chart.Series.Add(overSold); Utilities.Helper.BindingSettingsParams(chart, series, typeof(RSI), "Relative Strength Index (RSI)", new Data.PropertyParam[] { new Data.PropertyParam("Period", typeof(int)), new Data.PropertyParam("Style.Stroke", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overBought, typeof(ThresholdSeries), "Relative Strength Index (RSI)", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverBought"), }, () => { this.OnSettingParamsChanged(); } ); Utilities.Helper.BindingSettingsParams(chart, overSold, typeof(ThresholdSeries), "Relative Strength Index (RSI)", new Data.PropertyParam[] { new Data.PropertyParam("ZonesVisibility", typeof(bool)), new Data.PropertyParam("Threshold", typeof(int), "OverSold"), }, () => { this.OnSettingParamsChanged(); } ); overBought.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; overSold.OnThesholdChanged += (o, e) => { this.OnSettingParamsChanged(); }; //binding series color to axis title. Binding binding = new Binding(); binding.Path = new Windows.UI.Xaml.PropertyPath("Stroke"); binding.Source = series.Style; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series, overBought, overSold }; }
public VolumeSeries(C1FlexChart chart, string plotAreaName) : base() { Chart = chart; Chart.BeginUpdate(); AxisY.TitleStyle = new ChartStyle(); AxisY.TitleStyle.FontWeight = FontWeights.Bold; AxisY.Position = C1.Chart.Position.Right; AxisY.PlotAreaName = plotAreaName; AxisY.Title = "Vol"; AxisY.Labels = false; AxisY.MajorTickMarks = AxisY.MinorTickMarks = C1.Chart.TickMark.None; FinancialSeries series = new FinancialSeries(); series.ChartType = C1.Chart.Finance.FinancialChartType.ColumnVolume; series.Style = new C1.WPF.Chart.ChartStyle(); series.Style.Stroke = new SolidColorBrush(Color.FromArgb(255, 51, 103, 214)); series.Style.Fill = new SolidColorBrush(Color.FromArgb(128, 66, 133, 244)); series.Style.StrokeThickness = 1; series.BindingX = "Date"; series.Binding = "Volume,Close"; double[] values = null; ViewModel.ViewModel.Instance.PropertyChanged += (o, e) => { if (e.PropertyName == "CurrectQuote") { values = series.GetValues(2); // this is the closing value; } }; series.SymbolRendering += (sender, ev) => { if (ev.Index == 0) { return; } if (values == null) { values = series.GetValues(2); // this is the closing value; } if (values != null) { if (values[ev.Index - 1] > values[ev.Index]) { if (DownVolume is SolidColorBrush) { Color c = (DownVolume as SolidColorBrush).Color; Color cf = Color.FromArgb(128, c.R, c.G, c.B); ev.Engine.SetStroke(c.ToArgb()); ev.Engine.SetFill(cf.ToArgb()); } } else { if (UpVolume is SolidColorBrush) { Color c = (UpVolume as SolidColorBrush).Color; Color cf = Color.FromArgb(128, c.R, c.G, c.B); ev.Engine.SetStroke(c.ToArgb()); ev.Engine.SetFill(cf.ToArgb()); } } } }; series.AxisY = AxisY; Chart.Series.Add(series); //Utilities.Helper.BindingSettingsParams(chart, series, typeof(FinancialSeries), "Volume", // new Data.PropertyParam[] // { // new Data.PropertyParam("Style.Fill", typeof(Brush)), // new Data.PropertyParam("Style.Stroke", typeof(Brush)), // }, // () => // { // this.OnSettingParamsChanged(); // } //); Utilities.Helper.BindingSettingsParams(chart, this, typeof(VolumeSeries), "Volume", new Data.PropertyParam[] { new Data.PropertyParam("UpVolume", typeof(Brush)), new Data.PropertyParam("DownVolume", typeof(Brush)), }, () => { this.OnSettingParamsChanged(); } ); //binding series color to axis title. Binding binding = new Binding("UpVolume"); binding.Source = this; BindingOperations.SetBinding(AxisY.TitleStyle, ChartStyle.StrokeProperty, binding); Chart.EndUpdate(); this.Series = new FinancialSeries[] { series }; }