public TechnicalIndicators() { indicatorTypePicker = new UIPickerView(); indicatorTypeTextButton = new UIButton(); doneButton = new UIButton(); indicator = new SFSMAIndicator(); indicator.SeriesName = new NSString("Hi-Low"); indicator.XBindingPath = "XValue"; indicator.High = "High"; indicator.Low = "Low"; indicator.Open = "Open"; indicator.Close = "Close"; SFNumericalAxis axis = new SFNumericalAxis(); axis.OpposedPosition = true; axis.ShowMajorGridLines = false; indicator.YAxis = axis; indicatorCollection = new NSMutableArray(); indicatorCollection.Add(indicator); chart = new SFChart(); chart.Title.Text = new NSString("StockDetails"); chart.Title.TextAlignment = UITextAlignment.Center; SFDateTimeAxis datetime = new SFDateTimeAxis(); datetime.MaximumLabels = 6; datetime.LabelsIntersectAction = SFChartAxisLabelsIntersectAction.Hide; chart.PrimaryAxis = datetime; datetime.Title.Text = new NSString("Date"); chart.SecondaryAxis = new SFNumericalAxis(); SFChartTrackballBehavior behavior = new SFChartTrackballBehavior(); chart.AddChartBehavior(behavior); chart.TechnicalIndicators.Add(indicator); ChartViewModel dataModel = new ChartViewModel(); SFOHLCSeries series = new SFOHLCSeries(); series.ItemsSource = dataModel.TechnicalIndicatorData; series.XBindingPath = "XValue"; series.High = "High"; series.Low = "Low"; series.Open = "Open"; series.Close = "Close"; series.EnableTooltip = true; series.LineWidth = 1; series.SeriesName = new NSString("Hi-Low"); series.ColorModel.Palette = SFChartColorPalette.Natural; chart.Series.Add(series); this.AddSubview(chart); indicatorTypeTextButton.SetTitle("SMA indicator", UIControlState.Normal); indicatorTypeTextButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; indicatorTypeTextButton.SetTitleColor(UIColor.Black, UIControlState.Normal); indicatorTypeTextButton.TouchUpInside += delegate { indicatorTypePicker.Hidden = false; doneButton.Hidden = false; this.BecomeFirstResponder(); }; indicatorTypeTextButton.BackgroundColor = UIColor.Clear; indicatorTypeTextButton.Layer.BorderWidth = 2.0f; indicatorTypeTextButton.Layer.BorderColor = UIColor.FromRGB(240.0f / 255.0f, 240.0f / 255.0f, 240.0f / 255.0f).CGColor; indicatorTypeTextButton.Layer.CornerRadius = 8.0f; this.AddSubview(indicatorTypeTextButton); indicatorTypePicker.ShowSelectionIndicator = true; indicatorTypePicker.Hidden = true; indicatorTypePicker.Model = new StatusPickerViewModel(chart, indicatorTypeTextButton, indicator, indicatorCollection); indicatorTypePicker.BackgroundColor = UIColor.FromRGB(240f / 255.0f, 240f / 255.0f, 240f / 255.0f); indicatorTypePicker.SelectedRowInComponent(0); this.AddSubview(indicatorTypePicker); doneButton.SetTitle("Done" + "\t", UIControlState.Normal); doneButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right; doneButton.SetTitleColor(UIColor.Black, UIControlState.Normal); doneButton.TouchUpInside += delegate { indicatorTypePicker.Hidden = true; doneButton.Hidden = true; this.BecomeFirstResponder(); }; doneButton.BackgroundColor = UIColor.FromRGB(240f / 255.0f, 240f / 255.0f, 240f / 255.0f); doneButton.Hidden = true; this.AddSubview(doneButton); }
public StackedLine() { SFChart chart = new SFChart(); chart.Title.Text = new NSString("Monthly expense of a family"); chart.ColorModel.Palette = SFChartColorPalette.Natural; SFCategoryAxis primaryAxis = new SFCategoryAxis(); primaryAxis.LabelPlacement = SFChartLabelPlacement.BetweenTicks; primaryAxis.ShowMajorGridLines = false; primaryAxis.MajorTickStyle.LineSize = 0; chart.PrimaryAxis = primaryAxis; chart.SecondaryAxis = new SFNumericalAxis(); chart.SecondaryAxis.Maximum = new NSNumber(200); chart.SecondaryAxis.Minimum = new NSNumber(0); chart.SecondaryAxis.Interval = new NSNumber(20); chart.SecondaryAxis.AxisLineStyle.LineWidth = 0; chart.SecondaryAxis.MajorTickStyle.LineSize = 0; NSNumberFormatter formatter = new NSNumberFormatter(); formatter.PositiveSuffix = "$"; chart.SecondaryAxis.LabelStyle.LabelFormatter = formatter; ChartViewModel dataModel = new ChartViewModel(); SFChartTrackballBehavior behavior = new SFChartTrackballBehavior(); chart.AddChartBehavior(behavior); SFStackingLineSeries series1 = new SFStackingLineSeries(); series1.LineWidth = 2; series1.ItemsSource = dataModel.StackedLineData1; series1.XBindingPath = "XValue"; series1.YBindingPath = "YValue"; series1.DataMarker.ShowMarker = true; series1.DataMarker.MarkerColor = UIColor.White; series1.DataMarker.MarkerBorderColor = UIColor.FromRGBA(0.0f / 255.0f, 189.0f / 255.0f, 174.0f / 255.0f, 1.0f); series1.DataMarker.MarkerBorderWidth = 2; series1.DataMarker.MarkerWidth = 10f; series1.DataMarker.MarkerHeight = 10f; series1.LegendIcon = SFChartLegendIcon.SeriesType; series1.EnableTooltip = false; series1.Label = "Daughter"; series1.EnableAnimation = true; series1.LegendIcon = SFChartLegendIcon.SeriesType; chart.Series.Add(series1); SFStackingLineSeries series2 = new SFStackingLineSeries(); series2.LineWidth = 2; series2.ItemsSource = dataModel.StackedLineData2; series2.XBindingPath = "XValue"; series2.YBindingPath = "YValue"; series2.DataMarker.ShowMarker = true; series2.DataMarker.MarkerColor = UIColor.White; series2.DataMarker.MarkerBorderColor = UIColor.FromRGBA(64.0f / 255.0f, 64.0f / 255.0f, 65.0f / 255.0f, 1.0f); series2.DataMarker.MarkerBorderWidth = 2; series2.DataMarker.MarkerWidth = 10f; series2.DataMarker.MarkerHeight = 10f; series2.LegendIcon = SFChartLegendIcon.SeriesType; series2.EnableTooltip = false; series2.Label = "Son"; series2.LegendIcon = SFChartLegendIcon.SeriesType; series2.EnableAnimation = true; chart.Series.Add(series2); SFStackingLineSeries series3 = new SFStackingLineSeries(); series3.LineWidth = 2; series3.ItemsSource = dataModel.StackedLineData3; series3.XBindingPath = "XValue"; series3.YBindingPath = "YValue"; series3.DataMarker.ShowMarker = true; series3.DataMarker.MarkerColor = UIColor.White; series3.DataMarker.MarkerBorderColor = UIColor.FromRGBA(53.0f / 255.0f, 124.0f / 255.0f, 210.0f / 255.0f, 1.0f); series3.DataMarker.MarkerBorderWidth = 2; series3.DataMarker.MarkerWidth = 10f; series3.DataMarker.MarkerHeight = 10f; series3.LegendIcon = SFChartLegendIcon.SeriesType; series3.EnableTooltip = false; series3.Label = "Mother"; series3.EnableAnimation = true; chart.Series.Add(series3); SFStackingLineSeries series4 = new SFStackingLineSeries(); series4.ItemsSource = dataModel.StackedLineData4; series4.XBindingPath = "XValue"; series4.YBindingPath = "YValue"; series4.DataMarker.ShowMarker = true; series4.DataMarker.MarkerColor = UIColor.White; series4.DataMarker.MarkerBorderColor = UIColor.FromRGBA(229.0f / 255.0f, 101.0f / 255.0f, 144.0f / 255.0f, 1.0f); series4.DataMarker.MarkerBorderWidth = 2; series4.DataMarker.MarkerWidth = 10f; series4.DataMarker.MarkerHeight = 10f; series4.LegendIcon = SFChartLegendIcon.SeriesType; series4.EnableTooltip = false; series4.Label = "Father"; series4.EnableAnimation = true; chart.Series.Add(series4); chart.Legend.Visible = true; chart.Legend.ToggleSeriesVisibility = true; chart.Legend.IconWidth = 14; chart.Legend.IconHeight = 14; chart.Legend.DockPosition = SFChartLegendPosition.Bottom; this.AddSubview(chart); }