use of com.github.mikephil.charting.data.PieData in project AdMoney by ErnestoGonAr.
the class Saldo method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_saldo, container, false);
// Texts
ingresosT = (TextView) rootView.findViewById(R.id.cantIngreso);
egresosT = (TextView) rootView.findViewById(R.id.cantGasto);
saldoT = (TextView) rootView.findViewById(R.id.saldo);
try {
Double monto = Double.parseDouble(ingresos);
Double monto2 = Double.parseDouble(egresos);
Double monto3 = Double.parseDouble(saldo);
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.getDefault());
ingresosT.setText(nf.format(monto));
egresosT.setText(nf.format(monto2));
saldoT.setText(nf.format(monto3));
} catch (NumberFormatException e) {
}
// Piechart de ingresos egresos
pieChart = (PieChart) rootView.findViewById(R.id.din);
ArrayList<PieEntry> yEntrys = new ArrayList<PieEntry>();
yEntrys.add(new PieEntry(Float.parseFloat(ingresos)));
yEntrys.add(new PieEntry(Float.parseFloat(egresos)));
PieDataSet pieDataSet = new PieDataSet(yEntrys, "");
pieDataSet.setSliceSpace(2);
pieDataSet.setColors(ColorTemplate.MATERIAL_COLORS[0], ColorTemplate.MATERIAL_COLORS[2]);
pieChart.getDescription().setText("");
pieChart.setUsePercentValues(true);
pieChart.setHoleRadius(0);
pieDataSet.setLabel("");
pieDataSet.setValueTextSize(15);
pieChart.getLegend().setFormSize(0);
PieData pieData = new PieData(pieDataSet);
pieChart.setData(pieData);
pieChart.setDrawEntryLabels(false);
pieChart.setTransparentCircleAlpha(0);
/*pieChart.setHoleRadius(50);
pieChart.setCenterText("%");
pieChart.setCenterTextSize(25);
*/
pieChart.invalidate();
pieChart.animateXY(2000, 2000);
pieChart.requestFocus();
return rootView;
}
use of com.github.mikephil.charting.data.PieData in project run-wallet-android by runplay.
the class NetworkNodeInfoFragment method setData.
private void setData(long tips, long transactionsToRequest) {
ArrayList<PieEntry> entries = new ArrayList<>();
entries.add(new PieEntry(tips, getString(R.string.tips) + " " + "(" + tips + ")"));
entries.add(new PieEntry(transactionsToRequest, getString(R.string.transactions_to_request) + " " + "(" + transactionsToRequest + ")"));
PieDataSet dataSet = new PieDataSet(entries, getString(R.string.transactions) + "\n(" + (tips + transactionsToRequest) + ")");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<>();
colors.add(B.getColor(getActivity(), AppTheme.getPrimaryDark()));
colors.add(B.getColor(getActivity(), R.color.colorLight));
colors.add(B.getColor(getActivity(), R.color.white));
// for (int c : ColorTemplate.PASTEL_COLORS)
// colors.add(c);
dataSet.setColors(colors);
dataSet.setValueLinePart1OffsetPercentage(80.f);
dataSet.setValueLinePart1Length(0.2f);
dataSet.setValueLinePart2Length(0.4f);
dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setValueTextColor(ContextCompat.getColor(getActivity(), AppTheme.getPrimary()));
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(12f);
data.setValueTextColor(ContextCompat.getColor(getActivity(), AppTheme.getPrimary()));
chart.setData(data);
// undo all highlights
chart.highlightValues(null);
chart.invalidate();
}
use of com.github.mikephil.charting.data.PieData in project AmazeFileManager by TeamAmaze.
the class LoadFolderSpaceDataTask method updateChart.
private void updateChart(String totalSpace, List<PieEntry> entries) {
boolean isDarkTheme = appTheme.getMaterialDialogTheme() == Theme.DARK;
PieDataSet set = new PieDataSet(entries, null);
set.setColors(COLORS);
set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
set.setSliceSpace(5f);
set.setAutomaticallyDisableSliceSpacing(true);
set.setValueLinePart2Length(1.05f);
set.setSelectionShift(0f);
PieData pieData = new PieData(set);
pieData.setValueFormatter(new GeneralDialogCreation.SizeFormatter(context));
pieData.setValueTextColor(isDarkTheme ? Color.WHITE : Color.BLACK);
chart.setCenterText(new SpannableString(context.getString(R.string.total) + "\n" + totalSpace));
chart.setData(pieData);
}
use of com.github.mikephil.charting.data.PieData in project HAR-Android by linw7.
the class HistoryActivity method get_pie_data.
private PieData get_pie_data() {
// xVals用来表示每个饼块上的内容
ArrayList<String> xValues = new ArrayList<String>();
// 饼块上显示成Quarterly1, Quarterly2, Quarterly3, Quarterly4
xValues.add("Jog");
xValues.add("Walk");
xValues.add("Sit");
xValues.add("Stand");
// yVals用来表示封装每个饼块的实际数据
ArrayList<Entry> yValues = new ArrayList<Entry>();
yValues.add(new Entry(14, 0));
yValues.add(new Entry(14, 1));
yValues.add(new Entry(34, 2));
yValues.add(new Entry(38, 3));
PieDataSet pieDataSet = new PieDataSet(yValues, "s");
// 设置个饼状图之间的距离
pieDataSet.setSliceSpace(0f);
ArrayList<Integer> colors = new ArrayList<Integer>();
colors.add(Color.rgb(205, 205, 205));
colors.add(Color.rgb(114, 188, 223));
colors.add(Color.rgb(255, 123, 124));
colors.add(Color.rgb(57, 135, 200));
pieDataSet.setColors(colors);
DisplayMetrics metrics = getResources().getDisplayMetrics();
float px = 5 * (metrics.densityDpi / 160f);
// 选中态多出的长度
pieDataSet.setSelectionShift(px);
PieData pieData = new PieData(xValues, pieDataSet);
return pieData;
}
use of com.github.mikephil.charting.data.PieData in project HAR-Android by linw7.
the class HistoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
calendar = (CalendarView) findViewById(R.id.calendarView);
pie_chart = (PieChart) findViewById(R.id.pie_chart);
title_bar_back_btn = (ImageView) findViewById(R.id.title_bar_back_btn);
line_chart = (LineChart) findViewById(R.id.line_chart);
xAxis = line_chart.getXAxis();
yAxis = line_chart.getAxisLeft();
yAxisR = line_chart.getAxisRight();
title_bar_back_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(HistoryActivity.this, MainActivity.class);
startActivity(i);
}
});
LineData line_data = get_line_data();
show_chart(line_chart, line_data);
PieData pie_data = get_pie_data();
show_pie_chart(pie_chart, pie_data);
}
Aggregations