use of com.github.mikephil.charting.data.PieDataSet 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.PieDataSet 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.PieDataSet 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.PieDataSet in project Dxditor by kimi2009.
the class MainActivity method setGjxxData.
/**
* 设置告警信息的数据
*
* @param gjxxlist
*/
@Override
public void setGjxxData(List<GjxxBean> gjxxlist) {
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
// the chart.
for (int i = 0; i < gjxxlist.size(); i++) {
entries.add(new PieEntry(gjxxlist.get(i).getTypeProportion() * 100, gjxxlist.get(i).getTypeName()));
}
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setDrawIcons(false);
dataSet.setSliceSpace(3f);
dataSet.setIconsOffset(new MPPointF(0, 40));
dataSet.setSelectionShift(5f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int c : ColorTemplate.VORDIPLOM_COLORS) colors.add(c);
for (int c : ColorTemplate.JOYFUL_COLORS) colors.add(c);
for (int c : ColorTemplate.COLORFUL_COLORS) colors.add(c);
for (int c : ColorTemplate.LIBERTY_COLORS) colors.add(c);
for (int c : ColorTemplate.PASTEL_COLORS) colors.add(c);
colors.add(ColorTemplate.getHoloBlue());
// 26个颜色
dataSet.setColors(colors);
// dataSet.setSelectionShift(0f);
dataSet.setValueLinePart1OffsetPercentage(80.f);
dataSet.setValueLinePart1Length(0.2f);
dataSet.setValueLinePart2Length(0.4f);
// dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.BLACK);
gjpiechart.setData(data);
// undo all highlights
gjpiechart.highlightValues(null);
gjpiechart.invalidate();
}
use of com.github.mikephil.charting.data.PieDataSet in project MPAndroidChart by PhilJay.
the class ListViewMultiChartActivity method generateDataPie.
/**
* generates a random ChartData object with just one DataSet
*
* @return Pie data
*/
private PieData generateDataPie() {
ArrayList<PieEntry> entries = new ArrayList<>();
for (int i = 0; i < 4; i++) {
entries.add(new PieEntry((float) ((Math.random() * 70) + 30), "Quarter " + (i + 1)));
}
PieDataSet d = new PieDataSet(entries, "");
// space between slices
d.setSliceSpace(2f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
return new PieData(d);
}
Aggregations