Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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();
        }