Пример #1
0
        private BarChartViewModel GetBarChart()
        {
            BarDataSet dataset = new BarDataSet()
            {
                label           = "Buy",
                data            = new int[] { 65, 59, 80, 81, 56, 55, 40 },
                backgroundColor = "#42A5F5",
                borderColor     = "borderColor"
            };

            BarDataSet dataset2 = new BarDataSet()
            {
                label           = "Borrow",
                data            = new int[] { 28, 48, 40, 19, 86, 27, 90 },
                backgroundColor = "#9CCC65",
                borderColor     = "7CB342"
            };

            BarChartViewModel vm = new BarChartViewModel()
            {
                labels   = new string[] { "January", "February", "March", "April", "May", "June", "July" },
                datasets = new BarDataSet[] { dataset, dataset2 }
            };

            return(vm);
        }
        public MainPage()
        {
            InitializeComponent();

            var entries = new List <EntryChart>();

            entries.Add(new EntryChart(0, 5));
            entries.Add(new EntryChart(1, 7));
            entries.Add(new EntryChart(2, 10));
            entries.Add(new EntryChart(3, 3));
            entries.Add(new EntryChart(4, 1));
            entries.Add(new EntryChart(5, 7));
            entries.Add(new EntryChart(6, 2));
            var dataSet = new BarDataSet(entries, "Line Chart")
            {
                DataColor = Color.Red,
                DrawValue = false,
            };

            var entries2 = new List <EntryChart>();

            entries2.Add(new EntryChart(0, 1));
            entries2.Add(new EntryChart(1, 4));
            entries2.Add(new EntryChart(2, 9));
            entries2.Add(new EntryChart(3, 6));
            entries2.Add(new EntryChart(4, 3));
            entries2.Add(new EntryChart(5, 1));
            entries2.Add(new EntryChart(6, 7));
            var dataSet2 = new BarDataSet(entries2, "Line Chart 2")
            {
                DataColor = Color.Blue,
            };

            var entries3 = new List <PieEntry>();

            entries3.Add(new PieEntry(10, "col1", Color.Accent));
            entries3.Add(new PieEntry(30, "col2", Color.AliceBlue));
            entries3.Add(new PieEntry(25, "col3", Color.AntiqueWhite));
            entries3.Add(new PieEntry(25, "col4", Color.Aqua));
            entries3.Add(new PieEntry(10, "col5", Color.Aquamarine));
            var dataSet3 = new PieDataSet(entries3, "Pie Chart 2");

            var data = new PieChartData(dataSet3, null)
            {
                ValueDisplaySize  = 13,
                ValueDisplayColor = Color.Blue,
                TextDisplaySize   = 10,
                TextDisplayColor  = Color.Green
            };

            pieChart.ChartData = data;
            //lineChart.ChartData = data;
            //lineChart.XAxisLabels = new List<string>
            //{
            //    "Col1","Col2","Col3","Col4","Col5","Col6","Col7",
            //};
            //lineChart2.ChartData = data;
        }
