use of com.github.mikephil.charting.data.PieData in project MPAndroidChart by PhilJay.
the class SimpleFragment method generatePieData.
/**
* generates less data (1 DataSet, 4 values)
* @return PieData
*/
protected PieData generatePieData() {
int count = 4;
ArrayList<PieEntry> entries1 = new ArrayList<>();
for (int i = 0; i < count; i++) {
entries1.add(new PieEntry((float) ((Math.random() * 60) + 40), "Quarter " + (i + 1)));
}
PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2015");
ds1.setColors(ColorTemplate.VORDIPLOM_COLORS);
ds1.setSliceSpace(2f);
ds1.setValueTextColor(Color.WHITE);
ds1.setValueTextSize(12f);
PieData d = new PieData(ds1);
d.setValueTypeface(tf);
return d;
}
use of com.github.mikephil.charting.data.PieData in project MPAndroidChart by PhilJay.
the class HalfPieChartActivity method setData.
private void setData(int count, float range) {
ArrayList<PieEntry> values = new ArrayList<>();
for (int i = 0; i < count; i++) {
values.add(new PieEntry((float) ((Math.random() * range) + range / 5), parties[i % parties.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(tfLight);
chart.setData(data);
chart.invalidate();
}
use of com.github.mikephil.charting.data.PieData in project MPAndroidChart by PhilJay.
the class PieChartActivity method setData.
private void setData(int count, float range) {
ArrayList<PieEntry> entries = new ArrayList<>();
// the chart.
for (int i = 0; i < count; i++) {
entries.add(new PieEntry((float) ((Math.random() * range) + range / 5), parties[i % parties.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<>();
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(tfLight);
chart.setData(data);
// undo all highlights
chart.highlightValues(null);
chart.invalidate();
}
use of com.github.mikephil.charting.data.PieData in project carat by amplab.
the class SummaryFragment method generatePieData.
protected PieData generatePieData() {
ArrayList<Entry> entries = new ArrayList<Entry>();
ArrayList<String> xVals = new ArrayList<String>();
xVals.add(getString(R.string.chart_wellbehaved));
xVals.add(getString(R.string.chart_hogs));
xVals.add(getString(R.string.chart_bugs));
int wellbehaved = mMainActivity.mWellbehaved;
int hogs = mMainActivity.mHogs;
int bugs = mMainActivity.mBugs;
entries.add(new Entry((float) (wellbehaved), 1));
entries.add(new Entry((float) (hogs), 2));
entries.add(new Entry((float) (bugs), 3));
PieDataSet ds1 = new PieDataSet(entries, getString(R.string.summary_chart_center_text));
ds1.setColors(Constants.CARAT_COLORS);
ds1.setSliceSpace(2f);
PieData d = new PieData(xVals, ds1);
return d;
}
use of com.github.mikephil.charting.data.PieData in project anitrend-app by AniTrend.
the class MediaStatsFragment method showStatusDistribution.
private void showStatusDistribution() {
if (model.getStats() != null && model.getStats().getStatusDistribution() != null) {
configureSeriesStats();
List<PieEntry> pieEntries = getPresenter().getMediaStats(model.getStats().getStatusDistribution());
PieDataSet pieDataSet = new PieDataSet(pieEntries, getString(R.string.title_series_stats));
pieDataSet.setSliceSpace(3f);
pieDataSet.setColors(Color.parseColor("#6fc1ea"), Color.parseColor("#48c76d"), Color.parseColor("#f7464a"), Color.parseColor("#46bfbd"), Color.parseColor("#fba640"));
PieData pieData = new PieData(pieDataSet);
pieData.setValueTextColor(CompatUtil.getColorFromAttr(getContext(), R.attr.titleColor));
pieData.setValueTextSize(10f);
pieData.setValueFormatter(new PercentFormatter());
binding.seriesStats.setData(pieData);
binding.seriesStats.highlightValues(null);
binding.seriesStats.invalidate();
}
}
Aggregations