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(); }
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); }
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); }
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(); } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); CalligraphyConfig.InitDefault(new CalligraphyConfig.Builder() .SetDefaultFontPath("Estedad.ttf").Build()); SetContentView(Resource.Layout.layoutMyEventManangment); var font = Typeface.CreateFromAsset(Assets, "Estedad.ttf"); FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewstatuse).Typeface = font; myeventmanagmnettxtviewcaption = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewcaption); myeventmanagmnettxtviewcaption.Typeface = font; myeventmanagmnetButtonBack = FindViewById <Button>(Resource.Id.myeventmanagmnetButtonBack); myeventmanagmnetButtonBack.Typeface = font; myeventmanagmnetButtonBack.Click += delegate { Finish(); }; ImageView myeventmanagmnetimgviewback; myeventmanagmnetimgviewback = FindViewById <ImageView>(Resource.Id.myeventmanagmnetimgviewback); myeventmanagmnetimgviewback.Click += delegate { Finish(); }; myeventmanagmnetbuttondelete = FindViewById <Button>(Resource.Id.myeventmanagmnetbuttondelete); myeventmanagmnetbuttondelete.Click += delegate { string ValueToast = "مطمئنی میخوای حذفش کنی؟"; Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("حذف رویداد"); alert.SetMessage(ValueToast); alert.SetPositiveButton("بله", (senderAlert, args) => { //باز شدن فرگمنت ذیگر StatuseDeleteFragment dlg = new StatuseDeleteFragment(this); dlg.Show(this.FragmentManager, "Fragmentmanangerstatusedelete"); }); alert.SetNegativeButton("خیر", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }; myeventmanagmnetbuttonedit = FindViewById <Button>(Resource.Id.myeventmanagmnetbuttonedit); myeventmanagmnetbuttonedit.Typeface = font; myeventmanagmnetbuttonedit.Click += delegate { Intent oi = new Intent(this, typeof(EditMyEventActivity)); StartActivity(oi); }; myeventmanagmnetbuttondown = FindViewById <Button>(Resource.Id.myeventmanagmnetbuttondown); myeventmanagmnetbuttondown.Typeface = font; myeventmanagmnetbuttondown.Click += delegate { //ارتقا} Intent ine = new Intent(this, typeof(MyEventUpgradeActivity)); StartActivity(ine); }; myeventmanagmnetvpagerslider = FindViewById <ViewPager>(Resource.Id.myeventmanagmnetvpagerslider); // myeventmanagmnetvpagerslider.Adapter = new ImageAdapter(this); var myeventmanagmnettablayoutdots = FindViewById <TabLayout>(Resource.Id.myeventmanagmnettablayoutdots); myeventmanagmnettablayoutdots.SetupWithViewPager(myeventmanagmnetvpagerslider, true); myeventmanagmnettxtviewmajor = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewmajor); myeventmanagmnettxtviewmajor.Typeface = font; myeventmanagmnettxtviewsport = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewsport); myeventmanagmnettxtviewsport.Typeface = font; string txtviewsport = myeventmanagmnettxtviewsport.Text; string numberdigitone = txtviewsport.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewsport.Text = numberdigitone; myeventmanagmnettxtviewcaptiongroup = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewcaptiongroup); myeventmanagmnettxtviewcaptiongroup.Typeface = font; myeventmanagmnettxtviewplace = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewplace); myeventmanagmnettxtviewplace.Typeface = font; string txtviewplace = myeventmanagmnettxtviewplace.Text; string numberdigittwo = txtviewplace.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewplace.Text = numberdigittwo; myeventmanagmnettxtviewcaptionplace = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewcaptionplace); myeventmanagmnettxtviewcaptionplace.Typeface = font; myeventmanagmnettxtviewdate = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewdate); myeventmanagmnettxtviewdate.Typeface = font; string txtviewdate = myeventmanagmnettxtviewdate.Text; string numberdigitthree = txtviewdate.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewdate.Text = numberdigitthree; myeventmanagmnettxtviewtel = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewtel); myeventmanagmnettxtviewtel.Typeface = font; string txtviewtel = myeventmanagmnettxtviewtel.Text; string numberdigittel = txtviewtel.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewtel.Text = numberdigittel; myeventmanagmnettxtviewcaptiontime = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewcaptiontime); myeventmanagmnettxtviewcaptiontime.Typeface = font; myeventmanagmnettxtviewprice = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewprice); myeventmanagmnettxtviewprice.Typeface = font; string txtviewprice = myeventmanagmnettxtviewprice.Text; string numberdigittfor = txtviewprice.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewprice.Text = numberdigittfor; myeventmanagmnettxtviewaddress = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewaddress); myeventmanagmnettxtviewaddress.Typeface = font; string tviewaddress = myeventmanagmnettxtviewaddress.Text; string numberdigittfive = tviewaddress.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewaddress.Text = numberdigittfive; myeventmanagmnettxtviewcaptioncost = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewcaptioncost); myeventmanagmnettxtviewcaptioncost.Typeface = font; myeventmanagmnettxtviewdescription = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewdescription); myeventmanagmnettxtviewdescription.Typeface = font; string txtviewdescription = myeventmanagmnettxtviewdescription.Text; string numberdigittsix = txtviewdescription.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewdescription.Text = numberdigittsix; myeventmanagmnettxtviewurl = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewurl); myeventmanagmnettxtviewurl.Typeface = font; string ttxtviewurl = myeventmanagmnettxtviewurl.Text; string numberdigittseven = ttxtviewurl.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩"); myeventmanagmnettxtviewurl.Text = numberdigittseven; myeventmanagmnettxtviewcaptiondescription = FindViewById <TextView>(Resource.Id.myeventmanagmnettxtviewcaptiondescription); myeventmanagmnettxtviewcaptiondescription.Typeface = font; //TextView myeventmanagmnettxtviewcaptioncontact = FindViewById<TextView>(Resource.Id.myeventmanagmnettxtviewcaptioncontact); //myeventmanagmnettxtviewcaptioncontact.Typeface = font; myeventmanagmnetchart = FindViewById <BarChart>(Resource.Id.myeventmanagmnetchart); BarData data = new BarData(getXAxisValues(), getDataSet()); myeventmanagmnetchart.Data = (data); myeventmanagmnetchart.SetDescription("EventooChart"); myeventmanagmnetchart.AnimateXY(2000, 2000); myeventmanagmnetchart.Invalidate(); }
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 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(); }
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(); }