Пример #3
0
        public object GerarDataProvincias()
        {
            try
            {
                var data = new Charts.Data();

                var connString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;

                var qry = @"Select p.Nome as Provincia, COUNT(*)  as Total, SUM(Case When (Febre = 1 and Viagem = 1 and Contacto = 1) then 1 else 0 End) as AltoRisco from Resultado r inner join Municipio m on r.IdMunicipio = m.IdMunicipio inner join Provincia p on m.IdProvincia = p.IdProvincia Group by p.Nome, p.IdProvincia Order By p.IdProvincia";

                using (SqlConnection conn = new SqlConnection(connString))
                {
                    var cmd = new SqlCommand(qry, conn);

                    conn.Open();

                    var reader = cmd.ExecuteReader();

                    var ds = new BarDataSet
                    {
                        label                = "Reportes",
                        backgroundColor      = "#e1bcc3",
                        hoverBackgroundColor = "#b9e5e8"
                    };

                    var dsRisco = new BarDataSet
                    {
                        label                = "Reportes de Risco",
                        backgroundColor      = Color.Brown.Name,
                        hoverBackgroundColor = Color.Red.Name
                    };

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            data.labels.Add(reader["Provincia"].ToString());


                            ds.data.Add(Convert.ToInt32(reader["Total"]));
                            dsRisco.data.Add(Convert.ToInt32(reader["AltoRisco"]));
                        }
                    }

                    conn.Close();

                    data.datasets.Add(ds);
                    data.datasets.Add(dsRisco);
                }

                return(data);
            }
            catch (Exception e)
            {
                SystemLog.Erro(e);
                return(null);
            }
        }
        private List <BarDataSet> getDataSet()
        {
            List <BarDataSet> dataSets = null;

            List <BarEntry> valueSet1 = new List <BarEntry>();
            BarEntry        v1e1      = new BarEntry(110.000f, 0); // Jan

            valueSet1.Add(v1e1);
            BarEntry v1e2 = new BarEntry(40.000f, 1); // Feb

            valueSet1.Add(v1e2);
            BarEntry v1e3 = new BarEntry(60.000f, 2); // Mar

            valueSet1.Add(v1e3);
            BarEntry v1e4 = new BarEntry(30.000f, 3); // Apr

            valueSet1.Add(v1e4);
            BarEntry v1e5 = new BarEntry(90.000f, 4); // May

            valueSet1.Add(v1e5);
            BarEntry v1e6 = new BarEntry(100.000f, 5); // Jun

            valueSet1.Add(v1e6);

            List <BarEntry> valueSet2 = new List <BarEntry>();
            BarEntry        v2e1      = new BarEntry(150.000f, 0); // Jan

            valueSet2.Add(v2e1);
            BarEntry v2e2 = new BarEntry(90.000f, 1); // Feb

            valueSet2.Add(v2e2);
            BarEntry v2e3 = new BarEntry(120.000f, 2); // Mar

            valueSet2.Add(v2e3);
            BarEntry v2e4 = new BarEntry(60.000f, 3); // Apr

            valueSet2.Add(v2e4);
            BarEntry v2e5 = new BarEntry(20.000f, 4); // May

            valueSet2.Add(v2e5);
            BarEntry v2e6 = new BarEntry(80.000f, 5); // Jun

            valueSet2.Add(v2e6);

            BarDataSet barDataSet1 = new BarDataSet(valueSet1, "1");

            barDataSet1.Color = (Color.Rgb(0, 155, 0));
            BarDataSet barDataSet2 = new BarDataSet(valueSet2, "2");

            //barDataSet2.SetColor(ColorTemplate.ColorfulColors);

            dataSets = new List <BarDataSet>();
            dataSets.Add(barDataSet1);
            dataSets.Add(barDataSet2);
            return(dataSets);
        }
        private void Init()
        {
            finalBalance = SumIncomes - SumOutcomes;

            if (finalBalance > 0)
            {
                tvStatus.Text = GetString(Resource.String.we_still_have_money);
                tvFinalBalance.SetTextColor(Context.GetColorStateList(Resource.Color.text_color_blue));
                tvFinalBalance.Text = $"+{finalBalance.ToCurrency()}";
            }
            else
            {
                tvStatus.Text = GetString(Resource.String.We_are_broke_now);
                tvFinalBalance.SetTextColor(Context.GetColorStateList(Resource.Color.text_color_red));
                tvFinalBalance.Text = finalBalance.ToCurrency();
            }

            tvIncome.Text  = $"+{SumIncomes.ToCurrency()}";
            tvOutcome.Text = $"-{SumOutcomes.ToCurrency()}";

            barChart.Description.Enabled  = false;
            barChart.Legend.Enabled       = false;
            barChart.AxisRight.Enabled    = false;
            barChart.AxisLeft.Enabled     = false;
            barChart.AxisLeft.AxisMinimum = 0;
            barChart.XAxis.Position       = XAxis.XAxisPosition.Bottom;
            barChart.XAxis.SetDrawGridLines(false);
            barChart.XAxis.Granularity = 1;
            barChart.SetExtraOffsets(0, 0, 0, 10);
            barChart.SetScaleEnabled(false);

            var labels = new List <string>()
            {
                GetString(Resource.String.income),
                GetString(Resource.String.outcome)
            };

            var barGroup = new List <BarEntry>()
            {
                new BarEntry(0, SumIncomes / 1000f),
                new BarEntry(1, SumOutcomes / 1000f)
            };

            var barDataSet = new BarDataSet(barGroup, null);

            barDataSet.SetColors(new int[] { Resource.Color.income_color, Resource.Color.outcome_color }, Context);
            barDataSet.SetDrawValues(false);

            barChart.XAxis.ValueFormatter = new IndexAxisValueFormatter(labels);
            barChart.XAxis.TextColor      = ContextCompat.GetColor(Context, Resource.Color.text_color_blue);
            barChart.XAxis.TextSize       = Resources.GetDimension(Resource.Dimension.text_size_normal);
            barChart.Data = new BarData(barDataSet);;
            barChart.Invalidate();
        }
        private void SetData(int count, float range)
        {
            float start = 1f;

            IList <BarEntry> values = new List <BarEntry>();

            for (int i = (int)start; i < start + count; i++)
            {
                float val = random.Next((int)range + 1);

                if (random.Next(100) < 25)
                {
                    values.Add(new BarEntry(i, val));
                }
                else
                {
                    values.Add(new BarEntry(i, val));
                }
            }

            BarDataSet set1;

            BarData data = Chart.Data;

            if (data != null &&
                data.DataSetCount > 0)
            {
                set1         = (BarDataSet)data[0];
                set1.Entries = values;
                data.NotifyDataChanged();
                Chart.NotifyDataSetChanged();
            }
            else
            {
                set1 = new BarDataSet(values, "The year 2017")
                {
                    IsDrawIconsEnabled = false,
                    Colors             = ColorTemplate.MaterialColors
                };

                IList <IBarDataSet> dataSets = new List <IBarDataSet>
                {
                    set1
                };

                data = new BarData(dataSets);
                data.SetValueTextSize(10f);
                data.SetValueTypeface(FontManager.Default);
                data.BarWidth = 0.9f;

                Chart.Data = data;
            }
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            var entries  = new List <EntryChart>();
            var entries2 = new List <EntryChart>();
            var labels   = new List <string>();

            Random random = new Random();

            for (int i = 0; i < 8; i++)
            {
                entries.Add(new EntryChart(i, random.Next(20)));
                entries2.Add(new EntryChart(i, random.Next(20)));
                labels.Add("Entry" + i);
            }

            var dataSet4 = new BarDataSet(entries, "Bar DataSet 1")
            {
                Colors = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
            };
            var dataSet5 = new BarDataSet(entries2, "Bar DataSet 2")
            {
                Colors = new List <Color> {
                    Color.Green
                },
            };

            var data4 = new BarChartData(new List <IBarDataSet>()
            {
                dataSet4
            });

            chart.ChartData             = data4;
            chart.DescriptionChart.Text = "Test label chart description";

            chart.AxisLeft.DrawGridLines = false;
            chart.AxisLeft.DrawAxisLine  = true;
            chart.AxisLeft.Enabled       = true;

            chart.AxisRight.DrawAxisLine  = false;
            chart.AxisRight.DrawGridLines = false;
            chart.AxisRight.Enabled       = false;

            chart.XAxis.XAXISPosition      = XAXISPosition.BOTTOM;
            chart.XAxis.DrawGridLines      = false;
            chart.XAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);

            chart2.ChartData = data4;
        }
