コード例 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mView        = inflater.Inflate(Resource.Layout.ChartAllTablesDialog, container, false);
            chartSuccess = mView.FindViewById <BarChart>(Resource.Id.chartAllTablesDialog);

            dicOfDataSets = new Dictionary <string, List <BarEntry> >();

            List <StatsTables> searchedTable = (from table in listStatsTables
                                                where table.big_deviation.Contains("NO", StringComparison.OrdinalIgnoreCase)
                                                select table).ToList <StatsTables>();

            foreach (StatsTables row in searchedTable)
            {
                if (!listTableNames.Contains(row.table_name))
                {
                    listTableNames.Add(row.table_name);
                }
            }

            int counter = 0;

            foreach (string table in listTableNames)
            {
                barEntry = new List <BarEntry>();
                foreach (StatsTables item in searchedTable)
                {
                    if (table == item.table_name)
                    {
                        barEntry.Add(new BarEntry(counter, item.diff_last_trans));
                        counter++;
                    }
                }
                dicOfDataSets.Add(table, barEntry);
            }

            BarData data = new BarData();

            int[] chartColors  = { Color.ParseColor("#005571"), Color.ParseColor("#227691"), Color.ParseColor("#86B1C6"), Color.ParseColor("#BCD4E0"), Color.ParseColor("#FDB813"), Color.ParseColor("#FFC54E"), Color.ParseColor("#FFD27C"), Color.ParseColor("#FFE6B9") };
            int   counterColor = 0;

            foreach (KeyValuePair <string, List <BarEntry> > dicDataSet in dicOfDataSets)
            {
                dataSet = new BarDataSet(dicDataSet.Value, dicDataSet.Key);
                dataSet.SetColors(chartColors[counterColor]);
                data.AddDataSet(dataSet);
                counterColor++;
            }

            XAxis xAxis = chartSuccess.XAxis;

            xAxis.SetCenterAxisLabels(false);
            xAxis.SetDrawLabels(false);
            xAxis.Position = XAxis.XAxisPosition.BottomInside;
            xAxis.SetDrawGridLines(false);
            xAxis.SetAvoidFirstLastClipping(true);
            xAxis.XOffset = 10;

            Legend l = chartSuccess.Legend;

            l.VerticalAlignment   = Legend.LegendVerticalAlignment.Top;
            l.HorizontalAlignment = Legend.LegendHorizontalAlignment.Right;
            l.Orientation         = Legend.LegendOrientation.Vertical;
            l.WordWrapEnabled     = true;
            l.SetDrawInside(true);

            chartSuccess.Data = data;
            chartSuccess.AxisRight.SetDrawLabels(false);
            chartSuccess.XAxis.SetDrawLabels(false);
            chartSuccess.AnimateXY(3000, 3000);

            chartSuccess.Description.Enabled = true;
            chartSuccess.Description.Text    = "Tables without big deviation";

            chartSuccess.Invalidate();

            return(mView);
        }
