public override View GetSampleContent(Context context) { var chart = new SfChart(context);; chart.SetBackgroundColor(Color.White); chart.Title.Text = "Products Growth - 2015"; chart.Legend.Visibility = Visibility.Visible; if (context.Resources.DisplayMetrics.HeightPixels > context.Resources.DisplayMetrics.WidthPixels) { int padding = (context.Resources.DisplayMetrics.HeightPixels - context.Resources.DisplayMetrics.WidthPixels) / 2; chart.SetPadding(0, padding / 2, 0, padding); chart.Legend.DockPosition = ChartDock.Bottom; } else { int padding = (context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.HeightPixels) / 2; chart.SetPadding(padding, 0, padding, 0); chart.Legend.ItemMarginRight = padding / 6; chart.Legend.DockPosition = ChartDock.Right; } var datas = new ObservableArrayList(); datas.Add(new ChartDataPoint("Product A", 14)); datas.Add(new ChartDataPoint("Product B", 54)); datas.Add(new ChartDataPoint("Product C", 23)); datas.Add(new ChartDataPoint("Product D", 53)); var doughnutSeries = new DoughnutSeries { DataSource = datas, StartAngle = 180, EndAngle = 360 }; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.DataMarker.LabelContent = LabelContent.Percentage; doughnutSeries.DataMarkerPosition = CircularSeriesDataMarkerPosition.Outside; chart.Series.Add(doughnutSeries); return(chart); }
public override View GetSampleContent(Context context) { var chart = new SfChart(context); chart.SetBackgroundColor(Color.White); chart.Title.Text = "Products Growth - 2015"; chart.Legend.Visibility = Visibility.Visible; if (context.Resources.DisplayMetrics.HeightPixels > context.Resources.DisplayMetrics.WidthPixels) { int padding = (context.Resources.DisplayMetrics.HeightPixels - context.Resources.DisplayMetrics.WidthPixels) / 2; chart.SetPadding(0, padding / 2, 0, padding); chart.Legend.DockPosition = ChartDock.Bottom; } else { int padding = (context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.HeightPixels) / 2; chart.SetPadding(padding, 0, padding, 0); chart.Legend.ItemMarginRight = padding / 6; chart.Legend.DockPosition = ChartDock.Right; } var datas = new ObservableArrayList(); datas.Add(new ChartDataPoint("Product A", 14)); datas.Add(new ChartDataPoint("Product B", 54)); datas.Add(new ChartDataPoint("Product C", 23)); datas.Add(new ChartDataPoint("Product D", 53)); var pieSeries = new PieSeries { DataSource = datas, StartAngle = 180, EndAngle = 360, }; pieSeries.DataMarker.ShowLabel = true; pieSeries.DataMarker.LabelContent = LabelContent.Percentage; pieSeries.DataMarkerPosition = CircularSeriesDataMarkerPosition.Outside; chart.Series.Add(pieSeries); return chart; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LinearLayout linearLayout = new LinearLayout(this) { Orientation = Orientation.Vertical, LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) }; #region Chart chart = new SfChart(this) { PrimaryAxis = GetCategoryAxis(), SecondaryAxis = GetSecondaryAxis(), }; chart.SetPadding(20, 50, 20, 0); chart.Series.Add(new LineSeries() { ItemsSource = new ViewModel().Date, XBindingPath = "Month", YBindingPath = "Temperature", Color = Android.Graphics.Color.Red }); #endregion #region Spinner Spinner spinner = new Spinner(this) { Adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.action_array, Android.Resource.Layout.SimpleSpinnerItem), }; spinner.SetSelection(3); spinner.ItemSelected += Spinner_ItemSelected; #endregion #region TextView TextView textView = new TextView(this) { Text = "Choose Your Action", }; textView.SetPadding(5, 20, 5, 0); #endregion linearLayout.AddView(textView); linearLayout.AddView(spinner); linearLayout.AddView(chart); SetContentView(linearLayout); Window.AddFlags(WindowManagerFlags.Fullscreen); Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen); }
public override View GetSampleContent(Context context) { chart = new SfChart(context); chart.SetPadding(0, 10, 0, 0); chart.Behaviors.Add(new ChartTrackballBehavior()); DateTimeAxis dateTimeAxis = new DateTimeAxis(); dateTimeAxis.LabelStyle.LabelFormat = "MM/yyyy"; chart.PrimaryAxis = dateTimeAxis; NumericalAxis numericalAxis = new NumericalAxis(); chart.SecondaryAxis = numericalAxis; HiLoOpenCloseSeries candleSeries = new HiLoOpenCloseSeries(); candleSeries.ItemsSource = MainPage.GetTechnicalIndicatorData(); candleSeries.XBindingPath = "XValue"; candleSeries.Open = "Open"; candleSeries.Close = "Close"; candleSeries.High = "High"; candleSeries.Low = "Low"; candleSeries.EnableAnimation = true; candleSeries.Name = "Series"; chart.Series.Add(candleSeries); SimpleMovingAverageIndicator sMA = new SimpleMovingAverageIndicator(); sMA.SeriesName = "Series"; sMA.XBindingPath = "XValue"; sMA.Open = "Open"; sMA.Close = "Close"; sMA.High = "High"; sMA.Low = "Low"; sMA.EnableAnimation = true; chart.TechnicalIndicators.Add(sMA); TextView labelDisplayMode = new TextView(context); labelDisplayMode.TextSize = 20; labelDisplayMode.Text = "Technical Indicator type"; Spinner selectLabelMode = new Spinner(context, SpinnerMode.Dialog); adapter = new List <String>() { "Simple Moving Average Indicator", "Average True Indicator", "Exponential Moving Averge Indicator", "Momentum Indicator", "Accumulation Distribution Indicator", "RSI Indicator", "Triangular Moving Average Indicator", "MACD Indicator", "Stochastic Indicator", "Bollinger Band Indicator" }; ArrayAdapter <String> dataAdapter = new ArrayAdapter <String> (context, Android.Resource.Layout.SimpleSpinnerItem, adapter); dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line); selectLabelMode.Adapter = dataAdapter; selectLabelMode.ItemSelected += SelectLabelMode_ItemSelected; LinearLayout linearLayout = new LinearLayout(context); linearLayout.SetPadding(20, 0, 20, 30); linearLayout.SetBackgroundColor(Color.Rgb(236, 235, 242)); linearLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); linearLayout.Orientation = Orientation.Vertical; linearLayout.SetBackgroundColor(Color.White); linearLayout.AddView(selectLabelMode); linearLayout.AddView(chart); return(linearLayout); }