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 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; } }