コード例 #2
0
ファイル: UserActivity.cs プロジェクト: danejur/AniDroid
        private View CreateScoreDistributionView(
            IReadOnlyList <AniListScoreDistribution> animeScoreDistributions,
            IReadOnlyList <AniListScoreDistribution> mangaScoreDistributions)
        {
            var chartHeight = Resources.GetDimensionPixelSize(Resource.Dimension.Details_ChartHeight);
            var textColor   = GetThemedColor(Resource.Attribute.Background_Text);
            var margin      = Resources.GetDimensionPixelSize(Resource.Dimension.Details_MarginSmall);

            var detailView      = LayoutInflater.Inflate(Resource.Layout.View_AniListObjectDetail, null);
            var detailContainer = detailView.FindViewById <LinearLayout>(Resource.Id.AniListObjectDetail_InnerContainer);

            detailView.FindViewById <TextView>(Resource.Id.AniListObjectDetail_Name).Text = "Score Distribution";
            detailContainer.Orientation = Orientation.Horizontal;
            detailContainer.SetPadding(margin, 0, margin, 0);

            var typedColorArray = Resources.ObtainTypedArray(Resource.Array.Chart_Colors);
            var colorList       = new List <int>();

            for (var i = 0; i < typedColorArray.Length(); i++)
            {
                colorList.Add(typedColorArray.GetColor(i, 0));
            }

            var scoreDistChart = new BarChart(this)
            {
                LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, chartHeight),
            };

            var data = new BarData()
            {
                BarWidth = 4.5F
            };

            var animeEntries = Enumerable.Range(1, 10).Select(x => new BarEntry(x * 10, animeScoreDistributions.Any(y => y.Score == (x * 10)) ? animeScoreDistributions.First(y => y.Score == (x * 10)).Amount : 0, (x * 10).ToString())).ToList();
            var animeDataSet = new BarDataSet(animeEntries, "Anime")
            {
                Color = colorList[4]
            };

            data.AddDataSet(animeDataSet);

            var mangaEntries = Enumerable.Range(1, 10).Select(x => new BarEntry(x * 10, mangaScoreDistributions.Any(y => y.Score == (x * 10)) ? mangaScoreDistributions.First(y => y.Score == (x * 10)).Amount : 0, (x * 10).ToString())).ToList();
            var mangaDataSet = new BarDataSet(mangaEntries, "Manga")
            {
                Color = colorList[5]
            };

            data.AddDataSet(mangaDataSet);

            data.SetValueFormatter(new ChartUtils.IntegerValueFormatter());

            scoreDistChart.Data = data;
            scoreDistChart.SetTouchEnabled(false);
            scoreDistChart.SetScaleEnabled(false);
            scoreDistChart.GroupBars(5F, .6F, .2F);
            scoreDistChart.AxisLeft.Enabled    = false;
            scoreDistChart.AxisRight.Enabled   = false;
            scoreDistChart.Description.Enabled = false;
            scoreDistChart.XAxis.SetDrawGridLines(false);
            scoreDistChart.XAxis.SetDrawAxisLine(false);
            scoreDistChart.XAxis.Position    = XAxis.XAxisPosition.BottomInside;
            scoreDistChart.XAxis.Granularity = 1;
            scoreDistChart.XAxis.LabelCount  = 10;
            scoreDistChart.XAxis.TextColor   = animeDataSet.ValueTextColor = mangaDataSet.ValueTextColor = scoreDistChart.Legend.TextColor = textColor;

            detailContainer.AddView(scoreDistChart);

            return(detailView);
        }
コード例 #3
0
        private void ChartError()
        {
            mDicOfDataSets = new Dictionary <string, List <BarEntry> >();

            List <StatsTables> searchedTable = (from table in mListStatsTables
                                                where table.big_deviation.Contains("YES", StringComparison.OrdinalIgnoreCase)
                                                select table).ToList <StatsTables>();

            foreach (StatsTables row in searchedTable)
            {
                if (!mListTableNames.Contains(row.table_name))
                {
                    mListTableNames.Add(row.table_name);
                }
            }

            int counter = 0;

            foreach (string table in mListTableNames)
            {
                List <BarEntry> barEntry = new List <BarEntry>();
                foreach (StatsTables item in searchedTable)
                {
                    if (table == item.table_name)
                    {
                        barEntry.Add(new BarEntry(counter, item.diff_last_trans));
                        counter++;
                    }
                }
                mDicOfDataSets.Add(table, barEntry);
            }

            BarData data = new BarData();

            foreach (KeyValuePair <string, List <BarEntry> > dicDataSet in mDicOfDataSets)
            {
                dataSet = new BarDataSet(dicDataSet.Value, dicDataSet.Key);
                dataSet.SetColors(Color.DarkRed);
                data.AddDataSet(dataSet);
            }

            XAxis xAxis = chartError.XAxis;

            xAxis.SetCenterAxisLabels(false);
            xAxis.SetDrawLabels(false);
            xAxis.Position = XAxis.XAxisPosition.BottomInside;
            xAxis.SetDrawGridLines(false);

            chartError.Data = data;
            chartError.AxisRight.SetDrawLabels(false);
            chartError.XAxis.SetDrawLabels(false);
            chartError.AnimateXY(2000, 2000);

            chartError.Legend.Enabled = false;
            chartError.SetTouchEnabled(true);
            chartError.SetPinchZoom(false);
            chartError.DoubleTapToZoomEnabled = false;

            chartError.Description.Enabled = true;
            chartError.Description.Text    = "Tables with big deviation";

            //chartError.SetBackgroundColor(Color.WhiteSmoke);

            chartError.Invalidate();
        }
