コード例 #1
0
 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();
     }
 }
コード例 #2
0
        /// <summary>
        /// Executes the chart demo.
        /// </summary>
        /// <param name="context"> the context </param>
        /// <returns> the built intent </returns>
        public override Intent Execute(Context context)
        {
            double[]        values   = new double[] { 12, 14, 11, 10, 19 };
            int[]           colors   = new int[] { Color.Blue, Color.Green, Color.Magenta, Color.Yellow, Color.Cyan };
            DefaultRenderer renderer = BuildCategoryRenderer(colors);

            renderer.ZoomButtonsVisible = true;
            renderer.ZoomEnabled        = true;
            renderer.ChartTitleTextSize = 20;
            renderer.DisplayValues      = true;
            renderer.ShowLabels         = false;
            SimpleSeriesRenderer r = renderer.GetSeriesRendererAt(0);

            r.GradientEnabled = true;
            r.SetGradientStart(0, Color.Blue);
            r.SetGradientStop(0, Color.Green);
            r.Highlighted = true;
            Intent intent = ChartFactory.GetPieChartIntent(context, BuildCategoryDataset("Project budget", values), renderer, "Budget");

            return(intent);
        }