Пример #8
0
        private void SetChartData()
        {
            if (!ViewModel.StatisticItems.Any())
            {
                return;
            }

            var chart = FindViewById <BarChart>(Resource.Id.chart);

            var dataSetdExpenses = new BarDataSet(new List <BarEntry> {
                new BarEntry(0, (float)ViewModel.StatisticItems[0].Value)
            }, ViewModel.StatisticItems[0].Label);

            dataSetdExpenses.SetColors(Resources.GetColor(Resource.Color.color_income, Theme));

            var dataSetIncome = new BarDataSet(new List <BarEntry> {
                new BarEntry(1, (float)ViewModel.StatisticItems[1].Value)
            }, ViewModel.StatisticItems[1].Label);

            dataSetIncome.SetColors(Resources.GetColor(Resource.Color.color_expense, Theme));

            var dataSetRevenue = new BarDataSet(new List <BarEntry> {
                new BarEntry(2, (float)ViewModel.StatisticItems[2].Value)
            }, ViewModel.StatisticItems[2].Label);

            dataSetRevenue.SetColors(Resources.GetColor(Resource.Color.color_revenue, Theme));

            var barData = new BarData(dataSetdExpenses, dataSetIncome, dataSetRevenue)
            {
                BarWidth = 0.9f
            };

            chart.Data = barData;
            chart.Description.Enabled = false;
            chart.SetPinchZoom(false);
            chart.SetFitBars(true);

            var legend = chart.Legend;

            legend.TextSize    = 12f;
            legend.Orientation = Legend.LegendOrientation.Horizontal;
            legend.SetDrawInside(true);
            legend.VerticalAlignment   = Legend.LegendVerticalAlignment.Bottom;
            legend.HorizontalAlignment = Legend.LegendHorizontalAlignment.Left;
            legend.XEntrySpace         = 7f;
            legend.YEntrySpace         = 0;
            legend.YOffset             = 0f;

            chart.Invalidate();
        }
Пример #9
0
        private View CreateUserScoresView(IEnumerable <AniListScoreDistribution> scores)
        {
            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 = "Scores";

            var chartHeight = Resources.GetDimensionPixelSize(Resource.Dimension.Details_ChartHeight);
            var barColor    = ContextCompat.GetColor(this, Resource.Color.MediaUserData_ScoreChartBar);
            var textColor   = GetThemedColor(Resource.Attribute.Background_Text);

            var scoresChart = new BarChart(this)
            {
                LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, chartHeight)
            };
            var bars = scores.OrderBy(x => x.Score).Select(x => new BarEntry(x.Score, x.Amount))
                       .ToList();
            var dataSet = new BarDataSet(bars, "Scores");

            dataSet.SetColor(barColor, 255);

            var data = new BarData(dataSet)
            {
                BarWidth = 9
            };

            scoresChart.Data = data;
            scoresChart.SetFitBars(true);
            scoresChart.SetDrawGridBackground(false);
            scoresChart.Description.Enabled = false;
            scoresChart.Legend.Enabled      = false;
            scoresChart.AxisLeft.Enabled    = false;
            scoresChart.AxisRight.Enabled   = false;
            scoresChart.XAxis.SetDrawGridLines(false);
            scoresChart.XAxis.RemoveAllLimitLines();
            scoresChart.SetScaleEnabled(false);
            scoresChart.SetTouchEnabled(false);
            scoresChart.XAxis.SetLabelCount(10, false);
            scoresChart.XAxis.Granularity = 10;
            scoresChart.XAxis.Position    = XAxis.XAxisPosition.Bottom;
            scoresChart.XAxis.SetDrawAxisLine(false);
            scoresChart.XAxis.ValueFormatter = new ChartUtils.AxisValueCeilingFormatter(10);

            scoresChart.XAxis.TextColor = dataSet.ValueTextColor = textColor;

            detailContainer.AddView(scoresChart);
            return(detailView);
        }
        /*
         * EXPORT FOR BAR
         */
        public BarData ExportBarData(Widget.Charts.Models.BarChart.BarChartData bubbleChartData)
        {
            var dataSetItems = new List <BarDataSet>();

            foreach (var item in bubbleChartData.DataSets)
            {
                var entryOriginal = item.IF_GetValues().Select(obj => new BarEntry(obj.GetXPosition(), obj.GetYPosition()));
                var dataSet       = new BarDataSet(entryOriginal.ToArray(), item.IF_GetLabel());
                OnIntializeDataSetBar(item, dataSet);
                dataSetItems.Add(dataSet);
            }

            var data = new BarData(dataSetItems.ToArray());

            return(data);
        }
