protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); SetContentView(Resource.Layout.PieChartLayout); //mChart = new PieChart(this); //SetContentView(mChart); #if true tvX = (TextView) FindViewById(Resource.Id.tvXMax); tvY = (TextView) FindViewById(Resource.Id.tvYMax); mSeekBarX = (SeekBar) FindViewById(Resource.Id.seekBar1); mSeekBarY = (SeekBar) FindViewById(Resource.Id.seekBar2); mSeekBarY.Progress = 10; mSeekBarX.SetOnSeekBarChangeListener(this); mSeekBarY.SetOnSeekBarChangeListener(this); #endif #if true mChart = (PieChart) FindViewById(Resource.Id.chart1); mChart.SetUsePercentValues(true); mChart.SetDescription(""); mChart.SetExtraOffsets(5, 10, 5, 5); mChart.DragDecelerationFrictionCoef = 0.95f; //tf = Typeface.CreateFromAsset(Assets, "OpenSans-Regular.ttf"); //mChart.SetCenterTextTypeface(Typeface.CreateFromAsset(Assets, "OpenSans-Light.ttf")); mChart.CenterText = "MPAndroidChart developed by Philipp Jahoda"; //mChart.setcenter CenterText = new SpannableString(mChart.) Spanable generateCenterSpannableText(); mChart.DrawHoleEnabled = true; mChart.SetHoleColorTransparent(true); mChart.SetTransparentCircleColor(Color.White); mChart.SetTransparentCircleAlpha(110); mChart.HoleRadius = 58f; mChart.TransparentCircleRadius = 61f; mChart.SetDrawCenterText(true); mChart.RotationAngle = 0; // enable rotation of the chart by touch mChart.RotationEnabled = true; mChart.HighlightEnabled = true; // mChart.setUnit(" €"); // mChart.setDrawUnitsInChart(true); // add a selection listener mChart.SetOnChartValueSelectedListener(this); SetData(3, 100); mChart.AnimateY(1400, Easing.EasingOption.EaseInOutQuad); // mChart.spin(2000, 0, 360); var l = mChart.Legend; l.Position = Legend.LegendPosition.RightOfChart; l.XEntrySpace = 7f; l.YEntrySpace = 0f; l.YOffset = 0f; // Create your application here #endif }
private void MyPieChart() { sumOfLowOccupancy = (from table in mListStatsColumns where table.LOW_OCCUPANCY.Contains("YES", StringComparison.OrdinalIgnoreCase) select table).Count(); sumOfHighOccupancy = (from table in mListStatsColumns where table.LOW_OCCUPANCY.Contains("NO", StringComparison.OrdinalIgnoreCase) select table).Count(); resoultHighOccupancy = (sumOfHighOccupancy / sumOfLowOccupancy) * 100; resoultLowOccupncy = (sumOfLowOccupancy / sumOfHighOccupancy) * 100; mListOfEntry = new List <PieEntry>(); mListOfEntry.Add(new PieEntry(resoultHighOccupancy, "High occupancy")); mListOfEntry.Add(new PieEntry(resoultLowOccupncy, "Low occupancy")); dataSet = new PieDataSet(mListOfEntry, ""); dataSet.SliceSpace = 3; dataSet.SelectionShift = 2; dataSet.SetColor(Color.DarkGreen, 200); dataSet.AddColor(Color.DarkRed); PieData data = new PieData(dataSet); data.SetValueFormatter(new PercentFormatter()); data.SetValueTextSize(11f); data.SetValueTextColor(Color.Black); mPieChart.Data = data; mPieChart.HighlightValues(null); mPieChart.SetUsePercentValues(true); mPieChart.Description.Enabled = false; mPieChart.SetExtraOffsets(5, 10, 5, 5); mPieChart.DrawHoleEnabled = true; mPieChart.SetHoleColor(Color.White); mPieChart.HoleRadius = 7; mPieChart.SetTransparentCircleAlpha(10); mPieChart.RotationAngle = 0; mPieChart.RotationEnabled = true; mPieChart.HighlightPerTapEnabled = true; mPieChart.AnimateY(2000, Easing.EasingOption.EaseInOutQuad); Legend legend = mPieChart.Legend; legend.Position = Legend.LegendPosition.RightOfChart; legend.XEntrySpace = 7; legend.YEntrySpace = 5; mPieChart.Invalidate(); }