use of com.github.mikephil.charting.data.PieDataSet in project Gadgetbridge by Freeyourgadget.
the class AbstractWeekChartFragment method refreshDayPie.
private DayData refreshDayPie(DBHandler db, Calendar day, GBDevice device) {
PieData data = new PieData();
List<PieEntry> entries = new ArrayList<>();
PieDataSet set = new PieDataSet(entries, "");
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
float[] totalValues = getTotalsForActivityAmounts(amounts);
float totalValue = 0;
for (float value : totalValues) {
totalValue += value;
entries.add(new PieEntry(value));
}
set.setValueFormatter(getPieValueFormatter());
set.setColors(getColors());
if (totalValue < mTargetValue) {
entries.add(new PieEntry((mTargetValue - totalValue)));
set.addColor(Color.GRAY);
}
data.setDataSet(set);
//this hides the values (numeric) added to the set. These would be shown aside the strings set with addXValue above
data.setDrawValues(false);
return new DayData(data, formatPieValue((int) totalValue));
}
use of com.github.mikephil.charting.data.PieDataSet in project AdMoney by ErnestoGonAr.
the class Reporte_Egresos method addData.
private void addData() {
ArrayList<PieEntry> yEntrys = new ArrayList<>();
for (int i = 0; i < yData.length; i++) {
yEntrys.add(new PieEntry(yData[i], "$ " + yData[i] + " " + xData[i]));
}
PieDataSet pieDataSet = new PieDataSet(yEntrys, "");
pieDataSet.setSliceSpace(3);
pieDataSet.setValueTextSize(24);
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int c : ColorTemplate.MATERIAL_COLORS) colors.add(c);
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);
pieDataSet.setColors(colors);
PieData pieData = new PieData(pieDataSet);
pieChart.setDrawEntryLabels(false);
pieChart.setCenterText("%");
pieChart.setCenterTextSize(30);
pieChart.setUsePercentValues(true);
pieChart.setData(pieData);
pieChart.highlightValue(null);
pieChart.invalidate();
pieChart.animateXY(2000, 2000);
}
use of com.github.mikephil.charting.data.PieDataSet in project AdMoney by ErnestoGonAr.
the class Reporte_Ingresos method addData.
private void addData() {
ArrayList<PieEntry> yEntrys = new ArrayList<>();
for (int i = 0; i < yData.length; i++) {
yEntrys.add(new PieEntry(yData[i], "$ " + yData[i] + " " + xData[i]));
}
PieDataSet pieDataset = new PieDataSet(yEntrys, "");
pieDataset.setSliceSpace(3);
pieDataset.setValueTextSize(24);
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int c : ColorTemplate.MATERIAL_COLORS) colors.add(c);
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);
pieDataset.setColors(colors);
PieData pieData = new PieData(pieDataset);
pieChart.setDrawEntryLabels(false);
pieChart.setUsePercentValues(true);
pieChart.setCenterText("%");
pieChart.setCenterTextSize(30);
pieChart.setData(pieData);
pieChart.highlightValue(null);
pieChart.invalidate();
pieChart.animateXY(2000, 2000);
}
use of com.github.mikephil.charting.data.PieDataSet in project MPAndroidChart by PhilJay.
the class HalfPieChartActivity method setData.
private void setData(int count, float range) {
ArrayList<PieEntry> values = new ArrayList<PieEntry>();
for (int i = 0; i < count; i++) {
values.add(new PieEntry((float) ((Math.random() * range) + range / 5), mParties[i % mParties.length]));
}
PieDataSet dataSet = new PieDataSet(values, "Election Results");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
dataSet.setColors(ColorTemplate.MATERIAL_COLORS);
//dataSet.setSelectionShift(0f);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(mTfLight);
mChart.setData(data);
mChart.invalidate();
}
use of com.github.mikephil.charting.data.PieDataSet in project MPAndroidChart by PhilJay.
the class PieChartActivity method setData.
private void setData(int count, float range) {
float mult = range;
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
// the chart.
for (int i = 0; i < count; i++) {
entries.add(new PieEntry((float) ((Math.random() * mult) + mult / 5), mParties[i % mParties.length], getResources().getDrawable(R.drawable.star)));
}
PieDataSet dataSet = new PieDataSet(entries, "Election Results");
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());
dataSet.setColors(colors);
//dataSet.setSelectionShift(0f);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(mTfLight);
mChart.setData(data);
// undo all highlights
mChart.highlightValues(null);
mChart.invalidate();
}
Aggregations