Пример #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            BarChart barChart = new BarChart(this);

            barChart.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            var flag = new string[] { "First Bar,Second Bar", "93,93.15" };

            //--this is response
            string[] strDate   = flag[0].ToString().Split(',');
            string[] strValues = flag[1].ToString().Split(',');

            List <BarEntry> entries = new List <BarEntry>();

            for (int i = 0; i < strValues.Length; i++)
            {
                entries.Add(new BarEntry(float.Parse(strValues[i]), i));
            }

            BarDataSet dataset = new BarDataSet(entries, "");

            dataset.ValueTextSize = 15.0f;

            List <string> labels = new List <string>();

            for (int i = 0; i < strDate.Length; i++)
            {
                labels.Add(strDate[i].ToString());
            }

            BarData data = new BarData(labels, dataset);

            barChart.Data = data;
            barChart.SetDescription("");

            barChart.NotifyDataSetChanged();
            barChart.Invalidate();
            var root = FindViewById <LinearLayout>(Resource.Id.root);

            root.AddView(barChart);
        }
Пример #12
0
        public override ChartDataBase GetChartData()
        {
            var data = GetData();

            var chartData = new ChartDataBase {
                ChartType = ChartType.Bar
            };

            var labels       = new List <string[]>();
            var chartDataSet = new List <BarDataSet>();

            var residents = new BarDataSet {
                Label = "Национальные заявители", Data = new double[data.Rows.Count], BackgroundColor = "#2c8ebb", BorderColor = "#2c8ebb"
            };
            var nonResidents = new BarDataSet {
                Label = "Иностранне заявители", Data = new double[data.Rows.Count], BackgroundColor = "#b56b2c", BorderColor = "#b56b2c"
            };

            var dataNumber = 0;

            for (int i = 0; i < data.Rows.Count - 1; i++)
            {
                var row = data.Rows[i];
                if (row.IsHeader == false)
                {
                    residents.Data[dataNumber]    = row.Cells[2].Value;
                    nonResidents.Data[dataNumber] = row.Cells[3].Value;

                    dataNumber++;

                    string label = row.Cells[1].Value.ToString();

                    labels.Add(label.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
            chartDataSet.Add(residents);
            chartDataSet.Add(nonResidents);

            chartData.Labels   = labels;
            chartData.Datasets = chartDataSet.ToArray();

            return(chartData);
        }
Пример #13
0
        private BarData GetUpcomingBarData(List <TrackedPatient> trackedPatients)
        {
            BarData barData = new BarData();

            BarDataSet babiesDue = new BarDataSet()
            {
                Label = "Babies Due"
            };

            barData.Datasets.Add(babiesDue);

            // *** Set the starting working date ***
            DateTime workingDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            // *** Do six months work ***
            for (int i = 0; i < 6; i++)
            {
                // *** Get the name of the month ***
                string monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(workingDate.Month);

                // *** Add the name to the barData ***
                barData.Labels.Add(monthName);

                // *** Initialize count ***
                int count = 0;

                // *** If we have some tracked patients, count the ones that match month/year ***
                if (trackedPatients != null)
                {
                    count = trackedPatients.Count(t => t.EDD.Year == workingDate.Year && t.EDD.Month == workingDate.Month);
                }

                // *** Add the count ***
                babiesDue.Data.Add(count);

                // *** Go to the next month ***
                workingDate = workingDate.AddMonths(1);
            }

            return(barData);
        }
Пример #14
0
        private void InitializeChart()
        {
            if (supportChart != null && supportChart.ChartData != null && chartOriginal != null)
            {
                SupportChart.OnInitializeChart(supportChart, chartOriginal);
                var data         = supportChart.ChartData;
                var dataSetItems = new List <BarDataSet>();

                foreach (var itemChild in data.IF_GetDataSet())
                {
                    var        entryOriginal = itemChild.IF_GetEntry().Select(item => new MikePhil.Charting.Data.BarEntry(item.GetXPosition(), item.GetYPosition()));
                    BarDataSet lineDataSet   = new BarDataSet(entryOriginal.ToArray(), itemChild.IF_GetTitle());
                    lineDataSet.Color = itemChild.IF_GetDataColor().ToAndroid();
                    lineDataSet.SetDrawValues(itemChild.IF_GetDrawValue());
                    dataSetItems.Add(lineDataSet);
                }

                BarData lineData = new BarData(dataSetItems.ToArray());
                chartOriginal.Data = lineData;
            }
        }
        private void setData(int count, float range)
        {
            float start = 1f;

            List <BarEntry> yVals1 = new List <BarEntry>();

            for (int i = (int)start; i < start + count + 1; i++)
            {
                float mult = (range + 1);
                //random data
                float val = (float)(Java.Lang.Math.Random() * mult);
                yVals1.Add(new BarEntry(i, val));
            }

            BarDataSet set1;

            if (mChart.Data != null && mChart.BarData.DataSetCount > 0)
            {
                set1        = (BarDataSet)mChart.BarData.GetDataSetByIndex(0);
                set1.Values = yVals1;
                mChart.BarData.NotifyDataChanged();
                mChart.NotifyDataSetChanged();

                mChart.BarData.AddDataSet(set1);
            }
            else
            {
                set1 = new BarDataSet(yVals1, "2017");

                List <MikePhil.Charting.Interfaces.Datasets.IBarDataSet> dataSets = new List <MikePhil.Charting.Interfaces.Datasets.IBarDataSet>();

                dataSets.Add(set1);
                BarData data = new BarData(dataSets);

                dataSets.Add(set1);
                mChart.Data = data;
            }
        }
Пример #16
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();
        }
        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);
        }
