protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.xy_chart); mValue = FindViewById <EditText>(Resource.Id.xValue); mRenderer.ZoomButtonsVisible = true; mRenderer.StartAngle = 180; mRenderer.DisplayValues = true; mAdd = FindViewById <Button>(Resource.Id.add); mAdd.Enabled = true; mValue.Enabled = true; mAdd.Click += (e, s) => { double value = 0; try { value = Double.Parse(mValue.Text); } catch (Java.Lang.NumberFormatException) { mValue.RequestFocus(); return; } mValue.Text = ""; mValue.RequestFocus(); mSeries.Add("Series " + (mSeries.ItemCount + 1), value); SimpleSeriesRenderer renderer = new SimpleSeriesRenderer(); renderer.Color = COLORS[(mSeries.ItemCount - 1) % COLORS.Length]; mRenderer.AddSeriesRenderer(renderer); mChartView.Repaint(); }; }
protected override void OnResume() { base.OnResume(); if (mChartView == null) { LinearLayout layout = FindViewById <LinearLayout>(Resource.Id.chart); mChartView = ChartFactory.GetLineChartView(this, mDataset, mRenderer); // enable the chart click events mRenderer.ClickEnabled = true; mRenderer.SelectableBuffer = 10; mChartView.SetOnClickListener(new OnClickListenerAnonymousInnerClassHelper3(this)); layout.AddView ( mChartView, new Android.Widget.LinearLayout.LayoutParams ( Android.Widget.LinearLayout.LayoutParams.FillParent, Android.Widget.LinearLayout.LayoutParams.FillParent) ); bool enabled = mDataset.SeriesCount > 0; SeriesWidgetsEnabled = enabled; } else { mChartView.Repaint(); } }
protected override void OnResume() { base.OnResume(); if (mChartView == null) { LinearLayout layout = FindViewById <LinearLayout>(Resource.Id.chart); mChartView = ChartFactory.GetPieChartView(this, mSeries, mRenderer); mRenderer.ClickEnabled = true; mChartView.Click += (e, s) => { SeriesSelection seriesSelection = mChartView.CurrentSeriesAndPoint; if (seriesSelection == null) { Toast.MakeText(this, "No chart element selected", ToastLength.Short).Show(); } else { for (int i = 0; i < mSeries.ItemCount; i++) { mRenderer.GetSeriesRendererAt(i).Highlighted = (i == seriesSelection.PointIndex); } mChartView.Repaint(); Toast.MakeText(this, "Chart data point index " + seriesSelection.PointIndex + " selected " + "point value=" + seriesSelection.Value, ToastLength.Short).Show(); } }; layout.AddView(mChartView, new Android.Views.ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent)); } else { mChartView.Repaint(); } }
protected override void OnResume() { base.OnResume(); if (mChartView == null) { LinearLayout layout = FindViewById <LinearLayout>(Resource.Id.chart); // mChartView = ChartFactory.getLineChartView(this, mDataset, mRenderer); // mChartView = ChartFactory.getBarChartView(this, mDataset, mRenderer, // Type.DEFAULT); mChartView = ChartFactory.GetScatterChartView(this, mDataset, mRenderer); // enable the chart click events mRenderer.ClickEnabled = true; mRenderer.SelectableBuffer = 100; mChartView.SetOnClickListener(new OnClickListenerAnonymousInnerClassHelper3(this)); // an example of handling the zoom events on the chart mChartView.AddZoomListener(new ZoomListenerAnonymousInnerClassHelper(this), true, true); // an example of handling the pan events on the chart //mChartView.AddPanListener(new PanListenerAnonymousInnerClassHelper(this)); layout.AddView ( mChartView, new Android.Widget.LinearLayout.LayoutParams ( Android.Widget.LinearLayout.LayoutParams.FillParent, Android.Widget.LinearLayout.LayoutParams.FillParent ) ); bool enabled = mDataset.SeriesCount > 0; SeriesWidgetsEnabled = enabled; } else { mChartView.Repaint(); } }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.xy_chart); mX = FindViewById <EditText>(Resource.Id.xValue); mY = FindViewById <EditText>(Resource.Id.yValue); mAdd = FindViewById <Button>(Resource.Id.add); mRenderer.ApplyBackgroundColor = true; mRenderer.BackgroundColor = Color.Argb(100, 50, 50, 50); mRenderer.AxisTitleTextSize = 16; mRenderer.ChartTitleTextSize = 20; mRenderer.LabelsTextSize = 15; mRenderer.LegendTextSize = 15; mRenderer.SetMargins(new int[] { 20, 30, 15, 0 }); mRenderer.ZoomButtonsVisible = true; mRenderer.PointSize = 5; mNewSeries = FindViewById <Button>(Resource.Id.new_series); mNewSeries.Click += (e, s) => { String seriesTitle = "Series " + mDataset.SeriesCount + 1; XYSeries series = new XYSeries(seriesTitle); mDataset.AddSeries(series); mCurrentSeries = series; XYSeriesRenderer renderer = new XYSeriesRenderer(); mRenderer.AddSeriesRenderer(renderer); renderer.PointStyle = PointStyle.Circle; renderer.FillPoints = true; renderer.DisplayChartValues = true; renderer.DisplayChartValuesDistance = 10; mCurrentRenderer = renderer; SetSeriesWidgetsEnabled(true); mChartView.Repaint(); }; mAdd.Click += (e, s) => { double x = 0; double y = 0; try { x = Double.Parse(mX.Text); } catch (Exception) { mX.RequestFocus(); return; } try { y = double.Parse(mY.Text); } catch (Exception) { mY.RequestFocus(); return; } mCurrentSeries.Add(x, y); mX.Text = ""; mY.Text = ""; mX.RequestFocus(); mChartView.Repaint(); }; }