コード例 #4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mView           = inflater.Inflate(Resource.Layout.ChartAllTablesDialog, container, false);
            mChartAllTables = mView.FindViewById <BarChart>(Resource.Id.chartAllTablesDialog);

            dicOfDataSets = new Dictionary <string, List <BarEntry> >();

            foreach (StatsTables row in listStatsTables)
            {
                if (!listTableNames.Contains(row.table_name))
                {
                    listTableNames.Add(row.table_name);
                }
            }

            int counter = 0;


            foreach (string table in listTableNames)
            {
                List <BarEntry> barEntry = new List <BarEntry>();
                foreach (StatsTables item in listStatsTables)
                {
                    if (table == item.table_name)
                    {
                        barEntry.Add(new BarEntry(counter, item.diff_last_trans));
                        counter++;
                    }
                }
                dicOfDataSets.Add(table, barEntry);
            }

            BarData data = new BarData();

            int[] chartColors  = { Color.ParseColor("#005571"), Color.ParseColor("#227691"), Color.ParseColor("#86B1C6"), Color.ParseColor("#BCD4E0"), Color.ParseColor("#FDB813"), Color.ParseColor("#FFC54E"), Color.ParseColor("#FFD27C"), Color.ParseColor("#FFE6B9") };
            int   colorCounter = 0;

            foreach (KeyValuePair <string, List <BarEntry> > dicDataSet in dicOfDataSets)
            {
                dataSet = new BarDataSet(dicDataSet.Value, dicDataSet.Key);
                dataSet.SetColors(chartColors[colorCounter]);
                data.AddDataSet(dataSet);
                colorCounter++;
            }

            LimitLine limitLine = new LimitLine(70f);

            limitLine.LineColor = Color.DarkRed;
            limitLine.Enabled   = true;

            XAxis xAxis = mChartAllTables.XAxis;

            xAxis.SetCenterAxisLabels(false);
            xAxis.SetDrawLabels(false);
            xAxis.Position = XAxis.XAxisPosition.BottomInside;
            xAxis.SetDrawGridLines(false);

            YAxis yAxis = mChartAllTables.AxisLeft;

            yAxis.SetDrawGridLines(true);
            yAxis.AddLimitLine(limitLine);

            Legend l = mChartAllTables.Legend;

            l.VerticalAlignment   = Legend.LegendVerticalAlignment.Top;
            l.HorizontalAlignment = Legend.LegendHorizontalAlignment.Right;
            l.Orientation         = Legend.LegendOrientation.Vertical;
            l.WordWrapEnabled     = true;
            l.SetDrawInside(true);

            mChartAllTables.Data = data;
            mChartAllTables.AxisRight.SetDrawLabels(false);
            mChartAllTables.XAxis.SetDrawLabels(false);
            mChartAllTables.AnimateXY(3000, 3000);

            mChartAllTables.Description.Enabled = true;
            mChartAllTables.Description.Text    = "All tables chart";

            mChartAllTables.Invalidate();

            return(mView);
        }
コード例 #5
0
        private void ChartAllTables()
        {
            mDicOfDataSets = new Dictionary <string, List <BarEntry> >();

            foreach (StatsTables row in mListStatsTables)
            {
                if (!mListTableNames.Contains(row.table_name))
                {
                    mListTableNames.Add(row.table_name);
                }
            }

            int counter = 0;


            foreach (string table in mListTableNames)
            {
                List <BarEntry> barEntry = new List <BarEntry>();
                foreach (StatsTables item in mListStatsTables)
                {
                    if (table == item.table_name)
                    {
                        barEntry.Add(new BarEntry(counter, item.diff_last_trans));
                        counter++;
                    }
                }
                mDicOfDataSets.Add(table, barEntry);
            }

            BarData data = new BarData();

            int[] chartColors = { Color.DarkRed, Color.DarkGreen };

            foreach (KeyValuePair <string, List <BarEntry> > dicDataSet in mDicOfDataSets)
            {
                dataSet = new BarDataSet(dicDataSet.Value, dicDataSet.Key);

                foreach (BarEntry item in dicDataSet.Value)
                {
                    if (item.GetY() > 70)
                    {
                        dataSet.SetColors(chartColors[0]);
                    }

                    else
                    {
                        dataSet.SetColors(chartColors[1]);
                    }
                }
                data.AddDataSet(dataSet);
            }

            LimitLine limitLine = new LimitLine(70f);

            limitLine.LineColor = Color.DarkRed;
            limitLine.Enabled   = true;

            XAxis xAxis = chartAllTables.XAxis;

            xAxis.SetDrawLabels(false);
            xAxis.Position = XAxis.XAxisPosition.BottomInside;
            xAxis.SetDrawGridLines(true);

            YAxis yAxis = chartAllTables.AxisLeft;

            yAxis.SetDrawGridLines(true);
            yAxis.AddLimitLine(limitLine);

            chartAllTables.Data = data;
            chartAllTables.AxisRight.SetDrawLabels(false);
            chartAllTables.AnimateXY(3000, 3000);

            chartAllTables.Legend.Enabled = false;
            chartAllTables.SetTouchEnabled(true);
            chartAllTables.SetPinchZoom(false);
            chartAllTables.DoubleTapToZoomEnabled = false;

            chartAllTables.Description.Enabled = true;
            chartAllTables.Description.Text    = "All tables chart";

            //chartAllTables.SetBackgroundColor(Color.WhiteSmoke);

            chartAllTables.Invalidate();
        }