Пример #18
0
        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);
        }
Пример #19
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);
        }
        private void UpdatePaidView(string year)
        {
            var sumMoneyPaidByYear = moneyStates.Sum(x => x.IsPaid &&
                                                     (x.MoneyModel.Time.Year.ToString().Equals(year) ||
                                                      year.Equals(Total))
                ? x.MoneyModel.Amount
                : 0);

            tvPaid.Text = sumMoneyPaidByYear.ToCurrency();

            if (sumMoneyPaidByYear == 0)
            {
                barChart.Visibility = ViewStates.Invisible;
            }
            else
            {
                barChart.Visibility = ViewStates.Visible;

                var labels   = new List <string>();
                var barGroup = new List <BarEntry>();

                if (year.Equals(Total))
                {
                    var moneyYears = moneyStates
                                     .GroupBy(x => x.MoneyModel.Time.Year)
                                     .OrderBy(x => x.Key)
                                     .Select(x => new
                    {
                        lable = x.Key.ToString(),
                        value = x.Sum(y => y.IsPaid ? y.MoneyModel.Amount : 0)
                    });

                    labels = moneyYears.Select(x => x.lable).ToList();

                    barGroup = moneyYears
                               .Select((x, index) => new BarEntry(index, x.value / 1000f))
                               .ToList();
                }
                else
                {
                    var moneyMonths = moneyStates.Where(x => x.MoneyModel.Time.Year.ToString().Equals(year))
                                      .GroupBy(x => x.MoneyModel.Time.Month)
                                      .OrderBy(x => x.Key)
                                      .Select(x => new
                    {
                        lable = dateTimeFormatInfo.GetAbbreviatedMonthName(x.Key),
                        value = x.Sum(y => y.IsPaid ? y.MoneyModel.Amount : 0)
                    }).ToList();

                    labels = moneyMonths.Select(x => x.lable).ToList();

                    barGroup = moneyMonths
                               .Select((x, index) => new BarEntry(index, x.value / 1000f))
                               .ToList();
                }

                var barDataSet = new BarDataSet(barGroup, null);
                barDataSet.SetColors(ColorTemplate.ColorfulColors.ToArray());
                barDataSet.ValueFormatter = new ValueFormatter();

                barChart.XAxis.ValueFormatter = new IndexAxisValueFormatter(labels);
                barChart.Data = new BarData(barDataSet);;
                barChart.Invalidate();
            }
        }
        private void OnIntializeDataSetBar(UltimateXF.Widget.Charts.Models.BarChart.IBarDataSet source, BarDataSet original)
        {
            /*
             * Properties could not set
             * IF_GetStackSize
             * IF_GetEntryCountStacks
             */
            OnSettingsBarLineScatterCandleBubbleDataSet(source, original);

            if (source.IF_GetBarShadowColor().HasValue)
            {
                original.BarShadowColor = source.IF_GetBarShadowColor().Value.ToAndroid();
            }

            if (source.IF_GetBarBorderWidth().HasValue)
            {
                original.BarBorderWidth = source.IF_GetBarBorderWidth().Value;
            }

            if (source.IF_GetBarBorderColor().HasValue)
            {
                original.BarBorderColor = source.IF_GetBarBorderColor().Value.ToAndroid();
            }

            if (source.IF_GetHighLightAlpha().HasValue)
            {
                original.HighLightAlpha = source.IF_GetHighLightAlpha().Value;
            }

            if (source.IF_GetStackLabels() != null && source.IF_GetStackLabels().Count > 0)
            {
                original.SetStackLabels(source.IF_GetStackLabels().ToArray());
            }
        }
Пример #22
0
        public override ChartDataBase GetChartData()
        {
            var data = GetData();

            var chartData = new ChartDataBase {
                ChartType = ChartType.Bar
            };

            var labels       = new List <string[]>();
            var chartDataSet = new List <BarDataSet>();

            var residents = new BarDataSet {
                Label = "Национальные заявители", Data = new double[data.Rows.Count], BackgroundColor = "#2c8ebb", BorderColor = "#2c8ebb"
            };
            var nonResidents = new BarDataSet {
                Label = "Иностранне заявители", Data = new double[data.Rows.Count], BackgroundColor = "#b56b2c", BorderColor = "#b56b2c"
            };
            var sum = new BarDataSet {
                Label = "Всего", Data = new double[data.Rows.Count], BackgroundColor = "#cccccc", BorderColor = "#cccccc"
            };

            var dataNumber = 0;

            for (int i = 0; i < data.Rows.Count; i++)
            {
                //Пропускаем общее количество
                if (i == 10)
                {
                    continue;
                }

                var row = data.Rows[i];

                //workaround для общеизвестных, отображал некорректно
                if (i == 11)
                {
                    residents.Data[dataNumber]    = row.Cells[3].Value ?? 0;
                    nonResidents.Data[dataNumber] = row.Cells[4].Value ?? 0;
                    sum.Data[dataNumber]          = residents.Data[dataNumber] + nonResidents.Data[dataNumber];

                    dataNumber++;

                    string label = row.Cells[1].Value.ToString();

                    labels.Add(label.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                    continue;
                }
                //остальные типы
                if (row.IsHeader == false)
                {
                    if (dataNumber < 5)
                    {
                        residents.Data[dataNumber]    = row.Cells[2].Value ?? 0;
                        nonResidents.Data[dataNumber] = row.Cells[3].Value ?? 0;
                    }
                    else
                    {
                        try
                        {
                            residents.Data[dataNumber]    = row.Cells[4].Value ?? 0;
                            nonResidents.Data[dataNumber] = row.Cells[5].Value ?? 0;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    sum.Data[dataNumber] = residents.Data[dataNumber] + nonResidents.Data[dataNumber];

                    dataNumber++;

                    string label = row.Cells[1].Value.ToString();

                    labels.Add(label.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
            chartDataSet.Add(residents);
            chartDataSet.Add(nonResidents);
            chartDataSet.Add(sum);

            chartData.Labels   = labels;
            chartData.Datasets = chartDataSet.ToArray();

            return(chartData);
        }
Пример #23
0
        private void ChartsPage_Load(object sender, EventArgs e)
        {
            LineDataSet      lineDataSet1      = new LineDataSet();
            LineDataSet      lineDataSet2      = new LineDataSet();
            BarDataSet       barDataSet1       = new BarDataSet();
            RadarDataSet     radarDataSet1     = new RadarDataSet();
            PolarAreaDataSet polarAreaDataSet1 = new PolarAreaDataSet();
            DoughnutDataSet  doughnutDataSet1  = new DoughnutDataSet();
            PieDataSet       pieDataSet1       = new PieDataSet();

            lineDataSet1.BackgroundColor      = Color.FromArgb(70, 255, 189, 0);
            lineDataSet1.BorderColor          = Color.FromArgb(255, 46, 0);
            lineDataSet1.Data                 = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            lineDataSet1.PointBorderColor     = new[] { Color.FromArgb(0, 255, 0) };
            lineDataSet1.PointBackgroundColor = new[] { Color.FromArgb(0, 255, 0) };
            lineDataSet1.Fill                 = true;
            lineDataSet1.Label                = "Data Set";
            lineDataSet2.BorderColor          = Color.FromArgb(0, 86, 255);
            lineDataSet2.Data                 = new object[] { 1, 2, 4, 8, 16, 32, 64, 32, 16, 8, 4, 2 };
            lineDataSet2.Label                = "Data Set 2";
            lineDataSet2.PointStyle           = new[] { PointStyle.RectRounded };
            lineDataSet2.SteppedLine          = SteppedLine.After;
            chartJS1.DataSets.Add(lineDataSet1);
            chartJS1.DataSets.Add(lineDataSet2);

            barDataSet1.BackgroundColor = new[]
            {
                Color.FromArgb(49, 255, 0, 0),
                Color.FromArgb(58, 102, 255, 0),
                Color.FromArgb(52, 0, 183, 255),
                Color.FromArgb(53, 247, 0, 255),
                Color.FromArgb(52, 191, 123, 63),
                Color.FromArgb(53, 191, 63, 86),
                Color.FromArgb(104, 255, 0, 118),
                Color.FromArgb(237, 130, 237),
                Color.FromArgb(88, 64, 224, 208),
                Color.FromArgb(84, 255, 98, 70),
                Color.FromArgb(60, 41, 69, 70),
                Color.FromArgb(98, 0, 0, 128)
            };
            barDataSet1.BorderColor          = null;
            barDataSet1.Data                 = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            barDataSet1.HoverBackgroundColor = null;
            barDataSet1.Label                = "Data Set";
            chartJS2.DataSets.Add(barDataSet1);

            radarDataSet1.BackgroundColor = Color.FromArgb(72, 79, 191, 63);
            radarDataSet1.Data            = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            radarDataSet1.Label           = "Data Set";
            chartJS4.DataSets.Add(radarDataSet1);

            polarAreaDataSet1.BackgroundColor = new[]
            {
                Color.FromArgb(49, 255, 0, 0),
                Color.FromArgb(58, 102, 255, 0),
                Color.FromArgb(52, 0, 183, 255),
                Color.FromArgb(53, 247, 0, 255),
                Color.FromArgb(52, 191, 123, 63),
                Color.FromArgb(53, 191, 63, 86),
                Color.FromArgb(104, 255, 0, 118),
                Color.FromArgb(237, 130, 237),
                Color.FromArgb(88, 64, 224, 208),
                Color.FromArgb(84, 255, 98, 70),
                Color.FromArgb(60, 41, 69, 70),
                Color.FromArgb(98, 0, 0, 128)
            };
            polarAreaDataSet1.BorderColor          = null;
            polarAreaDataSet1.Data                 = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 };
            polarAreaDataSet1.HoverBackgroundColor = null;
            polarAreaDataSet1.Label                = "Data Set";
            chartJS6.DataSets.Add(polarAreaDataSet1);

            doughnutDataSet1.BackgroundColor = new[]
            {
                Color.FromArgb(49, 255, 0, 0),
                Color.FromArgb(58, 102, 255, 0),
                Color.FromArgb(52, 0, 183, 255),
                Color.FromArgb(53, 247, 0, 255),
                Color.FromArgb(52, 191, 123, 63),
                Color.FromArgb(53, 191, 63, 86),
                Color.FromArgb(104, 255, 0, 118),
                Color.FromArgb(237, 130, 237),
                Color.FromArgb(88, 64, 224, 208),
                Color.FromArgb(84, 255, 98, 70),
                Color.FromArgb(60, 41, 69, 70),
                Color.FromArgb(98, 0, 0, 128)
            };
            doughnutDataSet1.BorderColor          = null;
            doughnutDataSet1.Data                 = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 };
            doughnutDataSet1.HoverBackgroundColor = null;
            doughnutDataSet1.Label                = "Data Set";
            chartJS5.DataSets.Add(doughnutDataSet1);

            pieDataSet1.BackgroundColor = new[]
            {
                Color.FromArgb(49, 255, 0, 0),
                Color.FromArgb(58, 102, 255, 0),
                Color.FromArgb(52, 0, 183, 255),
                Color.FromArgb(53, 247, 0, 255),
                Color.FromArgb(52, 191, 123, 63),
                Color.FromArgb(53, 191, 63, 86),
                Color.FromArgb(104, 255, 0, 118),
                Color.FromArgb(237, 130, 237),
                Color.FromArgb(88, 64, 224, 208),
                Color.FromArgb(84, 255, 98, 70),
                Color.FromArgb(60, 41, 69, 70),
                Color.FromArgb(98, 0, 0, 128)
            };
            pieDataSet1.BorderColor          = null;
            pieDataSet1.Data                 = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            pieDataSet1.HoverBackgroundColor = null;
            pieDataSet1.Label                = "Data Set";
            chartJS3.DataSets.Add(pieDataSet1);

            Randomize();
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();
            var entrieLine = new List <EntryChart>();
            var entries    = new List <BubbleEntry>();
            var entries2   = new List <BubbleEntry>();
            var labels     = new List <string>();

            Random random = new Random();


            for (int i = 0; i < 8; i++)
            {
                entrieLine.Add(new EntryChart(i, random.Next(20)));
                entries.Add(new BubbleEntry(i, random.Next(8), random.Next(20)));
                entries2.Add(new BubbleEntry(i, random.Next(8), random.Next(20)));
                labels.Add("Entry" + i);
            }

            var entriesCandle = new List <CandleStickEntry>();

            entriesCandle.Add(new CandleStickEntry(0, 4.62f, 2.02f, 2.70f, 4.13f));
            entriesCandle.Add(new CandleStickEntry(1, 5.50f, 2.70f, 3.35f, 4.96f));
            entriesCandle.Add(new CandleStickEntry(2, 5.25f, 3.02f, 3.50f, 4.50f));
            entriesCandle.Add(new CandleStickEntry(3, 6f, 3.25f, 4.40f, 5.0f));
            entriesCandle.Add(new CandleStickEntry(4, 5.57f, 2f, 2.80f, 4.5f));

            var dataSetBubble = new BubbleDataSet(entries, "Bubble DataSet 1")
            {
                Colors = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
            };
            var dataBubble = new BubbleChartData(new List <IBubbleDataSet>()
            {
                dataSetBubble
            });


            var dataSetCandle = new CandleStickDataSet(entriesCandle, "Candle Stick DataSet 1")
            {
                DecreasingColor = Color.Red,
                IncreasingColor = Color.Green
            };
            var dataCandle = new CandleStickChartData(new List <ICandleStickDataSet>()
            {
                dataSetCandle
            });


            var dataSetLine = new LineDataSetXF(entrieLine, "Line DataSet 1")
            {
                CircleRadius     = 10,
                CircleHoleRadius = 4f,
                CircleColors     = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
                CircleHoleColor = Color.Green,
                Mode            = LineDataSetMode.CUBIC_BEZIER
            };
            var dataLine = new LineChartData(new List <ILineDataSetXF>()
            {
                dataSetLine
            });


            var dataSetbar = new BarDataSet(entrieLine, "Bar DataSet 1")
            {
                Colors = new List <Color>()
                {
                    Color.Accent, Color.Azure, Color.Bisque, Color.Gray, Color.Green, Color.Chocolate, Color.Black
                },
            };
            var dataBar = new BarChartData(new List <IBarDataSet>()
            {
                dataSetbar
            });

            var combinData = new CombinedChartData(null);

            combinData.BubbleChartData      = dataBubble;
            combinData.CandleStickChartData = dataCandle;
            combinData.LineChartData        = dataLine;
            combinData.BarChartData         = dataBar;
            chart.ChartData = combinData;
            chart.XAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);
        }
Пример #25
0
        public void LoadBarChart()
        {
            try
            {
                var entries  = new List <EntryChart>();
                var entries2 = new List <EntryChart>();
                var labels   = new List <string>();

                Random random = new Random();
                for (int i = 0; i < 36; i++)
                {
                    entries.Add(new EntryChart(i, random.Next(20)));
                    entries2.Add(new EntryChart(i, random.Next(20)));
                    labels.Add(states[i]);
                }

                var dataSet4 = new BarDataSet(entries, "Product Summary")
                {
                    Colors = new List <Color>()
                    {
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
                        Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
                        Color.FromHex("#e55137"), Color.FromHex("#ea9940"),
                        Color.Black
                    },
                };

                var data4 = new BarChartData(new List <IBarDataSet>()
                {
                    dataSet4
                });

                chart.ChartData             = data4;
                chart.DescriptionChart.Text = "Product chart description";

                chart.AxisLeft.DrawGridLines = false;
                chart.AxisLeft.DrawAxisLine  = true;
                chart.AxisLeft.Enabled       = true;

                chart.AxisRight.DrawAxisLine  = false;
                chart.AxisRight.DrawGridLines = false;
                chart.AxisRight.Enabled       = false;

                chart.XAxis.XAXISPosition      = XAXISPosition.BOTTOM;
                chart.XAxis.DrawGridLines      = false;
                chart.XAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);
            }
            catch (Exception ex)
            {
            }
        }
Пример #26
0
        private BarData GetOutcomesBarData()
        {
            BarData barData = new BarData();

            BarDataSet liveDataSet = new BarDataSet()
            {
                Label = "Live Deliveries"
            };
            BarDataSet otherDataSet = new BarDataSet()
            {
                Label = "Other Outcomes"
            };

            barData.Datasets.Add(liveDataSet);
            barData.Datasets.Add(otherDataSet);

            // *** Create From Date ***
            DateTime fromDate = DateTime.Now.AddMonths(-6);

            fromDate = new DateTime(fromDate.Year, fromDate.Month, 1);
            fromDate = fromDate.AddDays(-1);

            // *** Create To Date ***
            DateTime toDate = DateTime.Now.AddDays(1);

            // *** Get data from VistA ***
            PregnancyOutcomeResult outcomeResult = this.DashboardRepository.Pregnancy.GetPregnancyOutcomes(fromDate, toDate, 1, 100);

            // *** Set the starting working date ***
            DateTime workingDate = fromDate.AddDays(1);

            // *** Do six months work ***
            for (int i = 0; i < 7; i++)
            {
                // *** Get the name of the month ***
                string monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(workingDate.Month);

                // *** Add the name to the barData ***
                barData.Labels.Add(monthName);

                // *** Initialize counts ***
                int live  = 0;
                int other = 0;

                // *** If we have some tracked patients, count the ones that match month/year ***
                if (outcomeResult.Success)
                {
                    if (outcomeResult.PregnancyOutcomes != null)
                    {
                        // *** Get count for live deliveries ***
                        live = outcomeResult.PregnancyOutcomes.Count(p => p.EndDate.Month == workingDate.Month &&
                                                                     ((p.OutcomeType == PregnancyOutcomeType.FullTermDelivery) ||
                                                                      (p.OutcomeType == PregnancyOutcomeType.PretermDelivery)));

                        // *** Get count for all other outcomes ***
                        other = outcomeResult.PregnancyOutcomes.Count(p => p.EndDate.Month == workingDate.Month &&
                                                                      (p.OutcomeType != PregnancyOutcomeType.FullTermDelivery) &&
                                                                      (p.OutcomeType != PregnancyOutcomeType.PretermDelivery));
                    }
                }

                // *** Add the counts ***
                liveDataSet.Data.Add(live);
                otherDataSet.Data.Add(other);

                // *** Go to the next month ***
                workingDate = workingDate.AddMonths(1);
            }

            return(barData);
        }
Пример #27
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();
        }